-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8341094: Clean up relax_verify in ClassFileParser #21954
Conversation
👋 Welcome back coleenp! A progress list of the required criteria for merging this PR into |
@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:
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 169 new commits pushed to the
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 |
Webrevs
|
…ed on one call in ClassFileParser.
I am honestly very confused by this code:
Can we instead set Then, you can change
|
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.
I won't pretend that I could follow your analysis in the full. At the end of the day we can relax verification (of all kinds) for trusted classes in the released product, but we should have a way to enforce all verification checks on trusted classes during development in case we introduce a bug and start producing invalid class files. I'm not sure that this latter part is actually in place unless "verify all" is explicitly enabled. Of course we will discover bad trusted class files one way or another, but enabling verification would make it more obvious as to the problem.
Doing additional checks on trusted classes is okay provided it doesn't affect startup or general performance - if verification (and related checks) were free we'd always do them, so there has to be a tipping point.
Thanks
// Return false if the class is loaded by the bootstrap loader, | ||
// or if defineClass was called requesting skipping verification | ||
// -Xverify:all overrides this value |
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.
This comment doesn't describe the new operation of this method.
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.
You're right. There was an old change that made defineClass explicitly disable verification. That code is gone now.
@@ -52,12 +52,12 @@ class ClassFileStream: public ResourceObj { | |||
const char* clone_source() const; | |||
|
|||
public: | |||
static const bool verify; | |||
constexpr static bool verify = true; |
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.
Where, and how, is this used?
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.
It's passed into the ClassFileStream constructor with default value true.
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.
I removed this and fixed all the constructor calls.
Ioi, I like your suggestion. That would make it even clearer. We could set the value of _need_verify once in ClassFileStream constructor, and propagate the value of _need_verify to ClassFileParser. ClassFileParser has a lot of checks for _need_verify so it's still better for ClassFileParser to have one. David, there are three different concepts of "trusted" in this code which caused the duplication that I'm trying to resolve. One is for package access which includes boot/platform/system class loader. My change removes #2 since checking names is a fast enough operation (doesn't call java unless < JDK 1.5), and most , and maybe all platform class loading is called with ClassFileStream::_need_verify == true anyway, so this code checked these names anyway. Further, I'm trying to only check for when we want verification #3 in only one place as it was set and reset between ClassFileStream and ClassFileParser, and the same code is called again effectively ignoring the value of should_verify_class value passed into the Verifier but getting the same result as the last call. |
Ioi, your suggestion of passing class_loader to stream creation is really a cumbersome change. The Stream's version of need_verify is an internal flag used for determining whether we need to check for truncation and should be based on the ClassFileParser's call when we're about to parse the stream. But I did some cleanup to further unexpose this field. |
…y based on what ClassFileParser gets for the answer based on the BytecodeVerificationnRemote/Local flags and the class loader.
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.
I like the update so that CFS defaults to needing verification unless CFP sets it otherwise.
Why do we need Maybe we should get rid of |
Get rid of it in what way? Implicitly always true, or implicitly always false? Or? |
Always true. E.g.,
|
We need to check performance here, particularly startup, as that is what would be most affected by always verifying boot classes. |
Yes, the classFileStream::_need_verify was added for performance. We had a one-pager design document (now gone) and everything for JDK-4990299. This was before CDS was default, but this isn't really the purpose of my making this change. I'm trying to fix another bug after this cleanup. |
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.
LGTM. This simplifies the code. There doesn't seem to be security risks as this PR only strengths the checks.
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.
If the changes are now stable then I am fine with them.
Thanks
Thanks Ioi and David for your reviews and improvements. |
Going to push as commit 2145ace.
Your commit was automatically rebased without conflicts. |
Removed ClassFileParser::_relax_verify and cleaned up setting need_verify in the ClassFileStream code and ClassFileParser. Wrote up how I found control to flow to this setting with -Xverify:all/none/remote settings, which become BytecodeVerificationRemote/Local in the CR comments.
Tested with tier1-4. Valid class, field and method name testing is done through the JCK and there are CDS tests that test verification in runtime/cds/appcds/VerifierTest.java.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21954/head:pull/21954
$ git checkout pull/21954
Update a local copy of the PR:
$ git checkout pull/21954
$ git pull https://git.openjdk.org/jdk.git pull/21954/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21954
View PR using the GUI difftool:
$ git pr show -t 21954
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21954.diff
Using Webrev
Link to Webrev Comment