!585 The fast serialization function of sun.rmi.transport.ConnectionOutputStream is disabled by default

From: @zhangyunbo7 
Reviewed-by: @kuenking111 
Signed-off-by: @kuenking111
This commit is contained in:
openeuler-ci-bot 2024-07-26 10:12:27 +00:00 committed by Gitee
commit 18e9a4ae4a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 94 additions and 1 deletions

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

@ -943,7 +943,7 @@ Provides: java-%{javaver}-%{origin}-accessibility%{?1} = %{epoch}:%{version}-%{r
Name: java-%{javaver}-%{origin}
Version: %{javaver}.%{updatever}.%{buildver}
Release: 0
Release: 1
# 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
@ -1340,6 +1340,7 @@ 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
Patch442: Huawei-Keep-objects-when-remove-unshareable-info.patch
Patch443: The-fast-serialization-function-of-sun.rmi.transport.patch
#############################################
#
# Upstreamable patches
@ -1995,6 +1996,7 @@ pushd %{top_level_dir_name}
%patch440 -p1
%patch441 -p1
%patch442 -p1
%patch443 -p1
%endif
%ifarch loongarch64
@ -2654,6 +2656,9 @@ cjc.mainProgram(args) -- the returns from copy_jdk_configs.lua should not affect
%endif
%changelog
* Fri Tue 26 2024 benshuai5D <zhangyunbo7@huawei.com> -1:1.8.0.422-b05.1
- Add The-fast-serialization-function-of-sun.rmi.transport.patch
* Thu Tue 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