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

8335288: SunPKCS11 initialization will call C_GetMechanismInfo on unsupported mechanisms #20207

Closed
wants to merge 2 commits into from

Conversation

valeriepeng
Copy link
Contributor

@valeriepeng valeriepeng commented Jul 17, 2024

Can someone help review this fix? Changed the required-mechanism check by checking if the particular mechanism is inside the list of enabled supported mechanisms. This should be more reliable than calling C_GetMechanismInfo(..) on the required mechanism given vendors may return various sorts of error codes.

Thanks,
Valerie


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-8335288: SunPKCS11 initialization will call C_GetMechanismInfo on unsupported mechanisms (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20207

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 17, 2024

👋 Welcome back valeriep! 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 Jul 17, 2024

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

8335288: SunPKCS11 initialization will call C_GetMechanismInfo on unsupported mechanisms

Reviewed-by: mbalao, weijun, hchao

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

  • 777ed2b: 8339132: Make DirectCodeBuilder write through without allocating instruction objects
  • e57b593: 8335062: NMT: Make StackIndex non-opaque
  • 8c8b580: 8338281: jshell does not run shutdown hooks
  • d35ffa4: 8339017: Make a couple of fields in DoubleByte static
  • 723588a: 8338569: HTTP/1.1 CleanupTrigger may be triggerred after the next exchange started
  • 362f9ce: 8339120: Use more fine-granular gcc unused warnings
  • f080b4b: 8333098: ubsan: bytecodeInfo.cpp:318:59: runtime error: division by zero
  • ff59532: 8338678: Erroneous parameterized type represented as
  • 0b4a7d5: 8324859: Improve error recovery
  • 1383fec: 8327381: Refactor type-improving transformations in BoolNode::Ideal to BoolNode::Value
  • ... and 470 more: https://git.openjdk.org/jdk/compare/c8a95a763c169b94c5ba07d2c6fbdf99ba3b9e3b...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 rfr Pull request is ready for review label Jul 17, 2024
@openjdk
Copy link

openjdk bot commented Jul 17, 2024

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

  • security

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 security security-dev@openjdk.org label Jul 17, 2024
@mlbridge
Copy link

mlbridge bot commented Jul 17, 2024

Webrevs

@haimaychao
Copy link
Contributor

LGTM.

@valeriepeng
Copy link
Contributor Author

LGTM.

Thanks Haimay for the review~

@driverkt
Copy link
Member

driverkt commented Jul 19, 2024

I understand that the sample config is for a test, but are there any mechanisms we would want to disable by default? It occurred to me as I was reading through the test and noticed that SHA1 was not in the disabled list for the test.

@valeriepeng
Copy link
Contributor Author

I understand that the sample config is for a test, but are there any mechanisms we would want to disable by default? It occurred to me as I was reading through the test and noticed that SHA1 was not in the disabled list for the test.

Are you asking about general PKCS11 provider configuration setting? For PKCS11 providers, users provide their provider configuration file and they decide what to disable. As for SHA-1, it's not disabled by default for SUN provider either.

@valeriepeng
Copy link
Contributor Author

@martinuy Can you also review this? IIRC, this is introduced by the PBE PKCS12 changes earlier.

Copy link
Contributor

@martinuy martinuy left a comment

Choose a reason for hiding this comment

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

Overall, I like the change because in addition to fixing the bug we will save some getMechanismInfo calls for mechanisms that are supported by the token but disabled in the configuration. I made a couple of minor comments, though.

Arrays.stream(supportedMechanisms).boxed().collect
(Collectors.toCollection(HashSet::new));
if (config.getDisabledMechanisms() != null) {
enabledMechSet.removeAll(config.getDisabledMechanisms());
Copy link
Contributor

Choose a reason for hiding this comment

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

Should enabledMechSet be further restricted to Config::enabledMechanisms (if set)? Config::disabledMechanisms looks like a fallback for when Config::enabledMechanisms is not set, according to Config::isEnabled. I'd keep the logic that makes Config::enabledMechanisms work in pair with Config::disabledMechanisms in a single place, as duplicating it into two different places may lead to misalignment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you have a good point. Let me think about it and see how to better handle this.


for (int i = 0; i < supportedMechanisms.length; i++) {
long longMech = supportedMechanisms[i];
for (long longMech : supportedMechanisms) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the code under if (!config.isEnabled(longMech)) { still needed? Looks to me that we will be iterating over enabled mechanisms now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just for the record, I want to note that we will not longer be showing information about supported but disabled mechanisms here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I agree that it's better to show info about supported but disabled mechanisms.

Copy link
Contributor

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

@valeriepeng
Copy link
Contributor Author

Looks good to me.

Thanks Martin for the review~

Copy link
Contributor

@wangweij wangweij left a comment

Choose a reason for hiding this comment

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

Change looks fine.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 29, 2024
@haimaychao
Copy link
Contributor

Updated webrev looks good.

@valeriepeng
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 13, 2024

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

  • 3aa8338: 8340075: Autoconf bundle cannot run on read-only filesystem
  • 37bf589: 8339847: Broken link to the dieharder distribution website in SplittableRandom
  • 89c172a: 8340082: Use inline return tag in java.base
  • 1a0a538: 8340120: Remove redundant code in SegmentBulkOperations::mismatch
  • 89ca89c: 8338626: ClassLoaderExt::process_jar_manifest() should allow / separator on Windows
  • 3e0da58: 8333843: Provide guidelines on MemorySegment to read strings with known lengths
  • 3c4d15b: 8334301: Errors in jpackage man page
  • 4d01178: 8339927: Man page update for deprecating jhsdb debugd for removal
  • bd44cf8: 8330302: strace004 can still fail
  • 8a4ea09: 8336492: Regression in lambda serialization
  • ... and 648 more: https://git.openjdk.org/jdk/compare/c8a95a763c169b94c5ba07d2c6fbdf99ba3b9e3b...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Sep 13, 2024

@valeriepeng Pushed as commit fdfe503.

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

@valeriepeng valeriepeng deleted the JDK-8335288 branch September 13, 2024 21:14
@kaarefc
Copy link

kaarefc commented Oct 7, 2024

Hi. I'm the original reporter of this issue.
Thanks for the work done on this bug.
I see the the fix has been targeted at only Java 24.
Are there any plans to back port this to Java 21, which is the current LTS version, and where the regression was introduced?

@valeriepeng
Copy link
Contributor Author

Hi. I'm the original reporter of this issue. Thanks for the work done on this bug. I see the the fix has been targeted at only Java 24. Are there any plans to back port this to Java 21, which is the current LTS version, and where the regression was introduced?

I have just opened a request to backport this to JDK 21 update. Someone from the sustaining team should handle the backport request. Thank~

@valeriepeng
Copy link
Contributor Author

Hi. I'm the original reporter of this issue. Thanks for the work done on this bug. I see the the fix has been targeted at only Java 24. Are there any plans to back port this to Java 21, which is the current LTS version, and where the regression was introduced?

I have just opened a request to backport this to JDK 21 update. Someone from the sustaining team should handle the backport request. Thank~

Correction: It'll be the OpenJDK21 maintainers to handle the backport request (not the sustaining team).

@valeriepeng
Copy link
Contributor Author

Hi. I'm the original reporter of this issue. Thanks for the work done on this bug. I see the the fix has been targeted at only Java 24. Are there any plans to back port this to Java 21, which is the current LTS version, and where the regression was introduced?

I have just opened a request to backport this to JDK 21 update. Someone from the sustaining team should handle the backport request. Thank~

Correction: It'll be the OpenJDK21 maintainers to handle the backport request (not the sustaining team).

@GoeLin I fixed this in jdk24 and the submitter hopes that can be backported to jdk21. Is this something that you can help with? Thanks!

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

Successfully merging this pull request may close these issues.

6 participants