Skip to content

Commit d7a08bc

Browse files
authored
Merge branch 'master' into goetz_backport_8349188
2 parents 96603a7 + 9ae44ef commit d7a08bc

File tree

34 files changed

+3761
-2078
lines changed

34 files changed

+3761
-2078
lines changed

src/hotspot/os/linux/cgroupSubsystem_linux.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "utilities/globalDefinitions.hpp"
3636

3737
// controller names have to match the *_IDX indices
38-
static const char* cg_controller_name[] = { "cpu", "cpuset", "cpuacct", "memory", "pids" };
38+
static const char* cg_controller_name[] = { "cpuset", "cpu", "cpuacct", "memory", "pids" };
3939

4040
CgroupSubsystem* CgroupSubsystemFactory::create() {
4141
CgroupV1MemoryController* memory = NULL;
@@ -159,9 +159,10 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
159159
char buf[MAXPATHLEN+1];
160160
char *p;
161161
bool is_cgroupsV2;
162-
// true iff all required controllers, memory, cpu, cpuset, cpuacct are enabled
162+
// true iff all required controllers, memory, cpu, cpuacct are enabled
163163
// at the kernel level.
164164
// pids might not be enabled on older Linux distros (SLES 12.1, RHEL 7.1)
165+
// cpuset might not be enabled on newer Linux distros (Fedora 41)
165166
bool all_required_controllers_enabled;
166167

167168
/*
@@ -193,6 +194,7 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
193194
cg_infos[MEMORY_IDX]._hierarchy_id = hierarchy_id;
194195
cg_infos[MEMORY_IDX]._enabled = (enabled == 1);
195196
} else if (strcmp(name, "cpuset") == 0) {
197+
log_debug(os, container)("Detected optional cpuset controller entry in %s", proc_cgroups);
196198
cg_infos[CPUSET_IDX]._name = os::strdup(name);
197199
cg_infos[CPUSET_IDX]._hierarchy_id = hierarchy_id;
198200
cg_infos[CPUSET_IDX]._enabled = (enabled == 1);
@@ -216,8 +218,8 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
216218
is_cgroupsV2 = true;
217219
all_required_controllers_enabled = true;
218220
for (int i = 0; i < CG_INFO_LENGTH; i++) {
219-
// pids controller is optional. All other controllers are required
220-
if (i != PIDS_IDX) {
221+
// pids and cpuset controllers are optional. All other controllers are required
222+
if (i != PIDS_IDX && i != CPUSET_IDX) {
221223
is_cgroupsV2 = is_cgroupsV2 && cg_infos[i]._hierarchy_id == 0;
222224
all_required_controllers_enabled = all_required_controllers_enabled && cg_infos[i]._enabled;
223225
}

src/hotspot/share/classfile/classLoaderData.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,14 +985,23 @@ void ClassLoaderData::print_on(outputStream* out) const {
985985
}
986986
out->print_cr(" - handles %d", _handles.count());
987987
out->print_cr(" - dependency count %d", _dependency_count);
988-
out->print (" - klasses {");
989-
PrintKlassClosure closure(out);
990-
((ClassLoaderData*)this)->classes_do(&closure);
988+
out->print (" - klasses { ");
989+
if (Verbose) {
990+
PrintKlassClosure closure(out);
991+
((ClassLoaderData*)this)->classes_do(&closure);
992+
} else {
993+
out->print("...");
994+
}
991995
out->print_cr(" }");
992996
out->print_cr(" - packages " INTPTR_FORMAT, p2i(_packages));
993997
out->print_cr(" - module " INTPTR_FORMAT, p2i(_modules));
994998
out->print_cr(" - unnamed module " INTPTR_FORMAT, p2i(_unnamed_module));
995-
out->print_cr(" - dictionary " INTPTR_FORMAT, p2i(_dictionary));
999+
if (_dictionary != nullptr) {
1000+
out->print (" - dictionary " INTPTR_FORMAT " ", p2i(_dictionary));
1001+
_dictionary->print_size(out);
1002+
} else {
1003+
out->print_cr(" - dictionary " INTPTR_FORMAT, p2i(_dictionary));
1004+
}
9961005
if (_jmethod_ids != NULL) {
9971006
out->print (" - jmethod count ");
9981007
Method::print_jmethod_ids_count(this, out);

src/hotspot/share/classfile/dictionary.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,17 @@ void DictionaryEntry::print_count(outputStream *st) {
586586

587587
// ----------------------------------------------------------------------------
588588

589+
void Dictionary::print_size(outputStream* st) const {
590+
st->print_cr("Java dictionary (table_size=%d, classes=%d, resizable=%s)",
591+
table_size(), number_of_entries(), BOOL_TO_STR(_resizable));
592+
}
593+
589594
void Dictionary::print_on(outputStream* st) const {
590595
ResourceMark rm;
591596

592597
assert(loader_data() != NULL, "loader data should not be null");
593598
assert(!loader_data()->has_class_mirror_holder(), "cld should have a ClassLoader holder not a Class holder");
594-
st->print_cr("Java dictionary (table_size=%d, classes=%d, resizable=%s)",
595-
table_size(), number_of_entries(), BOOL_TO_STR(_resizable));
599+
print_size(st);
596600
st->print_cr("^ indicates that initiating loader is different from defining loader");
597601

598602
for (int index = 0; index < table_size(); index++) {

src/hotspot/share/classfile/dictionary.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 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
@@ -79,6 +79,7 @@ class Dictionary : public Hashtable<InstanceKlass*, mtClass> {
7979
TRAPS);
8080

8181
void print_on(outputStream* st) const;
82+
void print_size(outputStream* st) const;
8283
void verify();
8384

8485
private:

src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,11 @@ public void setAttribute (String name, Object value) {
377377
if (attributes == null) {
378378
attributes = getHttpContext().getAttributes();
379379
}
380-
attributes.put (name, value);
380+
if (value != null) {
381+
attributes.put (name, value);
382+
} else {
383+
attributes.remove (name);
384+
}
381385
}
382386

383387
public void setStreams (InputStream i, OutputStream o) {

src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
import java.io.*;
2929
import java.net.UnknownHostException;
30+
import java.nio.file.Files;
31+
import java.nio.file.Path;
3032
import java.security.cert.CertPathValidatorException;
3133
import java.security.cert.PKIXBuilderParameters;
3234
import java.util.*;
@@ -222,6 +224,8 @@ public static void main(String args[]) throws Exception {
222224
private Throwable chainNotValidatedReason = null;
223225
private Throwable tsaChainNotValidatedReason = null;
224226

227+
private List<String> crossChkWarnings = new ArrayList<>();
228+
225229
PKIXBuilderParameters pkixParameters;
226230
Set<X509Certificate> trustedCerts = new HashSet<>();
227231

@@ -1069,6 +1073,7 @@ void verifyJar(String jarName)
10691073
}
10701074
}
10711075
System.out.println();
1076+
crossCheckEntries(jarName);
10721077

10731078
if (!anySigned) {
10741079
if (disabledAlgFound) {
@@ -1103,6 +1108,143 @@ void verifyJar(String jarName)
11031108
System.exit(1);
11041109
}
11051110

1111+
private void crossCheckEntries(String jarName) throws Exception {
1112+
Set<String> locEntries = new HashSet<>();
1113+
1114+
try (JarFile jarFile = new JarFile(jarName);
1115+
JarInputStream jis = new JarInputStream(
1116+
Files.newInputStream(Path.of(jarName)))) {
1117+
1118+
Manifest cenManifest = jarFile.getManifest();
1119+
Manifest locManifest = jis.getManifest();
1120+
compareManifest(cenManifest, locManifest);
1121+
1122+
JarEntry locEntry;
1123+
while ((locEntry = jis.getNextJarEntry()) != null) {
1124+
String entryName = locEntry.getName();
1125+
locEntries.add(entryName);
1126+
1127+
JarEntry cenEntry = jarFile.getJarEntry(entryName);
1128+
if (cenEntry == null) {
1129+
crossChkWarnings.add(String.format(rb.getString(
1130+
"entry.1.present.when.reading.jarinputstream.but.missing.via.jarfile"),
1131+
entryName));
1132+
continue;
1133+
}
1134+
1135+
try {
1136+
readEntry(jis);
1137+
} catch (SecurityException e) {
1138+
crossChkWarnings.add(String.format(rb.getString(
1139+
"signature.verification.failed.on.entry.1.when.reading.via.jarinputstream"),
1140+
entryName));
1141+
continue;
1142+
}
1143+
1144+
try (InputStream cenInputStream = jarFile.getInputStream(cenEntry)) {
1145+
if (cenInputStream == null) {
1146+
crossChkWarnings.add(String.format(rb.getString(
1147+
"entry.1.present.in.jarfile.but.unreadable"),
1148+
entryName));
1149+
continue;
1150+
} else {
1151+
try {
1152+
readEntry(cenInputStream);
1153+
} catch (SecurityException e) {
1154+
crossChkWarnings.add(String.format(rb.getString(
1155+
"signature.verification.failed.on.entry.1.when.reading.via.jarfile"),
1156+
entryName));
1157+
continue;
1158+
}
1159+
}
1160+
}
1161+
1162+
compareSigners(cenEntry, locEntry);
1163+
}
1164+
1165+
jarFile.stream()
1166+
.map(JarEntry::getName)
1167+
.filter(n -> !locEntries.contains(n) && !n.equals(JarFile.MANIFEST_NAME))
1168+
.forEach(n -> crossChkWarnings.add(String.format(rb.getString(
1169+
"entry.1.present.when.reading.jarfile.but.missing.via.jarinputstream"), n)));
1170+
}
1171+
}
1172+
1173+
private void readEntry(InputStream is) throws IOException {
1174+
is.transferTo(OutputStream.nullOutputStream());
1175+
}
1176+
1177+
private void compareManifest(Manifest cenManifest, Manifest locManifest) {
1178+
if (cenManifest == null) {
1179+
crossChkWarnings.add(rb.getString(
1180+
"manifest.missing.when.reading.jarfile"));
1181+
return;
1182+
}
1183+
if (locManifest == null) {
1184+
crossChkWarnings.add(rb.getString(
1185+
"manifest.missing.when.reading.jarinputstream"));
1186+
return;
1187+
}
1188+
1189+
Attributes cenMainAttrs = cenManifest.getMainAttributes();
1190+
Attributes locMainAttrs = locManifest.getMainAttributes();
1191+
1192+
for (Object key : cenMainAttrs.keySet()) {
1193+
Object cenValue = cenMainAttrs.get(key);
1194+
Object locValue = locMainAttrs.get(key);
1195+
1196+
if (locValue == null) {
1197+
crossChkWarnings.add(String.format(rb.getString(
1198+
"manifest.attribute.1.present.when.reading.jarfile.but.missing.via.jarinputstream"),
1199+
key));
1200+
} else if (!cenValue.equals(locValue)) {
1201+
crossChkWarnings.add(String.format(rb.getString(
1202+
"manifest.attribute.1.differs.jarfile.value.2.jarinputstream.value.3"),
1203+
key, cenValue, locValue));
1204+
}
1205+
}
1206+
1207+
for (Object key : locMainAttrs.keySet()) {
1208+
if (!cenMainAttrs.containsKey(key)) {
1209+
crossChkWarnings.add(String.format(rb.getString(
1210+
"manifest.attribute.1.present.when.reading.jarinputstream.but.missing.via.jarfile"),
1211+
key));
1212+
}
1213+
}
1214+
}
1215+
1216+
private void compareSigners(JarEntry cenEntry, JarEntry locEntry) {
1217+
CodeSigner[] cenSigners = cenEntry.getCodeSigners();
1218+
CodeSigner[] locSigners = locEntry.getCodeSigners();
1219+
1220+
boolean cenHasSigners = cenSigners != null;
1221+
boolean locHasSigners = locSigners != null;
1222+
1223+
if (cenHasSigners && locHasSigners) {
1224+
if (!Arrays.equals(cenSigners, locSigners)) {
1225+
crossChkWarnings.add(String.format(rb.getString(
1226+
"codesigners.different.for.entry.1.when.reading.jarfile.and.jarinputstream"),
1227+
cenEntry.getName()));
1228+
}
1229+
} else if (cenHasSigners) {
1230+
crossChkWarnings.add(String.format(rb.getString(
1231+
"entry.1.is.signed.in.jarfile.but.is.not.signed.in.jarinputstream"),
1232+
cenEntry.getName()));
1233+
} else if (locHasSigners) {
1234+
crossChkWarnings.add(String.format(rb.getString(
1235+
"entry.1.is.signed.in.jarinputstream.but.is.not.signed.in.jarfile"),
1236+
locEntry.getName()));
1237+
}
1238+
}
1239+
1240+
private void displayCrossChkWarnings() {
1241+
System.out.println();
1242+
// First is a summary warning
1243+
System.out.println(rb.getString("jar.contains.internal.inconsistencies.result.in.different.contents.via.jarfile.and.jarinputstream"));
1244+
// each warning message with prefix "- "
1245+
crossChkWarnings.forEach(warning -> System.out.println("- " + warning));
1246+
}
1247+
11061248
private void displayMessagesAndResult(boolean isSigning) {
11071249
String result;
11081250
List<String> errors = new ArrayList<>();
@@ -1329,13 +1471,19 @@ private void displayMessagesAndResult(boolean isSigning) {
13291471
System.out.println(rb.getString("Warning."));
13301472
warnings.forEach(System.out::println);
13311473
}
1474+
if (!crossChkWarnings.isEmpty()) {
1475+
displayCrossChkWarnings();
1476+
}
13321477
} else {
13331478
if (!errors.isEmpty() || !warnings.isEmpty()) {
13341479
System.out.println();
13351480
System.out.println(rb.getString("Warning."));
13361481
errors.forEach(System.out::println);
13371482
warnings.forEach(System.out::println);
13381483
}
1484+
if (!crossChkWarnings.isEmpty()) {
1485+
displayCrossChkWarnings();
1486+
}
13391487
}
13401488

13411489
if (!isSigning && (!errors.isEmpty() || !warnings.isEmpty())) {

src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,34 @@ public class Resources extends java.util.ListResourceBundle {
324324
{"Cannot.find.file.", "Cannot find file: "},
325325
{"event.ocsp.check", "Contacting OCSP server at %s ..."},
326326
{"event.crl.check", "Downloading CRL from %s ..."},
327+
{"manifest.missing.when.reading.jarfile",
328+
"Manifest is missing when reading via JarFile"},
329+
{"manifest.missing.when.reading.jarinputstream",
330+
"Manifest is missing when reading via JarInputStream"},
331+
{"manifest.attribute.1.present.when.reading.jarfile.but.missing.via.jarinputstream",
332+
"Manifest main attribute %s is present when reading via JarFile but missing when reading via JarInputStream"},
333+
{"manifest.attribute.1.present.when.reading.jarinputstream.but.missing.via.jarfile",
334+
"Manifest main attribute %s is present when reading via JarInputStream but missing when reading via JarFile"},
335+
{"manifest.attribute.1.differs.jarfile.value.2.jarinputstream.value.3",
336+
"Manifest main attribute %1$s differs: JarFile value = %2$s, JarInputStream value = %3$s"},
337+
{"entry.1.present.when.reading.jarinputstream.but.missing.via.jarfile",
338+
"Entry %s is present when reading via JarInputStream but missing when reading via JarFile"},
339+
{"entry.1.present.when.reading.jarfile.but.missing.via.jarinputstream",
340+
"Entry %s is present when reading via JarFile but missing when reading via JarInputStream"},
341+
{"entry.1.present.in.jarfile.but.unreadable",
342+
"Entry %s is present in JarFile but unreadable"},
343+
{"codesigners.different.for.entry.1.when.reading.jarfile.and.jarinputstream",
344+
"Code signers are different for entry %s when reading from JarFile and JarInputStream"},
345+
{"entry.1.is.signed.in.jarfile.but.is.not.signed.in.jarinputstream",
346+
"Entry %s is signed in JarFile but is not signed in JarInputStream"},
347+
{"entry.1.is.signed.in.jarinputstream.but.is.not.signed.in.jarfile",
348+
"Entry %s is signed in JarInputStream but is not signed in JarFile"},
349+
{"jar.contains.internal.inconsistencies.result.in.different.contents.via.jarfile.and.jarinputstream",
350+
"This JAR file contains internal inconsistencies that may result in different contents when reading via JarFile and JarInputStream:"},
351+
{"signature.verification.failed.on.entry.1.when.reading.via.jarinputstream",
352+
"Signature verification failed on entry %s when reading via JarInputStream"},
353+
{"signature.verification.failed.on.entry.1.when.reading.via.jarfile",
354+
"Signature verification failed on entry %s when reading via JarFile"},
327355
};
328356

329357
/**

src/jdk.jartool/share/man/jarsigner.1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,13 @@ The timestamp will expire within one year on \f[CB]YYYY\-MM\-DD\f[R].
12961296
.RS
12971297
.RE
12981298
.TP
1299+
.B internalInconsistenciesDetected
1300+
This JAR contains internal inconsistencies detected during verification
1301+
that may result in different contents when reading via JarFile
1302+
and JarInputStream.
1303+
.RS
1304+
.RE
1305+
.TP
12991306
.B legacyAlg
13001307
An algorithm used is considered a security risk but not disabled.
13011308
.RS

0 commit comments

Comments
 (0)