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

8195744: Avoid calling ClassLoader.checkPackageAccess if security manager is not installed #2410

Closed
wants to merge 4 commits into from

Conversation

coleenp
Copy link
Contributor

@coleenp coleenp commented Feb 4, 2021

This change does not call up to Java for checkPackageAccess if the security manager is NULL, but still saves the protection domain in the pd_set for that dictionary entry. If the option -Djava.security.manager=disallow is set, that means that there will never be a security manager and the JVM code can avoid saving the protection domains completely.
See the two functions java_lang_System::has_security_manager() and java_lang_System::allow_security_manager() for details.
Also deleted ProtectionDomainVerification because there's no use for this option.

Tested with tier1 hotspot, jdk and langtools.
and tier2-6.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8195744: Avoid calling ClassLoader.checkPackageAccess if security manager is not installed

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2410/head:pull/2410
$ git checkout pull/2410

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 4, 2021

👋 Welcome back coleenp! 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 Feb 4, 2021
@openjdk
Copy link

openjdk bot commented Feb 4, 2021

@coleenp The following label will be automatically applied to this pull request:

  • hotspot-runtime

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 hotspot-runtime hotspot-runtime-dev@openjdk.org label Feb 4, 2021
@mlbridge
Copy link

mlbridge bot commented Feb 4, 2021

Webrevs

@mlchung
Copy link
Member

mlchung commented Feb 4, 2021

It's good to see this change benefitting from -Djava.security.manager=disallow work. A minor comment: VM now hardcodes the value for NEVER (1). It may worth adding a comment in System::NEVER of such dependency.

@coleenp
Copy link
Contributor Author

coleenp commented Feb 4, 2021

Thanks Mandy! It's nice to be able to optimize this. How's this comment? Is it an @implNote ??
// @implNote The HotSpot JVM hardcodes the value of NEVER.

@iklam
Copy link
Member

iklam commented Feb 5, 2021

Thanks Mandy! It's nice to be able to optimize this. How's this comment? Is it an @implNote ??
// @implNote The HotSpot JVM hardcodes the value of NEVER.

I think it's better to define const int NEVER = 1, and add code in debug builds to compare its value with the System::NEVER static field.

@coleenp
Copy link
Contributor Author

coleenp commented Feb 5, 2021

I didn't think a static final field would have an offset?
private static final int NEVER = 1;

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Hi Coleen,

Basic optimization looks good. I have a concern over the locking change. Some minor comments below.

Thanks,
David

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Feb 5, 2021
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Some comments remain confusing.

Thanks,
David

Comment on lines 4414 to 4415
// This field means that a security manager can be installed so we still have to
// populate the ProtectionDomainCacheTable.
Copy link
Member

Choose a reason for hiding this comment

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

No this field returns the installed SM if any. It doesn't tell you anything about whether you can install a SM or not (though obviously if non-NULL then you could).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

// This field tells us that a security manager is installed.

How about I just put this. I had a bug earlier that this explained to me but the allow_security_manager() also explains it.

src/java.base/share/classes/java/lang/System.java Outdated Show resolved Hide resolved
@openjdk openjdk bot removed the core-libs core-libs-dev@openjdk.org label Feb 5, 2021
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Updates seem fine to me.

Thanks,
David

@openjdk
Copy link

openjdk bot commented Feb 7, 2021

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

8195744: Avoid calling ClassLoader.checkPackageAccess if security manager is not installed

Reviewed-by: dholmes, iklam

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

  • ab65d53: 8261261: The version extra fields needs to be overridable in jib-profiles.js
  • 20d7713: 8261334: NMT: tuning statistic shows incorrect hash distribution
  • 92c6e6d: 8261254: Initialize charset mapping data lazily
  • 351d788: 8259074: regex benchmarks and tests
  • d6d5d9b: 8261231: Windows IME was disabled after DnD operation
  • 29a428f: 8261229: MethodData is not correctly initialized with TieredStopAtLevel=3
  • 48c932e: 8231286: HTML font size too large with high-DPI scaling and W3C_LENGTH_UNITS
  • dbc35f6: 8261094: Open javax/swing/text/html/CSS/4765271/bug4765271.java
  • db0ca2b: 8261161: Clean up warnings in hotspot/jtreg/vmTestbase tests
  • 2c28e36: 8237352: Update DatagramSocket to add support for joining multicast groups
  • ... and 37 more: https://git.openjdk.java.net/jdk/compare/c1dea39d08e3a9af03430b603e24192a02cde223...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 openjdk bot added the ready Pull request is ready to be integrated label Feb 7, 2021
@coleenp
Copy link
Contributor Author

coleenp commented Feb 8, 2021

Thanks for the code review, David.

@coleenp
Copy link
Contributor Author

coleenp commented Feb 8, 2021

Thanks for the code review Ioi, and thank you Mandy for looking at it.
/integrate

@openjdk openjdk bot closed this Feb 8, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 8, 2021
@openjdk
Copy link

openjdk bot commented Feb 8, 2021

@coleenp Since your change was applied there have been 47 commits pushed to the master branch:

  • ab65d53: 8261261: The version extra fields needs to be overridable in jib-profiles.js
  • 20d7713: 8261334: NMT: tuning statistic shows incorrect hash distribution
  • 92c6e6d: 8261254: Initialize charset mapping data lazily
  • 351d788: 8259074: regex benchmarks and tests
  • d6d5d9b: 8261231: Windows IME was disabled after DnD operation
  • 29a428f: 8261229: MethodData is not correctly initialized with TieredStopAtLevel=3
  • 48c932e: 8231286: HTML font size too large with high-DPI scaling and W3C_LENGTH_UNITS
  • dbc35f6: 8261094: Open javax/swing/text/html/CSS/4765271/bug4765271.java
  • db0ca2b: 8261161: Clean up warnings in hotspot/jtreg/vmTestbase tests
  • 2c28e36: 8237352: Update DatagramSocket to add support for joining multicast groups
  • ... and 37 more: https://git.openjdk.java.net/jdk/compare/c1dea39d08e3a9af03430b603e24192a02cde223...master

Your commit was automatically rebased without conflicts.

Pushed as commit ace8f94.

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

@coleenp coleenp deleted the check-access branch February 8, 2021 21:43
Copy link
Member

@mlchung mlchung 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.

@coleenp
Copy link
Contributor Author

coleenp commented Feb 8, 2021

Thanks Mandy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
4 participants