Skip to content

Conversation

@stuart-marks
Copy link
Member

@stuart-marks stuart-marks commented Nov 15, 2024

First cut at removal of Security Manager stuff from RMI.

This covers just about every SM-related case in RMI, except for a bit of package checking in MarshalInputStream. This will be handled separately. It's covered by JDK-8344329.

Further simplifications could be done in RuntimeUtil and NewThreadAction. However, those changes started to become somewhat more intrusive than I'd like for this PR, which is focused on removing security-related stuff. EDIT: I've filed JDK-8344461 to cover this additional cleanup work.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8344149: Remove usage of Security Manager from java.rmi (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22129/head:pull/22129
$ git checkout pull/22129

Update a local copy of the PR:
$ git checkout pull/22129
$ git pull https://git.openjdk.org/jdk.git pull/22129/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22129

View PR using the GUI difftool:
$ git pr show -t 22129

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22129.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 15, 2024

👋 Welcome back smarks! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 15, 2024

@stuart-marks This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8344149: Remove usage of Security Manager from java.rmi

Reviewed-by: rriggs, kevinw, aefimov

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 107 new commits pushed to the master branch:

  • 5cb0d43: 8293040: Argfile documentation for java launcher tool is confusing regarding usage of wildcards
  • 8d43e0d: 8344331: SM cleanup in java.scripting
  • f636674: 8344247: Move objectWaiter field to VirtualThread instance
  • de6e013: 8344310: Remove Security Manager dependencies from javax.crypto and com.sun.crypto packages
  • 92271af: 8344058: Remove doPrivileged calls from macos platform sources in the java.desktop module
  • 70eb95f: 8344187: Remove SecurityManager and related calls from java.instrument
  • 922b12f: 8344078: Remove security manager dependency in java.nio
  • 2649406: 8344352: 32-bit builds crash after JDK-8305895
  • e9e4200: 8343125: Correct the documentation for TreeMap's getFloorEntry and getCeilingEntry
  • c59adf6: 8344330: Remove AccessController.doPrivileged() from jdk.charsets module
  • ... and 97 more: https://git.openjdk.org/jdk/compare/168b18ec68dd5488704cf76895d2449cd86428a6...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Nov 15, 2024

@stuart-marks The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Nov 15, 2024
@stuart-marks stuart-marks changed the title First cut at removal of Security Manager stuff from RMI. 8344149: Remove usage of Security Manager from java.rmi Nov 15, 2024
@stuart-marks stuart-marks marked this pull request as ready for review November 18, 2024 17:00
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 18, 2024
@mlbridge
Copy link

mlbridge bot commented Nov 18, 2024

Webrevs

Copy link
Contributor

@kevinjwalls kevinjwalls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. 8-)

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 18, 2024
Copy link
Member

@AlekseiEfimov AlekseiEfimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me, with two suggestions below.


/**
* special child of the system thread group for running tasks that
* may execute user code, so that the security policy for threads in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still want to mention security policy here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I should probably edit that. I don't want to change the thread group behavior, so the justification for the thread group might mention the (historical) effect on security policy.

.equalsIgnoreCase("false");

/** table to hold sun classes to which access is explicitly permitted */
protected static Map<String, Class<?>> permittedSunClasses
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like permittedSunClasses map can be removed alongside to checkSunClass(String, AccessControlException) method, since it is only called on line 198:

} catch (@SuppressWarnings("removal") AccessControlException e) {
     return checkSunClass(className, e);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, missed your comment in a PR description - ignore the comment above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this will be covered by JDK-8344329.

Copy link
Contributor

@RogerRiggs RogerRiggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok, but some additional cleanup is recommended.

* @author Peter Jones
**/
public final class NewThreadAction implements PrivilegedAction<Thread> {
public final class NewThreadAction {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest inlining the methods and getting rid of the class, moving non-trivial methods to an existing Util class.
Or at least renaming it to to drop the "Action" that is indicative of doPrivileged.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, further cleanup should be done here. I had started on it but I backed away since it felt like a distraction from the initial pass of removing direct SecurityManager and AccessController calls. I've filed JDK-8344461 to cover the followup work.

public void startNewAcceptor() {
@SuppressWarnings("removal")
Thread t = AccessController.doPrivileged(
Thread t =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fold to previous line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Nov 18, 2024
Copy link
Contributor

@RogerRiggs RogerRiggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 18, 2024
@stuart-marks
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Nov 19, 2024

Going to push as commit 6a5256e.
Since your change was applied there have been 138 commits pushed to the master branch:

  • 0b1f571: 8253440: serviceability/sa/TestJhsdbJstackLineNumbers.java failed with "Didn't find enough line numbers"
  • 93e889b: 8342449: reimplement: JDK-8327114 Attach in Linux may have wrong behavior when pid == ns_pid
  • bb7a840: 8342541: Exclude List/KeyEventsTest/KeyEventsTest.java from running on macOS
  • 087a07b: 8343479: Remove unnecessary @SuppressWarnings annotations (hotspot)
  • 02ec8ca: 8342508: Use latch in BasicMenuUI/bug4983388.java instead of delay
  • 47ebf8d: 8342098: Write a test to compare the images
  • 78602be: 8344024: Unnecessary Hashtable usage in RSAPSSSignature.DIGEST_LENGTHS
  • 7f672eb: 8344550: Compilation error of jpackage test JPackageStringBundle.java source
  • 48223f7: 8344143: Test jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java timed out on macosx-x64
  • d4cd27e: 8344445: MethodCounters don't need a vptr
  • ... and 128 more: https://git.openjdk.org/jdk/compare/168b18ec68dd5488704cf76895d2449cd86428a6...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 19, 2024
@openjdk openjdk bot closed this Nov 19, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 19, 2024
@openjdk
Copy link

openjdk bot commented Nov 19, 2024

@stuart-marks Pushed as commit 6a5256e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.


import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.security.util.SecurityConstants;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any remaining uses of sun.security.util.* in java.rmi? I suspect this is the last one, in which case you can update java.base's module-info to not export this package to java.rmi.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check if it is the last one as part of JDK-8344299.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger has filed JDK-8344867 to cover cleanup of the unneeded qualified export.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

5 participants