RFR: 8338411: Implement JEP 486: Permanently Disable the Security Manager [v3]

Weijun Wang weijun at openjdk.org
Fri Oct 25 19:49:40 UTC 2024


On Thu, 24 Oct 2024 13:19:55 GMT, Sean Mullan <mullan at openjdk.org> wrote:

>> This is the implementation of JEP 486: Permanently Disable the Security Manager. See [JEP 486](https://openjdk.org/jeps/486) for more details. The [CSR](https://bugs.openjdk.org/browse/JDK-8338412) describes in detail the main changes in the JEP and also includes an apidiff of the specification changes.
>> 
>> NOTE: the majority (~95%) of the changes in this PR are test updates (removal/modifications) and API specification changes, the latter mostly to remove `@throws SecurityException`. The remaining changes are primarily the removal of the `SecurityManager`, `Policy`, `AccessController` and other Security Manager API implementations. There is very little new code.
>> 
>> The code changes can be broken down into roughly the following categories:
>> 
>> 1. Degrading the behavior of Security Manager APIs to either throw Exceptions by default or provide an execution environment that disallows access to all resources by default.
>> 2. Changing hundreds of methods and constructors to no longer throw a `SecurityException` if a Security Manager was enabled. They will operate as they did in JDK 23 with no Security Manager enabled.
>> 3. Changing the `java` command to exit with a fatal error if a Security Manager is enabled.
>> 4. Removing the hotspot native code for the privileged stack walk and the inherited access control context. The remaining hotspot code and tests related to the Security Manager will be removed immediately after integration - see [JDK-8341916](https://bugs.openjdk.org/browse/JDK-8341916).
>> 5. Removing or modifying hundreds of tests. Many tests that tested Security Manager behavior are no longer relevant and thus have been removed or modified.
>> 
>> There are a handful of Security Manager related tests that are failing and are at the end of the `test/jdk/ProblemList.txt`, `test/langtools/ProblemList.txt` and `test/hotspot/jtreg/ProblemList.txt` files - these will be removed or separate bugs will be filed before integrating this PR. 
>> 
>> Inside the JDK, we have retained calls to `SecurityManager::getSecurityManager` and `AccessController::doPrivileged` for now, as these methods have been degraded to behave the same as they did in JDK 23 with no Security Manager enabled. After we integrate this JEP, those calls will be removed in each area (client-libs, core-libs, security, etc).
>> 
>> I don't expect each reviewer to review all the code changes in this JEP. Rather, I advise that you only focus on the changes for the area (client-libs, core-libs, net, ...
>
> Sean Mullan has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 150 commits:
> 
>  - Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
>  - Merge
>  - Update @summary to replace "if the right permission is granted" can be replaced with "package java.lang is open to unnamed module".
>  - Remove println about Security Manager.
>  - Remove unused static variable NEW_PROXY_IN_PKG.
>  - Remove static variable `DEFAULT_POLICY` and unused imports.
>  - Remove hasSM() method and code that calls it, and remove comment about
>    running test manually with SM.
>  - clientlibs: import order
>  - warning-string
>  - java/net/httpclient/websocket/security/WSURLPermissionTest.java: integrated review feedback in renamed WSSanityTest.java
>  - ... and 140 more: https://git.openjdk.org/jdk/compare/f7a61fce...cb50dfde

Comments on `java.security` classes.

Also, I'd like to see some clarifications on what "the installed policy" or "the current policy" is. The `ProtectionDomain` mentions this when talking about dynamic permissions. On the other hand, the `Policy` class suggests there is no such a thing. If we do not have this concept no more, some modifications might be needed in `ProtectionDomain`.

I also reviewed files in `conf/security`. Everything looks fine except for the `networkaddress.cache.ttl` security property which still references the Security Manager.

src/java.base/share/classes/java/security/AccessControlContext.java line 32:

> 30: 
> 31: /**
> 32:  * AccessControlContext was used with a SecurityManager for access control decisions

I'm not sure how you use this name elsewhere. To me, one either uses "Security Manager" as the name for the technique or `SecurityManager` (inside `{@code}`) as the name for the class.

src/java.base/share/classes/java/security/AccessControlContext.java line 141:

> 139:         throws AccessControlException
> 140:     {
> 141:         throw new AccessControlException("");

No message for this exception?

src/java.base/share/classes/java/security/AccessControlException.java line 29:

> 27: 
> 28: /**
> 29:  *

Add a sentence like "This was..."?

src/java.base/share/classes/java/security/Policy.java line 90:

> 88:  *       and subject to removal in a future release. Consequently, this class
> 89:  *       is also deprecated and subject to removal. There is no replacement for
> 90:  *       the Security Manager or this class.

Don't you need at least one sentence as the body of the class spec here? Something like `Policy was...` which is similar to `AccessController`.

src/java.base/share/classes/java/security/Policy.java line 374:

> 372:      *
> 373:      * @param codesource the CodeSource to which the returned
> 374:      *          PermissionCollection has been granted

Can we say this parameter is ignored? I see some other methods said so.

Same with the other `getPermissions` and `implies`.

src/java.base/share/classes/java/security/SecureClassLoader.java line 1:

> 1: /*

The class spec still mentions "permissions which are retrieved by the system policy by default". Shall we remove it? Also, `getPermissions` always returns an empty `Permissions` object, do we need to add an `@apiNote` for it?

src/java.base/share/classes/java/security/Security.java line 489:

> 487: 
> 488:     /**
> 489:      * Adds a provider to the next position available..

Two periods at the end.

-------------

PR Review: https://git.openjdk.org/jdk/pull/21498#pullrequestreview-2395870667
PR Comment: https://git.openjdk.org/jdk/pull/21498#issuecomment-2438672204
PR Review Comment: https://git.openjdk.org/jdk/pull/21498#discussion_r1817189896
PR Review Comment: https://git.openjdk.org/jdk/pull/21498#discussion_r1817193883
PR Review Comment: https://git.openjdk.org/jdk/pull/21498#discussion_r1817194616
PR Review Comment: https://git.openjdk.org/jdk/pull/21498#discussion_r1817163586
PR Review Comment: https://git.openjdk.org/jdk/pull/21498#discussion_r1817173742
PR Review Comment: https://git.openjdk.org/jdk/pull/21498#discussion_r1817050537
PR Review Comment: https://git.openjdk.org/jdk/pull/21498#discussion_r1817042605


More information about the nio-dev mailing list