Skip to content

Commit 1d74df5

Browse files
committed
Merge
2 parents 432d962 + 618917e commit 1d74df5

File tree

23 files changed

+1184
-98
lines changed

23 files changed

+1184
-98
lines changed

hotspot/src/share/vm/opto/loopnode.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ Node *LoopLimitNode::Ideal(PhaseGVN *phase, bool can_reshape) {
12201220

12211221
const TypeInt* init_t = phase->type(in(Init) )->is_int();
12221222
const TypeInt* limit_t = phase->type(in(Limit))->is_int();
1223-
int stride_p;
1223+
jlong stride_p;
12241224
jlong lim, ini;
12251225
julong max;
12261226
if (stride_con > 0) {
@@ -1229,10 +1229,10 @@ Node *LoopLimitNode::Ideal(PhaseGVN *phase, bool can_reshape) {
12291229
ini = init_t->_lo;
12301230
max = (julong)max_jint;
12311231
} else {
1232-
stride_p = -stride_con;
1232+
stride_p = -(jlong)stride_con;
12331233
lim = init_t->_hi;
12341234
ini = limit_t->_lo;
1235-
max = (julong)min_jint;
1235+
max = (julong)(juint)min_jint; // double cast to get 0x0000000080000000, not 0xffffffff80000000
12361236
}
12371237
julong range = lim - ini + stride_p;
12381238
if (range <= max) {

hotspot/src/share/vm/opto/superword.cpp

Lines changed: 514 additions & 16 deletions
Large diffs are not rendered by default.

hotspot/src/share/vm/opto/superword.hpp

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,18 +452,63 @@ class SuperWord : public ResourceObj {
452452

453453
//------------------------------SWPointer---------------------------
454454
// Information about an address for dependence checking and vector alignment
455+
//
456+
// We parse and represent pointers of the simple form:
457+
//
458+
// pointer = adr + offset + invar + scale * ConvI2L(iv)
459+
//
460+
// Where:
461+
//
462+
// adr: the base address of an array (base = adr)
463+
// OR
464+
// some address to off-heap memory (base = TOP)
465+
//
466+
// offset: a constant offset
467+
// invar: a runtime variable, which is invariant during the loop
468+
// scale: scaling factor
469+
// iv: loop induction variable
470+
//
471+
// But more precisely, we parse the composite-long-int form:
472+
//
473+
// pointer = adr + long_offset + long_invar + long_scale * ConvI2L(int_offset + inv_invar + int_scale * iv)
474+
//
475+
// pointer = adr + long_offset + long_invar + long_scale * ConvI2L(int_index)
476+
// int_index = int_offset + int_invar + int_scale * iv
477+
//
478+
// However, for aliasing and adjacency checks (e.g. SWPointer::cmp()) we always use the simple form to make
479+
// decisions. Hence, we must make sure to only create a "valid" SWPointer if the optimisations based on the
480+
// simple form produce the same result as the compound-long-int form would. Intuitively, this depends on
481+
// if the int_index overflows, but the precise conditions are given in SWPointer::is_safe_to_use_as_simple_form().
482+
//
483+
// ConvI2L(int_index) = ConvI2L(int_offset + int_invar + int_scale * iv)
484+
// = Convi2L(int_offset) + ConvI2L(int_invar) + ConvI2L(int_scale) * ConvI2L(iv)
485+
//
486+
// scale = long_scale * ConvI2L(int_scale)
487+
// offset = long_offset + long_scale * ConvI2L(int_offset)
488+
// invar = long_invar + long_scale * ConvI2L(int_invar)
489+
//
490+
// pointer = adr + offset + invar + scale * ConvI2L(iv)
491+
//
455492
class SWPointer VALUE_OBJ_CLASS_SPEC {
456493
protected:
457494
MemNode* _mem; // My memory reference node
458495
SuperWord* _slp; // SuperWord class
459496

460-
Node* _base; // NULL if unsafe nonheap reference
461-
Node* _adr; // address pointer
497+
// Components of the simple form:
498+
Node* _base; // Base address of an array OR NULL if some off-heap memory.
499+
Node* _adr; // Same as _base if an array pointer OR some off-heap memory pointer.
462500
jint _scale; // multiplier for iv (in bytes), 0 if no loop iv
463501
jint _offset; // constant offset (in bytes)
464502
Node* _invar; // invariant offset (in bytes), NULL if none
465503
bool _negate_invar; // if true then use: (0 - _invar)
466504

505+
// The int_index components of the compound-long-int form. Used to decide if it is safe to use the
506+
// simple form rather than the compound-long-int form that was parsed.
507+
bool _has_int_index_after_convI2L;
508+
int _int_index_after_convI2L_offset;
509+
Node* _int_index_after_convI2L_invar;
510+
int _int_index_after_convI2L_scale;
511+
467512
PhaseIdealLoop* phase() { return _slp->phase(); }
468513
IdealLoopTree* lpt() { return _slp->lpt(); }
469514
PhiNode* iv() { return _slp->iv(); } // Induction var
@@ -480,6 +525,8 @@ class SWPointer VALUE_OBJ_CLASS_SPEC {
480525
// Match: offset is (k [+/- invariant])
481526
bool offset_plus_k(Node* n, bool negate = false);
482527

528+
bool is_safe_to_use_as_simple_form(Node* base, Node* adr) const;
529+
483530
public:
484531
enum CMP {
485532
Less = 1,
@@ -507,12 +554,45 @@ class SWPointer VALUE_OBJ_CLASS_SPEC {
507554
int memory_size() { return _mem->memory_size(); }
508555

509556
// Comparable?
557+
// We compute if and how two SWPointers can alias at runtime, i.e. if the two addressed regions of memory can
558+
// ever overlap. There are essentially 3 relevant return states:
559+
// - NotComparable: Synonymous to "unknown aliasing".
560+
// We have no information about how the two SWPointers can alias. They could overlap, refer
561+
// to another location in the same memory object, or point to a completely different object.
562+
// -> Memory edge required. Aliasing unlikely but possible.
563+
//
564+
// - Less / Greater: Synonymous to "never aliasing".
565+
// The two SWPointers may point into the same memory object, but be non-aliasing (i.e. we
566+
// know both address regions inside the same memory object, but these regions are non-
567+
// overlapping), or the SWPointers point to entirely different objects.
568+
// -> No memory edge required. Aliasing impossible.
569+
//
570+
// - Equal: Synonymous to "overlap, or point to different memory objects".
571+
// The two SWPointers either overlap on the same memory object, or point to two different
572+
// memory objects.
573+
// -> Memory edge required. Aliasing likely.
574+
//
575+
// In a future refactoring, we can simplify to two states:
576+
// - NeverAlias: instead of Less / Greater
577+
// - MayAlias: instead of Equal / NotComparable
578+
//
579+
// Two SWPointer are "comparable" (Less / Greater / Equal), iff all of these conditions apply:
580+
// 1) Both are valid, i.e. expressible in the compound-long-int or simple form.
581+
// 2) The adr are identical, or both are array bases of different arrays.
582+
// 3) They have identical scale.
583+
// 4) They have identical invar.
584+
// 5) The difference in offsets is limited: abs(offset0 - offset1) < 2^31.
510585
int cmp(SWPointer& q) {
511586
if (valid() && q.valid() &&
512587
(_adr == q._adr || _base == _adr && q._base == q._adr) &&
513588
_scale == q._scale &&
514589
_invar == q._invar &&
515590
_negate_invar == q._negate_invar) {
591+
jlong difference = abs(java_subtract((jlong)_offset, (jlong)q._offset));
592+
jlong max_diff = (jlong)1 << 31;
593+
if (difference >= max_diff) {
594+
return NotComparable;
595+
}
516596
bool overlap = q._offset < _offset + memory_size() &&
517597
_offset < q._offset + q.memory_size();
518598
return overlap ? Equal : (_offset < q._offset ? Less : Greater);
@@ -529,6 +609,13 @@ class SWPointer VALUE_OBJ_CLASS_SPEC {
529609
static bool comparable(int cmp) { return cmp < NotComparable; }
530610

531611
void print();
612+
613+
static bool try_AddI_no_overflow(jint offset1, jint offset2, jint& result);
614+
static bool try_SubI_no_overflow(jint offset1, jint offset2, jint& result);
615+
static bool try_AddSubI_no_overflow(jint offset1, jint offset2, bool is_sub, jint& result);
616+
static bool try_LShiftI_no_overflow(jint offset1, int offset2, jint& result);
617+
static bool try_MulI_no_overflow(jint offset1, jint offset2, jint& result);
618+
532619
};
533620

534621
#endif // SHARE_VM_OPTO_SUPERWORD_HPP

jdk/src/share/classes/com/sun/jndi/ldap/Obj.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -241,6 +241,10 @@ static Object decodeObject(Attributes attrs)
241241
ClassLoader cl = helper.getURLClassLoader(codebases);
242242
return deserializeObject((byte[])attr.get(), cl);
243243
} else if ((attr = attrs.get(JAVA_ATTRIBUTES[REMOTE_LOC])) != null) {
244+
// javaRemoteLocation attribute (RMI stub will be created)
245+
if (!VersionHelper12.isSerialDataAllowed()) {
246+
throw new NamingException("Object deserialization is not allowed");
247+
}
244248
// For backward compatibility only
245249
return decodeRmiObject(
246250
(String)attrs.get(JAVA_ATTRIBUTES[CLASSNAME]).get(),

jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper12.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -40,13 +40,13 @@ final class VersionHelper12 extends VersionHelper {
4040
"com.sun.jndi.ldap.object.trustURLCodebase";
4141

4242
// System property to control whether classes are allowed to be loaded from
43-
// 'javaSerializedData' attribute
43+
// 'javaSerializedData', 'javaRemoteLocation' or 'javaReferenceAddress' attributes.
4444
private static final String TRUST_SERIAL_DATA_PROPERTY =
4545
"com.sun.jndi.ldap.object.trustSerialData";
4646

4747
/**
48-
* Determines whether objects may be deserialized from the content of
49-
* 'javaSerializedData' attribute.
48+
* Determines whether objects may be deserialized or reconstructed from a content of
49+
* 'javaSerializedData', 'javaRemoteLocation' or 'javaReferenceAddress' LDAP attributes.
5050
*/
5151
private static final boolean trustSerialData;
5252

@@ -56,7 +56,7 @@ final class VersionHelper12 extends VersionHelper {
5656
static {
5757
String trust = getPrivilegedProperty(TRUST_URL_CODEBASE_PROPERTY, "false");
5858
trustURLCodebase = "true".equalsIgnoreCase(trust);
59-
String trustSDString = getPrivilegedProperty(TRUST_SERIAL_DATA_PROPERTY, "true");
59+
String trustSDString = getPrivilegedProperty(TRUST_SERIAL_DATA_PROPERTY, "false");
6060
trustSerialData = "true".equalsIgnoreCase(trustSDString);
6161
}
6262

@@ -72,8 +72,9 @@ private static String getPrivilegedProperty(String propertyName, String defaultV
7272
VersionHelper12() {} // Disallow external from creating one of these.
7373

7474
/**
75-
* Returns true if deserialization of objects from 'javaSerializedData'
76-
* and 'javaReferenceAddress' LDAP attributes is allowed.
75+
* Returns true if deserialization or reconstruction of objects from
76+
* 'javaSerializedData', 'javaRemoteLocation' and 'javaReferenceAddress'
77+
* LDAP attributes is allowed.
7778
*
7879
* @return true if deserialization is allowed; false - otherwise
7980
*/

jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import sun.security.krb5.*;
4242
import sun.security.jgss.krb5.Krb5Util;
4343
import sun.security.krb5.Credentials;
44-
import sun.misc.HexDumpEncoder;
4544

4645
/**
4746
* <p> This <code>LoginModule</code> authenticates users using
@@ -786,15 +785,11 @@ private void attemptAuthentication(boolean getPasswdFromSharedState)
786785

787786
if (debug) {
788787
System.out.println("principal is " + principal);
789-
HexDumpEncoder hd = new HexDumpEncoder();
790788
if (ktab != null) {
791789
System.out.println("Will use keytab");
792790
} else if (storeKey) {
793791
for (int i = 0; i < encKeys.length; i++) {
794-
System.out.println("EncryptionKey: keyType=" +
795-
encKeys[i].getEType() +
796-
" keyBytes (hex dump)=" +
797-
hd.encodeBuffer(encKeys[i].getBytes()));
792+
System.out.println(encKeys[i].toString());
798793
}
799794
}
800795
}
@@ -895,7 +890,7 @@ private void promptForPass(boolean getPasswdFromSharedState)
895890
}
896891
if (debug) {
897892
System.out.println
898-
("password is " + new String(password));
893+
("Get password from shared state");
899894
}
900895
return;
901896
}

jdk/src/share/classes/java/net/doc-files/net-properties.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@ <H2>Misc HTTP properties</H2>
220220
property is defined, then its value will be used a the domain
221221
name.</P>
222222
</OL>
223+
<LI><P><B>{@systemProperty jdk.http.maxHeaderSize}</B> (default: 393216 or 384kB)<BR>
224+
This is the maximum header field section size that a client is prepared to accept.
225+
This is computed as the sum of the size of the uncompressed header name, plus
226+
the size of the uncompressed header value, plus an overhead of 32 bytes for
227+
each field section line. If a peer sends a field section that exceeds this
228+
size a {@link java.net.ProtocolException ProtocolException} will be raised.
229+
This applies to all versions of the HTTP protocol. A value of zero or a negative
230+
value means no limit. If left unspecified, the default value is 393216 bytes.
223231
</UL>
224232
<P>All these properties are checked only once at startup.</P>
225233
<a name="AddressCache"></a>

jdk/src/share/classes/java/text/MessageFormat.java

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.io.InvalidObjectException;
4242
import java.io.IOException;
4343
import java.io.ObjectInputStream;
44+
import java.io.ObjectStreamException;
4445
import java.text.DecimalFormat;
4546
import java.util.ArrayList;
4647
import java.util.Arrays;
@@ -960,6 +961,8 @@ public Object[] parse(String source, ParsePosition pos) {
960961
maximumArgumentNumber = argumentNumbers[i];
961962
}
962963
}
964+
965+
// Constructors/applyPattern ensure that resultArray.length < MAX_ARGUMENT_INDEX
963966
Object[] resultArray = new Object[maximumArgumentNumber + 1];
964967

965968
int patternOffset = 0;
@@ -1210,6 +1213,9 @@ protected Object readResolve() throws InvalidObjectException {
12101213
* @serial
12111214
*/
12121215
private int[] argumentNumbers = new int[INITIAL_FORMATS];
1216+
// Implementation limit for ArgumentIndex pattern element. Valid indices must
1217+
// be less than this value
1218+
private static final int MAX_ARGUMENT_INDEX = 10000;
12131219

12141220
/**
12151221
* One less than the number of entries in <code>offsets</code>. Can also be thought of
@@ -1434,6 +1440,11 @@ private void makeFormat(int position, int offsetNumber,
14341440
+ argumentNumber);
14351441
}
14361442

1443+
if (argumentNumber >= MAX_ARGUMENT_INDEX) {
1444+
throw new IllegalArgumentException(
1445+
argumentNumber + " exceeds the ArgumentIndex implementation limit");
1446+
}
1447+
14371448
// resize format information arrays if necessary
14381449
if (offsetNumber >= formats.length) {
14391450
int newLength = formats.length * 2;
@@ -1580,24 +1591,52 @@ private static final void copyAndFixQuotes(String source, int start, int end,
15801591
* @throws InvalidObjectException if the objects read from the stream is invalid.
15811592
*/
15821593
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
1583-
in.defaultReadObject();
1584-
boolean isValid = maxOffset >= -1
1585-
&& formats.length > maxOffset
1586-
&& offsets.length > maxOffset
1587-
&& argumentNumbers.length > maxOffset;
1594+
ObjectInputStream.GetField fields = in.readFields();
1595+
if (fields.defaulted("argumentNumbers") || fields.defaulted("offsets")
1596+
|| fields.defaulted("formats") || fields.defaulted("locale")
1597+
|| fields.defaulted("pattern") || fields.defaulted("maxOffset")){
1598+
throw new InvalidObjectException("Stream has missing data");
1599+
}
1600+
1601+
locale = (Locale) fields.get("locale", null);
1602+
String patt = (String) fields.get("pattern", null);
1603+
int maxOff = fields.get("maxOffset", -2);
1604+
int[] argNums = ((int[]) fields.get("argumentNumbers", null)).clone();
1605+
int[] offs = ((int[]) fields.get("offsets", null)).clone();
1606+
Format[] fmts = ((Format[]) fields.get("formats", null)).clone();
1607+
1608+
// Check arrays/maxOffset have correct value/length
1609+
boolean isValid = maxOff >= -1 && argNums.length > maxOff
1610+
&& offs.length > maxOff && fmts.length > maxOff;
1611+
1612+
// Check the correctness of arguments and offsets
15881613
if (isValid) {
1589-
int lastOffset = pattern.length() + 1;
1590-
for (int i = maxOffset; i >= 0; --i) {
1591-
if ((offsets[i] < 0) || (offsets[i] > lastOffset)) {
1614+
int lastOffset = patt.length() + 1;
1615+
for (int i = maxOff; i >= 0; --i) {
1616+
if (argNums[i] < 0 || argNums[i] >= MAX_ARGUMENT_INDEX
1617+
|| offs[i] < 0 || offs[i] > lastOffset) {
15921618
isValid = false;
15931619
break;
15941620
} else {
1595-
lastOffset = offsets[i];
1621+
lastOffset = offs[i];
15961622
}
15971623
}
15981624
}
1625+
15991626
if (!isValid) {
1600-
throw new InvalidObjectException("Could not reconstruct MessageFormat from corrupt stream.");
1627+
throw new InvalidObjectException("Stream has invalid data");
16011628
}
1629+
maxOffset = maxOff;
1630+
pattern = patt;
1631+
offsets = offs;
1632+
formats = fmts;
1633+
argumentNumbers = argNums;
1634+
}
1635+
1636+
/**
1637+
* Serialization without data not supported for this class.
1638+
*/
1639+
private void readObjectNoData() throws ObjectStreamException {
1640+
throw new InvalidObjectException("Deserialized MessageFormat objects need data");
16021641
}
16031642
}

jdk/src/share/classes/javax/security/auth/kerberos/KerberosKey.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -233,9 +233,9 @@ public String toString() {
233233
if (destroyed) {
234234
return "Destroyed Principal";
235235
}
236-
return "Kerberos Principal " + principal.toString() +
237-
"Key Version " + versionNum +
238-
"key " + key.toString();
236+
return "KerberosKey: principal " + principal +
237+
", version " + versionNum +
238+
", key " + key.toString();
239239
}
240240

241241
/**

0 commit comments

Comments
 (0)