Skip to content

Commit

Permalink
Merge upstream-jdk21u
Browse files Browse the repository at this point in the history
  • Loading branch information
earthling-amzn committed Aug 14, 2024
2 parents a857c73 + 75c82f6 commit 6d9d059
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 324 deletions.
33 changes: 15 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,26 +364,23 @@ jobs:
- test-windows-x64

steps:
# Hack to get hold of the api environment variables that are only defined for actions
- name: 'Get API configuration'
id: api
uses: actions/github-script@v7
with:
script: 'return { url: process.env["ACTIONS_RUNTIME_URL"], token: process.env["ACTIONS_RUNTIME_TOKEN"] }'

- name: 'Remove bundle artifacts'
run: |
# Find and remove all bundle artifacts
ALL_ARTIFACT_URLS="$(curl -s \
-H 'Accept: application/json;api-version=6.0-preview' \
-H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \
'${{ fromJson(steps.api.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview')"
BUNDLE_ARTIFACT_URLS="$(echo "$ALL_ARTIFACT_URLS" | jq -r -c '.value | map(select(.name|startswith("bundles-"))) | .[].url')"
for url in $BUNDLE_ARTIFACT_URLS; do
echo "Removing $url"
curl -s \
-H 'Accept: application/json;api-version=6.0-preview' \
-H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \
-X DELETE "$url" \
# See: https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28
ALL_ARTIFACT_IDS="$(curl -sL \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ github.token }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
'${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts')"
BUNDLE_ARTIFACT_IDS="$(echo "$ALL_ARTIFACT_IDS" | jq -r -c '.artifacts | map(select(.name|startswith("bundles-"))) | .[].id')"
for id in $BUNDLE_ARTIFACT_IDS; do
echo "Removing $id"
curl -sL \
-X DELETE \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ github.token }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
"${{ github.api_url }}/repos/${{ github.repository }}/actions/artifacts/$id" \
|| echo "Failed to remove bundle"
done
4 changes: 3 additions & 1 deletion make/autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,11 @@ AC_OUTPUT

# After AC_OUTPUT, we need to do final work
CUSTOM_CONFIG_OUTPUT_GENERATED_HOOK
BASIC_POST_CONFIG_OUTPUT

# Finally output some useful information to the user
HELP_PRINT_SUMMARY_AND_WARNINGS
CUSTOM_SUMMARY_AND_WARNINGS_HOOK
HELP_REPEAT_WARNINGS

# All output is done. Do the post-config output management.
BASIC_POST_CONFIG_OUTPUT
8 changes: 7 additions & 1 deletion make/autoconf/jdk-options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,15 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_LEAK_SANITIZER],
#
AC_DEFUN_ONCE([JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER],
[
UTIL_ARG_WITH(NAME: additional-ubsan-checks, TYPE: string,
DEFAULT: [],
DESC: [Customizes the ubsan checks],
OPTIONAL: true)
# GCC reports lots of likely false positives for stringop-truncation and format-overflow.
# Silence them for now.
UBSAN_CHECKS="-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base -fno-sanitize=alignment"
UBSAN_CHECKS="-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base -fno-sanitize=alignment \
$ADDITIONAL_UBSAN_CHECKS"
UBSAN_CFLAGS="$UBSAN_CHECKS -Wno-stringop-truncation -Wno-format-overflow -fno-omit-frame-pointer -DUNDEFINED_BEHAVIOR_SANITIZER"
UBSAN_LDFLAGS="$UBSAN_CHECKS"
UTIL_ARG_ENABLE(NAME: ubsan, DEFAULT: false, RESULT: UBSAN_ENABLED,
Expand Down
19 changes: 19 additions & 0 deletions make/autoconf/lib-alsa.m4
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,25 @@ AC_DEFUN_ONCE([LIB_SETUP_ALSA],
PKG_CHECK_MODULES(ALSA, alsa, [ALSA_FOUND=yes], [ALSA_FOUND=no])
fi
fi
if test "x$ALSA_FOUND" = xno; then
# If we have sysroot set, and no explicit library location is set,
# look at known locations in sysroot.
if test "x$SYSROOT" != "x" && test "x${with_alsa_lib}" == x; then
if test -f "$SYSROOT/usr/lib64/libasound.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
ALSA_LIBS="-L$SYSROOT/usr/lib64 -lasound"
ALSA_FOUND=yes
elif test -f "$SYSROOT/usr/lib/libasound.so"; then
ALSA_LIBS="-L$SYSROOT/usr/lib -lasound"
ALSA_FOUND=yes
elif test -f "$SYSROOT/usr/lib/$OPENJDK_TARGET_CPU-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI/libasound.so"; then
ALSA_LIBS="-L$SYSROOT/usr/lib/$OPENJDK_TARGET_CPU-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI -lasound"
ALSA_FOUND=yes
elif test -f "$SYSROOT/usr/lib/$OPENJDK_TARGET_CPU_AUTOCONF-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI/libasound.so"; then
ALSA_LIBS="-L$SYSROOT/usr/lib/$OPENJDK_TARGET_CPU_AUTOCONF-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI -lasound"
ALSA_FOUND=yes
fi
fi
fi
if test "x$ALSA_FOUND" = xno; then
AC_CHECK_HEADERS([alsa/asoundlib.h],
[
Expand Down
4 changes: 2 additions & 2 deletions make/autoconf/lib-x11.m4
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ AC_DEFUN_ONCE([LIB_SETUP_X11],
elif test -f "$SYSROOT/usr/lib/libX11.so"; then
x_libraries="$SYSROOT/usr/lib"
elif test -f "$SYSROOT/usr/lib/$OPENJDK_TARGET_CPU-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI/libX11.so"; then
x_libraries="$SYSROOT/usr/lib/$OPENJDK_TARGET_CPU-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI/libX11.so"
x_libraries="$SYSROOT/usr/lib/$OPENJDK_TARGET_CPU-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI"
elif test -f "$SYSROOT/usr/lib/$OPENJDK_TARGET_CPU_AUTOCONF-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI/libX11.so"; then
x_libraries="$SYSROOT/usr/lib/$OPENJDK_TARGET_CPU_AUTOCONF-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI/libX11.so"
x_libraries="$SYSROOT/usr/lib/$OPENJDK_TARGET_CPU_AUTOCONF-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI"
fi
fi
fi
Expand Down
14 changes: 6 additions & 8 deletions src/hotspot/share/cds/cppVtables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,17 @@

class CppVtableInfo {
intptr_t _vtable_size;
intptr_t _cloned_vtable[1];
intptr_t _cloned_vtable[1]; // Pseudo flexible array member.
static size_t cloned_vtable_offset() { return offset_of(CppVtableInfo, _cloned_vtable); }
public:
static int num_slots(int vtable_size) {
return 1 + vtable_size; // Need to add the space occupied by _vtable_size;
}
int vtable_size() { return int(uintx(_vtable_size)); }
void set_vtable_size(int n) { _vtable_size = intptr_t(n); }
intptr_t* cloned_vtable() { return &_cloned_vtable[0]; }
void zero() { memset(_cloned_vtable, 0, sizeof(intptr_t) * vtable_size()); }
// Using _cloned_vtable[i] for i > 0 causes undefined behavior. We use address calculation instead.
intptr_t* cloned_vtable() { return (intptr_t*)((char*)this + cloned_vtable_offset()); }
void zero() { memset(cloned_vtable(), 0, sizeof(intptr_t) * vtable_size()); }
// Returns the address of the next CppVtableInfo that can be placed immediately after this CppVtableInfo
static size_t byte_size(int vtable_size) {
CppVtableInfo i;
return pointer_delta(&i._cloned_vtable[vtable_size], &i, sizeof(u1));
return cloned_vtable_offset() + (sizeof(intptr_t) * vtable_size);
}
};

Expand Down
6 changes: 5 additions & 1 deletion src/hotspot/share/code/vtableStubs.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, 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 @@ -28,6 +28,7 @@
#include "asm/macroAssembler.hpp"
#include "code/vmreg.hpp"
#include "memory/allStatic.hpp"
#include "sanitizers/ub.hpp"

// A VtableStub holds an individual code stub for a pair (vtable index, #args) for either itables or vtables
// There's a one-to-one relationship between a VtableStub and such a pair.
Expand Down Expand Up @@ -173,6 +174,9 @@ class VtableStub {
public:
// Query
bool is_itable_stub() { return !_is_vtable_stub; }
// We reinterpret arbitrary memory as VtableStub. This does not cause failures because the lookup/equality
// check will reject false objects. Disabling UBSan is a temporary workaround until JDK-8331725 is fixed.
ATTRIBUTE_NO_UBSAN
bool is_vtable_stub() { return _is_vtable_stub; }
bool is_abstract_method_error(address epc) { return epc == code_begin()+_ame_offset; }
bool is_null_pointer_exception(address epc) { return epc == code_begin()+_npe_offset; }
Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/share/prims/jvmtiExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,9 @@ class JvmtiClassFileLoadHookPoster : public StackObj {
_cached_class_file_ptr = cache_ptr;
_has_been_modified = false;

assert(!_thread->is_in_any_VTMS_transition(), "CFLH events are not allowed in any VTMS transition");
if (_thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
}
_state = JvmtiExport::get_jvmti_thread_state(_thread);
if (_state != nullptr) {
_class_being_redefined = _state->get_class_being_redefined();
Expand Down Expand Up @@ -1363,10 +1365,9 @@ void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) {
if (state == nullptr) {
return;
}
if (thread->is_in_tmp_VTMS_transition()) {
return; // skip ClassLoad events in tmp VTMS transition
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
}
assert(!thread->is_in_any_VTMS_transition(), "class load events are not allowed in any VTMS transition");

EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Trg Class Load triggered",
JvmtiTrace::safe_get_thread_name(thread)));
Expand Down Expand Up @@ -1401,10 +1402,9 @@ void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) {
if (state == nullptr) {
return;
}
if (thread->is_in_tmp_VTMS_transition()) {
return; // skip ClassPrepare events in tmp VTMS transition
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
}
assert(!thread->is_in_any_VTMS_transition(), "class prepare events are not allowed in any VTMS transition");

EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Trg Class Prepare triggered",
JvmtiTrace::safe_get_thread_name(thread)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -981,9 +981,7 @@ public final ForkJoinWorkerThread newThread(ForkJoinPool pool) {
boolean isCommon = (pool.workerNamePrefix == null);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm == null)
return new ForkJoinWorkerThread(null, pool, true, false);
else if (isCommon)
if (sm != null && isCommon)
return newCommonWithACC(pool);
else
return newRegularWithACC(pool);
Expand Down
22 changes: 16 additions & 6 deletions src/java.base/share/classes/javax/crypto/KEM.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, 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 @@ -29,6 +29,7 @@
import java.security.*;
import java.security.InvalidAlgorithmParameterException;
import java.security.spec.AlgorithmParameterSpec;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -539,10 +540,19 @@ public static KEM getInstance(String algorithm)
List<Provider.Service> list = GetInstance.getServices(
"KEM",
Objects.requireNonNull(algorithm, "null algorithm name"));
if (list.isEmpty()) {
throw new NoSuchAlgorithmException(algorithm + " KEM not available");
List<Provider.Service> allowed = new ArrayList<>();
for (Provider.Service s : list) {
if (!JceSecurity.canUseProvider(s.getProvider())) {
continue;
}
allowed.add(s);
}
if (allowed.isEmpty()) {
throw new NoSuchAlgorithmException
(algorithm + " KEM not available");
}
return new KEM(algorithm, new DelayedKEM(list.toArray(new Provider.Service[0])));

return new KEM(algorithm, new DelayedKEM(allowed.toArray(new Provider.Service[0])));
}

/**
Expand All @@ -568,7 +578,7 @@ public static KEM getInstance(String algorithm, Provider provider)
if (provider == null) {
return getInstance(algorithm);
}
GetInstance.Instance instance = GetInstance.getInstance(
GetInstance.Instance instance = JceSecurity.getInstance(
"KEM",
KEMSpi.class,
Objects.requireNonNull(algorithm, "null algorithm name"),
Expand Down Expand Up @@ -601,7 +611,7 @@ public static KEM getInstance(String algorithm, String provider)
if (provider == null) {
return getInstance(algorithm);
}
GetInstance.Instance instance = GetInstance.getInstance(
GetInstance.Instance instance = JceSecurity.getInstance(
"KEM",
KEMSpi.class,
Objects.requireNonNull(algorithm, "null algorithm name"),
Expand Down
47 changes: 11 additions & 36 deletions test/jdk/com/sun/crypto/provider/DHKEM/Compliance.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, 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 All @@ -26,7 +26,9 @@
* @bug 8297878
* @summary Key Encapsulation Mechanism API
* @library /test/lib
* @build java.base/com.sun.crypto.provider.EvenKEMImpl
* @modules java.base/com.sun.crypto.provider
* @run main/othervm Compliance
*/
import jdk.test.lib.Asserts;
import jdk.test.lib.Utils;
Expand All @@ -45,18 +47,19 @@

import com.sun.crypto.provider.DHKEM;

import static com.sun.crypto.provider.EvenKEMImpl.isEven;

public class Compliance {

public static void main(String[] args) throws Exception {
basic();
conform();
determined();
try {
Security.insertProviderAt(new ProviderImpl(), 1);
delayed();
} finally {
Security.removeProvider("XP");
}
// Patch an alternate DHKEM in SunEC which is ahead of SunJCE
// in security provider listing.
Security.getProvider("SunEC")
.put("KEM.DHKEM", "com.sun.crypto.provider.EvenKEMImpl");
delayed();
}

// Encapsulated conformance checks
Expand Down Expand Up @@ -220,34 +223,6 @@ static byte[] calcDetermined(long seed) throws Exception {
return enc2;
}

public static class ProviderImpl extends Provider {
ProviderImpl() {
super("XP", "1", "XP");
put("KEM.DHKEM", "Compliance$KEMImpl");
}
}

static boolean isEven(Key k) {
return Arrays.hashCode(k.getEncoded()) % 2 == 0;
}

public static class KEMImpl extends DHKEM {

@Override
public EncapsulatorSpi engineNewEncapsulator(PublicKey pk, AlgorithmParameterSpec spec, SecureRandom secureRandom)
throws InvalidAlgorithmParameterException, InvalidKeyException {
if (!isEven(pk)) throw new InvalidKeyException("Only accept even keys");
return super.engineNewEncapsulator(pk, spec, secureRandom);
}

@Override
public DecapsulatorSpi engineNewDecapsulator(PrivateKey sk, AlgorithmParameterSpec spec)
throws InvalidAlgorithmParameterException, InvalidKeyException {
if (!isEven(sk)) throw new InvalidKeyException("Only accept even keys");
return super.engineNewDecapsulator(sk, spec);
}
}

// Ensure delayed provider selection
static void delayed() throws Exception {
KeyPairGenerator g = KeyPairGenerator.getInstance("X25519");
Expand All @@ -266,7 +241,7 @@ static void delayed() throws Exception {
KEM.Encapsulator eodd = kem.newEncapsulator(odd);
KEM.Encapsulator eeven = kem.newEncapsulator(even);
Asserts.assertEQ(eodd.providerName(), "SunJCE");
Asserts.assertEQ(eeven.providerName(), "XP");
Asserts.assertEQ(eeven.providerName(), "SunEC");
}

static ECPublicKey badECKey() {
Expand Down
Loading

0 comments on commit 6d9d059

Please sign in to comment.