!594 Sync master to openEuler-22.03-LTS-SP3

From: @zhangyunbo7 
Reviewed-by: @kuenking111 
Signed-off-by: @kuenking111
This commit is contained in:
openeuler-ci-bot 2024-08-07 01:19:34 +00:00 committed by Gitee
commit 0598a80404
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 354 additions and 22 deletions

View File

@ -0,0 +1,72 @@
From 11116ea71b22635302759817b43c555ded53f882 Mon Sep 17 00:00:00 2001
Subject: 8137165: Tests fail in SR_Handler because thread is not VMThread or JavaThread
---
hotspot/src/os/linux/vm/os_linux.cpp | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp
index 6ee49eedc..773c746af 100644
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -1070,6 +1070,13 @@ void os::free_thread(OSThread* osthread) {
assert(osthread != NULL, "osthread not set");
if (Thread::current()->osthread() == osthread) {
+#ifdef ASSERT
+ sigset_t current;
+ sigemptyset(&current);
+ pthread_sigmask(SIG_SETMASK, NULL, &current);
+ assert(!sigismember(&current, SR_signum), "SR signal should not be blocked!");
+#endif
+
// Restore caller's signal mask
sigset_t sigmask = osthread->caller_sigmask();
pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
@@ -4723,7 +4730,8 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
// after sigsuspend.
int old_errno = errno;
- Thread* thread = Thread::current();
+ Thread* thread = Thread::current_or_null();
+ assert(thread != NULL, "Missing current thread in SR_handler");
OSThread* osthread = thread->osthread();
assert(thread->is_VM_thread() || thread->is_Java_thread(), "Must be VMThread or JavaThread");
@@ -4735,7 +4743,7 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
os::SuspendResume::State state = osthread->sr.suspended();
if (state == os::SuspendResume::SR_SUSPENDED) {
sigset_t suspend_set; // signals for sigsuspend()
-
+ sigemptyset(&suspend_set);
// get current set of blocked signals and unblock resume signal
pthread_sigmask(SIG_BLOCK, NULL, &suspend_set);
sigdelset(&suspend_set, SR_signum);
@@ -5025,6 +5033,7 @@ static bool call_chained_handler(struct sigaction *actp, int sig,
// try to honor the signal mask
sigset_t oset;
+ sigemptyset(&oset);
pthread_sigmask(SIG_SETMASK, &(actp->sa_mask), &oset);
// call into the chained handler
@@ -5035,7 +5044,7 @@ static bool call_chained_handler(struct sigaction *actp, int sig,
}
// restore the signal mask
- pthread_sigmask(SIG_SETMASK, &oset, 0);
+ pthread_sigmask(SIG_SETMASK, &oset, NULL);
}
// Tell jvm's signal handler the signal is taken care of.
return true;
@@ -6699,6 +6708,7 @@ void Parker::park(bool isAbsolute, jlong time) {
// Don't catch signals while blocked; let the running threads have the signals.
// (This allows a debugger to break into the running thread.)
sigset_t oldsigs;
+ sigemptyset(&oldsigs);
sigset_t* allowdebug_blocked = os::Linux::allowdebug_blocked_signals();
pthread_sigmask(SIG_BLOCK, allowdebug_blocked, &oldsigs);
#endif
--
2.19.1

View File

@ -0,0 +1,135 @@
From f4b0357c01f51e813642c3ac5c8ff33c1576eb72 Mon Sep 17 00:00:00 2001
Subject: Extending the IV Length Supported by KAEProvider AES/Gcm
---
.../security/openssl/kae_symmetric_cipher.c | 23 ++++++--
.../security/openssl/KAEGcmIvLenTest.java | 52 +++++++++++++++++++
2 files changed, 72 insertions(+), 3 deletions(-)
create mode 100644 jdk/test/org/openeuler/security/openssl/KAEGcmIvLenTest.java
diff --git a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_symmetric_cipher.c b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_symmetric_cipher.c
index ec8894f1a..7618d6e16 100644
--- a/jdk/src/solaris/native/org/openeuler/security/openssl/kae_symmetric_cipher.c
+++ b/jdk/src/solaris/native/org/openeuler/security/openssl/kae_symmetric_cipher.c
@@ -146,6 +146,7 @@ Java_org_openeuler_security_openssl_KAESymmetricCipherBase_nativeInit(JNIEnv* en
const EVP_CIPHER* cipher = NULL;
ENGINE* kaeEngine = NULL;
int keyLength = (*env)->GetArrayLength(env, key);
+ int ivLength = 0;
const char* algo = (*env)->GetStringUTFChars(env, cipherType, 0);
if (StartsWith("aes", algo)) {
@@ -158,7 +159,6 @@ Java_org_openeuler_security_openssl_KAESymmetricCipherBase_nativeInit(JNIEnv* en
KAE_TRACE("KAESymmetricCipherBase_nativeInit: kaeEngine => %p", kaeEngine);
- (*env)->ReleaseStringUTFChars(env, cipherType, algo);
if (cipher == NULL) {
KAE_ThrowOOMException(env, "create EVP_CIPHER fail");
goto cleanup;
@@ -170,19 +170,35 @@ Java_org_openeuler_security_openssl_KAESymmetricCipherBase_nativeInit(JNIEnv* en
if (iv != NULL) {
ivBytes = (*env)->GetByteArrayElements(env, iv, NULL);
+ ivLength = (*env)->GetArrayLength(env, iv);
}
if (key != NULL) {
keyBytes = (*env)->GetByteArrayElements(env, key, NULL);
}
- if (!EVP_CipherInit_ex(ctx, cipher, kaeEngine, (const unsigned char*)keyBytes,
- (const unsigned char*)ivBytes, encrypt ? 1 : 0)) {
+ if (!EVP_CipherInit_ex(ctx, cipher, kaeEngine, NULL,
+ NULL, encrypt ? 1 : 0)) {
KAE_ThrowFromOpenssl(env, "EVP_CipherInit_ex failed", KAE_ThrowRuntimeException);
goto cleanup;
}
+ if (strcasecmp(algo + 8, "gcm") == 0) {
+ /* Set IV length if default 12 bytes (96 bits) is not appropriate */
+ if(!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, ivLength, NULL)) {
+ KAE_ThrowFromOpenssl(env, "EVP_CIPHER_CTX_ctrl failed", KAE_ThrowRuntimeException);
+ goto cleanup;
+ }
+ }
+
+ if (!EVP_CipherInit_ex(ctx, NULL, kaeEngine, (const unsigned char*)keyBytes,
+ (const unsigned char*)ivBytes, encrypt ? 1 : 0)) {
+ KAE_ThrowFromOpenssl(env, "EVP_CipherInit_ex int key & iv failed", KAE_ThrowRuntimeException);
+ goto cleanup;
+ }
+
EVP_CIPHER_CTX_set_padding(ctx, padding ? 1 : 0);
+ (*env)->ReleaseStringUTFChars(env, cipherType, algo);
FreeMemoryFromInit(env, iv, ivBytes, key, keyBytes, keyLength);
return (jlong)ctx;
@@ -190,6 +206,7 @@ cleanup:
if (ctx != NULL) {
EVP_CIPHER_CTX_free(ctx);
}
+ (*env)->ReleaseStringUTFChars(env, cipherType, algo);
FreeMemoryFromInit(env, iv, ivBytes, key, keyBytes, keyLength);
return 0;
}
diff --git a/jdk/test/org/openeuler/security/openssl/KAEGcmIvLenTest.java b/jdk/test/org/openeuler/security/openssl/KAEGcmIvLenTest.java
new file mode 100644
index 000000000..c9e2257aa
--- /dev/null
+++ b/jdk/test/org/openeuler/security/openssl/KAEGcmIvLenTest.java
@@ -0,0 +1,52 @@
+import org.openeuler.security.openssl.KAEProvider;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.GCMParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.util.Arrays;
+
+/**
+ * @test
+ * @summary Basic test for AES/GCM Iv
+ * @requires os.arch=="aarch64"
+ * @run main KAEGcmIvLenTest
+ */
+public class KAEGcmIvLenTest {
+ private static String plainText = "helloworldhellow"; // 16bytes for NoPadding
+ private static String shortPlainText = "helloworld"; // 5 bytes for padding
+ private static SecretKeySpec ks = new SecretKeySpec("AESEncryptionKey".getBytes(StandardCharsets.UTF_8), "AES"); // key has 16 bytes
+ private static int[] ivLens = {12, 16};
+ public static void main(String[] args) throws Exception {
+ Security.addProvider(new KAEProvider());
+ for (int ivLen : ivLens) {
+ testGcm(plainText,"AES/GCM/NoPadding", "KAEProvider", "SunJCE", ivLen);
+ testGcm(plainText,"AES/GCM/NoPadding", "SunJCE", "KAEProvider", ivLen);
+ testGcm(shortPlainText,"AES/GCM/PKCS5Padding", "KAEProvider", "SunJCE", ivLen);
+ testGcm(shortPlainText,"AES/GCM/PKCS5Padding", "SunJCE", "KAEProvider", ivLen);
+ }
+
+ }
+
+ private static void testGcm(String plainText, String algo, String encryptProvider, String decryptProvider, int ivLen) throws Exception {
+ Cipher enCipher = Cipher.getInstance(algo, encryptProvider);
+ enCipher.init(Cipher.ENCRYPT_MODE, ks, getIv(ivLen));
+ byte[] cipherText = enCipher.doFinal(plainText.getBytes());
+
+ Cipher deCipher = Cipher.getInstance(algo, decryptProvider);
+ deCipher.init(Cipher.DECRYPT_MODE, ks, getIv(ivLen));
+ byte[] origin = deCipher.doFinal(cipherText);
+
+ if (!Arrays.equals(plainText.getBytes(), origin)) {
+ throw new RuntimeException("gcm decryption failed, algo = " + algo);
+ }
+ }
+
+ private static GCMParameterSpec getIv(int ivLen) {
+ if (ivLen == 16) {
+ return new GCMParameterSpec(128, "abcdefghabcdefgh".getBytes(StandardCharsets.UTF_8));
+ }
+ return new GCMParameterSpec(96, "abcdefghabcd".getBytes(StandardCharsets.UTF_8));
+ }
+}
--
2.19.1

View File

@ -0,0 +1,88 @@
Subject: [PATCH][Huawei] The fast serialization function of
sun.rmi.transport.ConnectionOutputStream is disabled by default
---
.../classes/java/io/ObjectOutputStream.java | 23 ++++++++++++++++---
.../sun/rmi/server/MarshalOutputStream.java | 10 ++++++++
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/jdk/src/share/classes/java/io/ObjectOutputStream.java b/jdk/src/share/classes/java/io/ObjectOutputStream.java
index 328f47589..78dc3c5b2 100644
--- a/jdk/src/share/classes/java/io/ObjectOutputStream.java
+++ b/jdk/src/share/classes/java/io/ObjectOutputStream.java
@@ -240,7 +240,7 @@ public class ObjectOutputStream
* Value of "UseFastSerializer" property. The fastSerializer is turned
* on when it is true.
*/
- private final boolean useFastSerializer = UNSAFE.getUseFastSerializer();
+ private boolean useFastSerializer = UNSAFE.getUseFastSerializer();
/**
* value of "printFastSerializer" property,
@@ -254,7 +254,22 @@ public class ObjectOutputStream
* Magic number that is written to the stream header when using fastserilizer.
*/
private static final short STREAM_MAGIC_FAST = (short)0xdeca;
+
+ /**
+ * The default value is true. If you want to disable the fast serialization function, please set it to false.
+ */
+ protected boolean enableFastSerializerClass(){
+ return true;
+ }
+ /**
+ * Disable fast serialization functionality.
+ */
+ private void disableFastSerializerStatusByClass() {
+ if ( this.useFastSerializer && !enableFastSerializerClass()){
+ this.useFastSerializer = false;
+ }
+ }
/**
* Creates an ObjectOutputStream that writes to the specified OutputStream.
* This constructor writes the serialization stream header to the
@@ -279,7 +294,8 @@ public class ObjectOutputStream
* @see ObjectInputStream#ObjectInputStream(InputStream)
*/
public ObjectOutputStream(OutputStream out) throws IOException {
- verifySubclass();
+ disableFastSerializerStatusByClass();
+ verifySubclass();
bout = new BlockDataOutputStream(out);
handles = new HandleTable(10, (float) 3.00);
subs = new ReplaceTable(10, (float) 3.00);
@@ -311,7 +327,8 @@ public class ObjectOutputStream
* @see java.io.SerializablePermission
*/
protected ObjectOutputStream() throws IOException, SecurityException {
- SecurityManager sm = System.getSecurityManager();
+ disableFastSerializerStatusByClass();
+ SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
}
diff --git a/jdk/src/share/classes/sun/rmi/server/MarshalOutputStream.java b/jdk/src/share/classes/sun/rmi/server/MarshalOutputStream.java
index 699f11072..e113441f8 100644
--- a/jdk/src/share/classes/sun/rmi/server/MarshalOutputStream.java
+++ b/jdk/src/share/classes/sun/rmi/server/MarshalOutputStream.java
@@ -48,6 +48,16 @@ import sun.rmi.transport.Target;
*/
public class MarshalOutputStream extends ObjectOutputStream
{
+ /**
+ * value of "enableRMIFastSerializerClass" property
+ */
+ private static final boolean enableRMIFastSerializerClass = java.security.AccessController.doPrivileged( new sun.security.action.GetBooleanAction( "enableRMIFastSerializerClass")).booleanValue();
+
+ @Override
+ protected boolean enableFastSerializerClass() {
+ return this.enableRMIFastSerializerClass;
+ }
+
/**
* Creates a marshal output stream with protocol version 1.
*/
--
2.44.0

View File

@ -1,17 +1,18 @@
From c4fd69c76c41b7b6168f1071d50143566f7d269e
From a168b23b9b49998642adabda7edd76a0d45c07b8
Date: Fri, 22 Sep 2023 14:48:33 +0800
Subject: [PATCH] add Fix-aarch64-runtime-thread-signal-transfer-bug
---
.../src/cpu/aarch64/vm/vm_version_aarch64.cpp | 47 +++++----
.../src/cpu/aarch64/vm/vm_version_aarch64.hpp | 8 ++
hotspot/src/os/linux/vm/os_linux.cpp | 7 ++
hotspot/src/os/linux/vm/os_linux.cpp | 3 +
.../linux_aarch64/vm/thread_linux_aarch64.cpp | 97 +++++++++++++++++++
.../linux_aarch64/vm/thread_linux_aarch64.hpp | 3 +
5 files changed, 141 insertions(+), 21 deletions(-)
hotspot/src/share/vm/runtime/os.cpp | 5 +
6 files changed, 142 insertions(+), 21 deletions(-)
diff --git a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
index 27ab00dd..839df4a3 100644
index 27ab00dda..839df4a34 100644
--- a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp
@@ -169,27 +169,7 @@ void VM_Version::get_processor_features() {
@ -76,7 +77,7 @@ index 27ab00dd..839df4a3 100644
ResourceMark rm;
diff --git a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp
index 7f3a5326..47353df9 100644
index 7f3a53262..47353df91 100644
--- a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp
@@ -63,6 +63,7 @@ public:
@ -108,21 +109,10 @@ index 7f3a5326..47353df9 100644
static ByteSize ctr_el0_offset() { return byte_offset_of(PsrInfo, ctr_el0); }
static bool is_zva_enabled() {
diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp
index 2dde2587..647ef582 100644
index 6b1e6b805..6ee49eedc 100644
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -5576,6 +5576,10 @@ jint os::init_2(void)
Linux::is_floating_stack() ? "floating stack" : "fixed stack");
}
+#ifdef AARCH64
+ JavaThread::os_linux_aarch64_options(active_processor_count(), argv_for_execvp);
+#endif
+
if (UseNUMA) {
if (!Linux::libnuma_init()) {
UseNUMA = false;
@@ -5760,6 +5764,9 @@ void os::set_native_thread_name(const char *name) {
@@ -5760,6 +5760,9 @@ void os::set_native_thread_name(const char *name) {
const int rc = Linux::_pthread_setname_np(pthread_self(), buf);
// ERANGE should not happen; all other errors should just be ignored.
assert(rc != ERANGE, "pthread_setname_np failed");
@ -133,7 +123,7 @@ index 2dde2587..647ef582 100644
}
diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/thread_linux_aarch64.cpp b/hotspot/src/os_cpu/linux_aarch64/vm/thread_linux_aarch64.cpp
index 87e42318..8b0e2c98 100644
index 87e42318a..b9c468d6d 100644
--- a/hotspot/src/os_cpu/linux_aarch64/vm/thread_linux_aarch64.cpp
+++ b/hotspot/src/os_cpu/linux_aarch64/vm/thread_linux_aarch64.cpp
@@ -25,6 +25,7 @@
@ -248,7 +238,7 @@ index 87e42318..8b0e2c98 100644
assert(this->is_Java_thread(), "must be JavaThread");
JavaThread* jt = (JavaThread *)this;
diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/thread_linux_aarch64.hpp b/hotspot/src/os_cpu/linux_aarch64/vm/thread_linux_aarch64.hpp
index a2f0135c..f14ace0d 100644
index a2f0135c2..f14ace0d3 100644
--- a/hotspot/src/os_cpu/linux_aarch64/vm/thread_linux_aarch64.hpp
+++ b/hotspot/src/os_cpu/linux_aarch64/vm/thread_linux_aarch64.hpp
@@ -66,6 +66,9 @@
@ -261,6 +251,23 @@ index a2f0135c..f14ace0d 100644
bool pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava);
private:
bool pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava);
diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp
index ff35e8b3a..cae1cf477 100644
--- a/hotspot/src/share/vm/runtime/os.cpp
+++ b/hotspot/src/share/vm/runtime/os.cpp
@@ -366,6 +366,11 @@ static void signal_thread_entry(JavaThread* thread, TRAPS) {
}
void os::init_before_ergo() {
+#ifdef AARCH64
+ // global variables
+ extern char** argv_for_execvp;
+ JavaThread::os_linux_aarch64_options(active_processor_count(), argv_for_execvp);
+#endif
initialize_initial_active_processor_count();
// We need to initialize large page support here because ergonomics takes some
// decisions depending on large page support and the calculated large page size.
--
2.19.1

View File

@ -937,7 +937,7 @@ Provides: java-%{javaver}-%{origin}-accessibility%{?1} = %{epoch}:%{version}-%{r
Name: java-%{javaver}-%{origin}
Version: %{javaver}.%{updatever}.%{buildver}
Release: 0
Release: 5
# java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons
# and this change was brought into RHEL-4. java-1.5.0-ibm packages
# also included the epoch in their virtual provides. This created a
@ -1333,7 +1333,12 @@ Patch438: Huawei-Add-Aggressive-CDS.patch
Patch439: Backport-8151845-Comment-in-globals.hpp-for-MetaspaceSize-is-.patch
Patch440: Backport-8210706-G1-may-deadlock-when-starting-a-concurrent-c.patch
Patch441: Backport-8318889-Backport-Important-Fixed-Issues-in-Later-Ver.patch
#422
Patch442: Huawei-Keep-objects-when-remove-unshareable-info.patch
Patch443: The-fast-serialization-function-of-sun.rmi.transport.patch
Patch445: Extending-the-IV-Length-Supported-by-KAEProvider-AES.patch
Patch446: 8137165-Tests-fail-in-SR_Handler-because-thread-is-n.patch
#############################################
#
# Upstreamable patches
@ -1989,10 +1994,19 @@ pushd %{top_level_dir_name}
%patch440 -p1
%patch441 -p1
%patch442 -p1
%patch443 -p1
%patch445 -p1
%patch446 -p1
%endif
%ifarch loongarch64
%patch4000 -p1
%patch308 -p1
%patch310 -p1
%patch311 -p1
%patch312 -p1
%endif
%ifarch riscv64
@ -2649,7 +2663,23 @@ cjc.mainProgram(arg)
%endif
%changelog
* Thu Tue 16 2024 Autistic_boyya <wangzhongyi7@huawei.com> -1:1.8.0.422-b05.rolling
* Tue Aug 6 2024 benshuai5D <zhangyunbo7@huawei.com> -1:1.8.0.422-b05.5
- modified add-Fix-aarch64-runtime-thread-signal-transfer-bug.patch
* Sat Aug 3 2024 kuenking111 <wangkun49@huawei.com> -1:1.8.0.422-b05.4
- Add 8137165-Tests-fail-in-SR_Handler-because-thread-is-n.patch
- Extending-the-IV-Length-Supported-by-KAEProvider-AES.patch
* Tue Jul 30 2024 benshuai5D <zhangyunbo7@huawei.com> -1:1.8.0.422-b05.3
- Fix-the-ActiveProcessorCount-function-of-the-spark-s.patch
* Tue Jul 30 2024 Xiang Gao <gaoxiang@kylinos.cn> - 1:1.8.0.422-b05.2
- Backport 8178498,8193710,8196743,8284330, serviceability tools support containers on loongarch
* Fri Jul 26 2024 benshuai5D <zhangyunbo7@huawei.com> -1:1.8.0.422-b05.1
- Add The-fast-serialization-function-of-sun.rmi.transport.patch
* Tue Jul 16 2024 Autistic_boyya <wangzhongyi7@huawei.com> -1:1.8.0.422-b05.rolling
- modified 8014628-Support-AES-Encryption-with-HMAC-SHA2-for-Ke.patch
- modified 8136577_Make_AbortVMOnException_available_in_product_builds.patch
- modified Dynamic-CDS-Archive.patch