Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2718,6 +2718,10 @@ address StubGenerator::generate_base64_decodeBlock() {
__ BIND(L_finalBit);
// Now have 1 to 63 bytes left to decode

// A padded Base64 tail shorter than one complete block is handled by Java.
__ cmpl(length, 4);
__ jcc(Assembler::less, L_bruteForce);

// I was going to let Java take care of the final fragment
// however it will repeatedly call this routine for every 4 bytes
// of input data, so handle the rest here.
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/opto/c2compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ bool C2Compiler::is_intrinsic_supported(vmIntrinsics::ID id) {
break;
case vmIntrinsics::_compress_i:
case vmIntrinsics::_compress_l:
if (!Matcher::match_rule_supported(Op_CompressBits)) return false;
break;
// disable because of JDK-8350896
return false;
case vmIntrinsics::_expand_i:
case vmIntrinsics::_expand_l:
if (!Matcher::match_rule_supported(Op_ExpandBits)) return false;
break;
// disable because of JDK-8350896
return false;
case vmIntrinsics::_numberOfLeadingZeros_i:
if (!Matcher::match_rule_supported(Op_CountLeadingZerosI)) return false;
break;
Expand Down
10 changes: 10 additions & 0 deletions src/hotspot/share/opto/loopnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4395,6 +4395,7 @@ const TypeInt* PhaseIdealLoop::filtered_type( Node *n, Node* n_ctrl) {
Node* region = phi->in(0);
assert(n_ctrl == nullptr || n_ctrl == region, "ctrl parameter must be region");
if (region && region != C->top()) {
// Compute the union over the types of the paths/inputs.
for (uint i = 1; i < phi->req(); i++) {
Node* val = phi->in(i);
Node* use_c = region->in(i);
Expand All @@ -4405,10 +4406,17 @@ const TypeInt* PhaseIdealLoop::filtered_type( Node *n, Node* n_ctrl) {
} else {
filtered_t = filtered_t->meet(val_t)->is_int();
}
} else {
// We found no constriant, so we have to assume that this path
// is unconstrained, i.e. it could have the whole int range.
filtered_t = TypeInt::INT;
}
}
}
}

// The filtered type may be worse than what we already know
// about n, so take the intersection.
const TypeInt* n_t = _igvn.type(n)->is_int();
if (filtered_t != nullptr) {
n_t = n_t->join(filtered_t)->is_int();
Expand All @@ -4419,6 +4427,8 @@ const TypeInt* PhaseIdealLoop::filtered_type( Node *n, Node* n_ctrl) {

//------------------------------filtered_type_from_dominators--------------------------------
// Return a possibly more restrictive type for val based on condition control flow of dominators
// Note: we can also return "nullptr", which means "no constraint", and should be interpreted
// as if we returned TypeInt::INT.
const TypeInt* PhaseIdealLoop::filtered_type_from_dominators( Node* val, Node *use_ctrl) {
if (val->is_Con()) {
return val->bottom_type()->is_int();
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/opto/vectornode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2214,9 +2214,7 @@ Node* XorVNode::Ideal_XorV_VectorMaskCmp(PhaseGVN* phase, bool can_reshape) {
Node* in1 = in(1);
Node* in2 = in(2);
// Transformations for predicated vectors are not supported for now.
if (is_predicated_vector() ||
in1->is_predicated_vector() ||
in2->is_predicated_vector()) {
if (is_predicated_vector()) {
return nullptr;
}

Expand All @@ -2240,6 +2238,7 @@ Node* XorVNode::Ideal_XorV_VectorMaskCmp(PhaseGVN* phase, bool can_reshape) {
}
if (in1->Opcode() != Op_VectorMaskCmp ||
in1->outcnt() != 1 ||
in1->is_predicated_vector() ||
!in1->as_VectorMaskCmp()->predicate_can_be_negated() ||
!VectorNode::is_all_ones_vector(in2)) {
return nullptr;
Expand Down
65 changes: 49 additions & 16 deletions src/java.base/share/classes/java/lang/AbstractStringBuilder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -267,6 +267,9 @@ private static boolean needsNewBuffer(byte[] value, byte coder, int newCapacity,
private static byte[] ensureCapacityNewCoder(byte[] value, byte coder, int count,
int minimumCapacity, byte newCoder) {
assert coder == newCoder || newCoder == UTF16 : "bad new coder UTF16 -> LATIN1";
if (minimumCapacity < 0) {
throwExcessiveLengthError();
}
// overflow-conscious code
// Compute the new larger size if growth is requested, otherwise keep the capacity the same
int oldCapacity = value.length >> coder;
Expand Down Expand Up @@ -303,6 +306,9 @@ private static byte[] ensureCapacityNewCoder(byte[] value, byte coder, int count
* @param minimumCapacity the new minimum capacity
*/
private static byte[] ensureCapacitySameCoder(byte[] value, byte coder, int minimumCapacity) {
if (minimumCapacity < 0) {
throwExcessiveLengthError();
}
// overflow-conscious code
int oldCapacity = value.length >> coder;
if (minimumCapacity - oldCapacity > 0) {
Expand Down Expand Up @@ -334,17 +340,17 @@ private static byte[] inflateToUTF16(byte[] value, int count) {
* @param value the current buffer
* @param coder of the current buffer
* @param minCapacity the desired minimum capacity
* @throws OutOfMemoryError if minCapacity is less than zero or
* greater than (Integer.MAX_VALUE >> coder)
* @throws OutOfMemoryError if {@code minCapacity} is out of bounds
*/
private static int newCapacity(byte[] value, byte coder, int minCapacity) {
assert minCapacity >= 0 : "Invalid minimum capacity: " + minCapacity;
int oldLength = value.length;
int newLength = minCapacity << coder;
int growth = newLength - oldLength;
int length = ArraysSupport.newLength(oldLength, growth, oldLength + (2 << coder));
if (length == Integer.MAX_VALUE) {
throw new OutOfMemoryError("Required length exceeds implementation limit");
long newLength = (long) minCapacity << coder;
if (newLength < 0 || newLength >= Integer.MAX_VALUE) {
throwExcessiveLengthError();
}
int growth = (int) newLength - oldLength;
int length = ArraysSupport.newLength(oldLength, growth, oldLength + (2 << coder));
return length >> coder;
}

Expand Down Expand Up @@ -2085,9 +2091,9 @@ long prepend(long lengthCoder, byte[] buffer) {
private AbstractStringBuilder repeat(char c, int count) {
byte coder = this.coder;
int prevCount = this.count;
int limit = prevCount + count;
byte[] value = this.value;
byte newCoder = (byte) (coder | StringLatin1.coderFromChar(c));
int limit = repeatLimit(newCoder, prevCount, 1, count);
if (needsNewBuffer(value, coder, limit, newCoder)) {
this.value = value = ensureCapacityNewCoder(value, coder, prevCount, limit, newCoder);
this.coder = coder = newCoder;
Expand Down Expand Up @@ -2183,36 +2189,63 @@ public AbstractStringBuilder repeat(CharSequence cs, int count) {
byte coder = this.coder;
int offset = this.count;
byte[] value = this.value;
int valueLength = length << coder;
if ((Integer.MAX_VALUE - offset) / count < valueLength) {
throw new OutOfMemoryError("Required length exceeds implementation limit");
}
int total = count * length;
int limit = offset + total;
final int limit;
if (cs instanceof String str) {
byte newCoder = (byte)(coder | str.coder());
limit = repeatLimit(newCoder, offset, length, count);
if (needsNewBuffer(value, coder, limit, newCoder)) {
this.value = value = ensureCapacityNewCoder(value, coder, offset, limit, newCoder);
this.coder = coder = newCoder;
}
str.getBytes(value, offset, newCoder);
} else if (cs instanceof AbstractStringBuilder asb) {
byte newCoder = (byte)(coder | asb.coder);
limit = repeatLimit(newCoder, offset, length, count);
if (needsNewBuffer(value, coder, limit, newCoder)) {
this.value = value = ensureCapacityNewCoder(value, coder, offset, limit, newCoder);
this.coder = coder = newCoder;
}
asb.getBytes(value, offset, newCoder);
} else {
limit = repeatLimit(coder, offset, length, count);
byte[] currValue = ensureCapacitySameCoder(value, coder, limit);
value = appendChars(currValue, coder, offset, cs, 0, length);
if (currValue != value) {
this.coder = coder = UTF16;
}
this.value = value;
}
String.repeatCopyRest(value, offset << coder, total << coder, length << coder);
String.repeatCopyRest(value, offset << coder, (count * length) << coder, length << coder);
this.count = limit;
return this;
}

/**
* {@return the new {@linkplain #count length} (in {@code char}s) after
* appending the given sequence with specified repetitions}
*
* @param coder the {@linkplain #coder coder} that will be used for encoding
* @param offset the {@linkplain #count offset} (in {@code char}s) to start appending at
* @param seqLength the length in {@code char}s of the sequence to be repeated
* @param seqRepetition the repetition count
*
* @throws OutOfMemoryError If the resultant length is out of bounds
*/
private static int repeatLimit(int coder, int offset, int seqLength, int seqRepetition) {
assert offset >= 0 : "Invalid offset: " + offset;
assert seqLength >= 0 : "Invalid sequence length: " + seqLength;
assert seqRepetition >= 0 : "Invalid sequence repetition count: " + seqRepetition;
long repeatedSeqLength = (long) seqLength * seqRepetition;
long limit = (long) offset + repeatedSeqLength;
long encodedLimit = limit << coder;
if (limit < 0 || encodedLimit < 0 || encodedLimit >= Integer.MAX_VALUE) {
throwExcessiveLengthError();
}
return (int) limit;
}

private static void throwExcessiveLengthError() {
throw new OutOfMemoryError("Required length exceeds implementation limit");
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -201,6 +201,15 @@ class DHServerKeyExchangeMessage extends HandshakeMessage {
}

if (x509Credentials == null) {
// Only anonymous key exchange is unsigned. For any other
// cipher suite the server Certificate message must have been
// received before the ServerKeyExchange message.
if (!chc.negotiatedCipherSuite.isAnonymous()) {
throw chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
"No X.509 credentials negotiated for " +
"DH ServerKeyExchange: missing Certificate");
}

// anonymous, no authentication, no signature
if (m.hasRemaining()) {
throw chc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -244,6 +244,15 @@ class ECDHServerKeyExchangeMessage extends HandshakeMessage {
}

if (x509Credentials == null) {
// Only anonymous key exchange is unsigned. For any other
// cipher suite the server Certificate message must have been
// received before the ServerKeyExchange message.
if (!chc.negotiatedCipherSuite.isAnonymous()) {
throw chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
"No X.509 credentials negotiated for " +
"ECDH ServerKeyExchange: missing Certificate");
}

// anonymous, no authentication, no signature
if (m.hasRemaining()) {
throw chc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -133,6 +133,15 @@ public void consume(ConnectionContext context,
// The consuming happens in client side only.
ClientHandshakeContext chc = (ClientHandshakeContext)context;

// Check for an unprocessed server Certificate message. If
// that handshake consumer is still present then that expected
// message was not sent.
if (chc.handshakeConsumers.containsKey(
SSLHandshake.CERTIFICATE.id)) {
throw chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
"Unexpected ServerHelloDone handshake message.");
}

SSLConsumer certStatCons = chc.handshakeConsumers.remove(
SSLHandshake.CERTIFICATE_STATUS.id);
if (certStatCons != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -92,6 +92,15 @@ public void consume(ConnectionContext context,
// clean up this consumer
chc.handshakeConsumers.remove(SSLHandshake.SERVER_KEY_EXCHANGE.id);

// If the Certificate consumer is still registered, the server
// omitted the required Certificate message before sending
// ServerKeyExchange.
if (chc.handshakeConsumers.containsKey(
SSLHandshake.CERTIFICATE.id)) {
throw chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
"Unexpected ServerKeyExchange handshake message.");
}

// Any receipt/consumption of the CertificateRequest before
// ServerKeyExchange is a state machine violation. We may not
// know for sure if an early CR message is a violation though until
Expand Down Expand Up @@ -131,4 +140,3 @@ public void consume(ConnectionContext context,
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ byte[] encrypt(HandshakeContext hc, SSLSessionImpl session) {

ByteBuffer aad = ByteBuffer.allocate(Integer.BYTES + 1);
aad.putInt(key.num).put(compressed);
aad.flip();
c.updateAAD(aad);

encrypted = c.doFinal(data);
Expand Down Expand Up @@ -276,6 +277,7 @@ ByteBuffer decrypt(HandshakeContext hc) {
byte compressed = data.get();
ByteBuffer aad = ByteBuffer.allocate(Integer.BYTES + 1);
aad.putInt(keyID).put(compressed);
aad.flip();
c.updateAAD(aad);

// use getOutputSize to avoid a ShortBufferException
Expand Down
33 changes: 33 additions & 0 deletions src/java.base/share/conf/security/java.security
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,39 @@ sun.security.krb5.disableReferrals=false
# be overwritten with a System property (-Dsun.security.krb5.maxReferrals).
sun.security.krb5.maxReferrals=5

#
# Policy for Kerberos service transited field checking:
#
# In cross-realm authentication, if the service ticket includes a non-empty
# transited field but the ticket flags do not have TRANSIT-POLICY-CHECKED set,
# the application server should perform the transited-realm checks itself.
# This is required in Section 2.7 of RFC 4120.
#
# This property determines whether the server performs the transited-realm
# check when the service ticket does not have the TRANSIT-POLICY-CHECKED flag
# set. If the value is set to "true", the JDK performs the check when
# GSSContext.acceptSecContext is called to process the incoming context-
# establishment token, which contains the service ticket.
#
# The check uses the explicit paths configured in the [capaths] section of
# krb5.conf, or if that is not configured, uses an implicit hierarchical
# relationship between realm names. If any of the realms encoded in the
# transited field are not allowed, the context establishment will fail.
# If the value is set to "false", no check is performed. The default value
# of this property is "true".
#
# This property should be used at your own risk.
#
# If a system property of the same name is also specified, it supersedes the
# security property value defined here.
#
# Note: This property is currently used by the Java Kerberos GSS-API mechanism
# of the JDK Reference implementation. An application using native GSS-API
# does not use this property; instead it follows the policy of the underlying
# native GSS library. Support for this property is not guaranteed in other
# Java SE implementations.
sun.security.krb5.acceptor.checkTransitedPolicy = true

#
# This property contains a list of disabled EC Named Curves that can be included
# in the jdk.[tls|certpath|jar].disabledAlgorithms properties. To include this
Expand Down
4 changes: 4 additions & 0 deletions src/java.base/windows/native/libnet/DefaultProxySelector.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,20 +330,24 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
jhost = (*env)->NewString(env, current->host, (jsize)wcslen(current->host));
if (jhost == NULL || (*env)->ExceptionCheck(env)) {
proxy_array = NULL;
goto noproxy;
}
isa = (*env)->CallStaticObjectMethod(env, isaddr_class,
isaddr_createUnresolvedID, jhost,
current->port);
if (isa == NULL || (*env)->ExceptionCheck(env)) {
proxy_array = NULL;
goto noproxy;
}
proxy = (*env)->NewObject(env, proxy_class, proxy_ctrID, type_proxy, isa);
if (proxy == NULL || (*env)->ExceptionCheck(env)) {
proxy_array = NULL;
goto noproxy;
}
(*env)->SetObjectArrayElement(env, proxy_array, index, proxy);
if ((*env)->ExceptionCheck(env)) {
proxy_array = NULL;
goto noproxy;
}
index++;
}
Expand Down
Loading
Loading