Skip to content
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

8297451: ProcessHandleImpl should assert privilege when modifying reaper thread #11309

Closed
wants to merge 4 commits into from

Conversation

rjernst
Copy link
Contributor

@rjernst rjernst commented Nov 23, 2022

This commit guards thread modifications for the process reaper thread with doPrivileged.


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-8297451: ProcessHandleImpl should assert privilege when modifying reaper thread

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11309

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

Using diff file

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

…per thread

This commit guards thread modifications for the process reaper thread
with doPrivileged.
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 23, 2022

👋 Welcome back rjernst! 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 openjdk bot added the rfr Pull request is ready for review label Nov 23, 2022
@openjdk
Copy link

openjdk bot commented Nov 23, 2022

@rjernst 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 23, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 23, 2022

Webrevs

@ChrisHegarty
Copy link
Member

Hi @rjernst Thanks for taking this one on.

I agree with adding the privileged blocks around the calls to Thread::setName, but the usage raises a warning which fails the build. It might be cleaner and easier to refactor into a privilegedThreadSetName helper method.

Additionally, I noticed that there is an existing test that can be modified slightly to cover this.

I've put these two comments / suggestions in the form of a PR and raised it against your branch. rjernst#1

*/
public static Thread newSystemThread(String name, Runnable target,
long stackSize, int priority,
boolean daemon) {
Copy link
Member

@ChrisHegarty ChrisHegarty Nov 23, 2022

Choose a reason for hiding this comment

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

Thanks for adding this overload, I think that it will be useful for the future too. ( it never seems to matter how many variants of these factories we have, we still need one more :-) )

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to to avoid creating new factories when the desired function can be done on the resulting thread.
Such as setDaemon() and setName(), etc.
It does avoid the doPriv in this case, but is not necessary and when the security manager goes away, will leave around clutter (duplicated) functionality.

Copy link
Member

Choose a reason for hiding this comment

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

Looking beyond this specific change, there is a lot of potential use for this new factory elsewhere in the code. It also avoids similar bugs from possibly reoccurring (by having the setDaemon call inside the factory).

Copy link
Member

Choose a reason for hiding this comment

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

In the interest of making progress, let’s revert the change to the factory. This can be done separately, if at all.

Add privileged helper method and update existing test
@openjdk
Copy link

openjdk bot commented Nov 26, 2022

⚠️ @rjernst This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

Copy link
Member

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

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

LGTM

@openjdk
Copy link

openjdk bot commented Nov 26, 2022

@rjernst 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:

8297451: ProcessHandleImpl should assert privilege when modifying reaper thread

Reviewed-by: chegar, alanb

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 43 new commits pushed to the master branch:

  • 99d3840: 8297359: RISC-V: improve performance of floating Max Min intrinsics
  • 6c05771: 8295447: NullPointerException with invalid pattern matching construct in constructor call
  • 76a24c3: 8297145: Add a @sealedGraph tag to ConstantDesc
  • 099b42f: 8297148: Add a @sealedGraph tag to CallSite
  • 85ddd8f: 8295253: Remove kludge from v1_0/PerfDataBuffer.java
  • 952e100: 8297431: [JVMCI] HotSpotJVMCIRuntime.encodeThrowable should not throw an exception
  • 08e6a82: 8297590: [TESTBUG] HotSpotResolvedJavaFieldTest does not run
  • 4f65570: 8294583: JShell: NPE in switch with non existing record pattern
  • fd910f7: 8297384: Add IR tests for existing idealizations of arithmetic nodes
  • cfe5a37: 8297556: Parse::check_interpreter_type fails with assert "must constrain OSR typestate"
  • ... and 33 more: https://git.openjdk.org/jdk/compare/b4bd287f736b6b5dcfe1b183cae9b11eb6f22686...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@ChrisHegarty, @AlanBateman) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 26, 2022
Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

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

This looks okay. Not important but can eliminate the casts from privilegedThreadSetXXX methods if you separate the creation of the PrivilegedAction from the doPriv call.

@rjernst
Copy link
Contributor Author

rjernst commented Nov 26, 2022

/integrate

@rjernst
Copy link
Contributor Author

rjernst commented Nov 26, 2022

Not important but can eliminate the casts from privilegedThreadSetXXX methods if you separate the creation of the PrivilegedAction from the doPriv call.

I chose to keep it as is since there was already another doPriv in the file that uses the cast style.

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Nov 26, 2022
@openjdk
Copy link

openjdk bot commented Nov 26, 2022

@rjernst
Your change (at version bc42d41) is now ready to be sponsored by a Committer.

@ChrisHegarty
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Nov 26, 2022

Going to push as commit 50f9043.
Since your change was applied there have been 43 commits pushed to the master branch:

  • 99d3840: 8297359: RISC-V: improve performance of floating Max Min intrinsics
  • 6c05771: 8295447: NullPointerException with invalid pattern matching construct in constructor call
  • 76a24c3: 8297145: Add a @sealedGraph tag to ConstantDesc
  • 099b42f: 8297148: Add a @sealedGraph tag to CallSite
  • 85ddd8f: 8295253: Remove kludge from v1_0/PerfDataBuffer.java
  • 952e100: 8297431: [JVMCI] HotSpotJVMCIRuntime.encodeThrowable should not throw an exception
  • 08e6a82: 8297590: [TESTBUG] HotSpotResolvedJavaFieldTest does not run
  • 4f65570: 8294583: JShell: NPE in switch with non existing record pattern
  • fd910f7: 8297384: Add IR tests for existing idealizations of arithmetic nodes
  • cfe5a37: 8297556: Parse::check_interpreter_type fails with assert "must constrain OSR typestate"
  • ... and 33 more: https://git.openjdk.org/jdk/compare/b4bd287f736b6b5dcfe1b183cae9b11eb6f22686...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 26, 2022

@ChrisHegarty @rjernst Pushed as commit 50f9043.

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

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.

4 participants