-
Notifications
You must be signed in to change notification settings - Fork 740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update java.security.manager behaviour #14329
Conversation
In JDK18, |
Keeping in mind that we'll need to remove all the SecurityManager tests for (likely) jdk19 and later. |
For Global settings, If you want to set for each impacted test, |
@babsingh please advise if this is ready for reviewing. |
@JasonFengJ9 This is good to review. I have kept it in the draft state because we will also need test changes. Without the test changes, OpenJ9 tests will fail with JDK18. For the test changes, I am planning to update https://github.com/adoptium/TKG/blob/master/openj9Settings.mk as follows:
In JDK18, this should revert OpenJ9 behaviour to |
FYI @renfeiw as the change may be added to TKG. |
You probably need to use append, something like this:
|
77c99c8
to
e19d599
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good.
f1ff1b9
to
a411f47
Compare
ecdd3ef
to
cff0f94
Compare
1. Consolidate security manager startup code invoked from ClassLoader.initializeClassLoaders in System.initSecurityManager (new method). 2. As per the Java doc, the java.security.manager property should only be read at startup. Example: If this property is initialized with "disallow" when the JVM is started, then a security manager will not be set at startup and cannot be set dynamically. Currently, this property is read in System.setSecurityManager. If a user changes this property after startup, then System.setSecurityManager's behaviour will change after startup. This behaviour does not follow the Java doc and reference implementation. To fix this issue, the java.security.manager is only read once at startup in System.initSecurityManager. 3. In JDK18, System.setSecurityManager's run-time behaviour changes with respect to the java.security.manager property. Previously, if the property was null, the run-time behaviour was success or throws SecurityException. In JDK18, the new behaviour is to throw UnsupportedOperationException if the property is null. This matches the behaviour when the property is set to "disallow". Fixes: eclipse-openj9#14092 Fixes: eclipse-openj9#14094 Signed-off-by: Babneet Singh <[email protected]>
Tests which use System.setSecurityManager need to explicitly set the java.security.manager property in JDK18+. Impacted Java8andUp tests: - JCL_TEST_Java-Security - JCL_TEST_Java-Lang - JCL_TEST_Java-Lang-Invoke - JCL_TEST_Java-Lang_ClassLoader - JCL_TEST_Java-Internals - JCL_TEST_IBM-VM - JCL_TEST_Java-Lang-Ref Impacted JLM_Tests: - JLM_Tests_IBMinternal - TestMemoryMXBean Impacted Jsr292 tests: - jsr292Test - jsr292BootstrapTest Impacted cmdLineTests: - J9security - proxyFieldAccess Signed-off-by: Babneet Singh <[email protected]>
setSecurityManager should do nothing if the input argument is null and no security manager has been established. Before, this was being enforced implicitly. The implicit check no longer works. There is error handling code and code to print a warning message, which needs to avoided in the above "do nothing" scenario. So, an explicit null check has been added to enforce the "no nothing" scenario. Signed-off-by: Babneet Singh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM
@tajila can you please relaunch the PR builds? |
Jenkins test sanity win jdk11 |
Jenkins test sanity plinux jdk17,18 |
Jenkins test sanity plinux jdk17,jdk18 |
@babsingh please make a PR for the JDK18 stream as well |
The below tests have been fixed by eclipse-openj9/openj9#14329: - java/lang/System/AllowSecurityManager - java/lang/System/SecurityManagerWarnings Signed-off-by: Babneet Singh <[email protected]>
The below tests have been fixed by eclipse-openj9/openj9#14329: - java/lang/System/AllowSecurityManager - java/lang/System/SecurityManagerWarnings Signed-off-by: Babneet Singh <[email protected]>
In some cases, warning messages are no longer being printed when the input argument is null. Revising the fix in eclipse-openj9#14329 to correctly throw UnsupportedOperationException (UOE) in case of a null input argument when the security manager is disallowed. When the security manager is not allowed to be set dynamically, return if the input argument is null. UnsupportedOperationException should only be thrown for a non-null input argument. Fixes: eclipse-openj9#14445 Signed-off-by: Babneet Singh <[email protected]>
In some cases, warning messages are no longer being printed when the input argument is null. Revising the fix in eclipse-openj9#14329 to correctly throw UnsupportedOperationException (UOE) in case of a null input argument when the security manager is disallowed. When the security manager is not allowed to be set dynamically, return if the input argument is null. UnsupportedOperationException should only be thrown for a non-null input argument. Fixes: eclipse-openj9#14445 Signed-off-by: Babneet Singh <[email protected]>
Consolidate security manager startup code invoked from
ClassLoader.initializeClassLoaders
inSystem.initSecurityManager
(new method).As per the Java doc, the
java.security.manager
property should only be readat startup. Example: If this property is initialized with
"disallow"
when theJVM is started, then a security manager will not be set at startup and cannot
be set dynamically. Currently, this property is read in
System.setSecurityManager
. If a user changes this property after startup, thenSystem.setSecurityManager
's behaviour will change after startup. This behaviourdoes not follow the Java doc and reference implementation. To fix this issue,
the
java.security.manager
is only read once at startup inSystem.initSecurityManager
.In JDK18,
System.setSecurityManager
's run-time behaviour changes withrespect to the
java.security.manager
property. Previously, if the propertywas null, the run-time behaviour was
success or throws SecurityException
.In JDK18, the new behaviour is to
throw UnsupportedOperationException
if theproperty is null. This matches the behaviour when the property is set to
"disallow"
.Set
java.security.manager
property for impacted tests.Explicitly handle
null
arguments inSystem.setSecurityManager
.Fixes: #14092
Fixes: #14094
Signed-off-by: Babneet Singh [email protected]