Skip to content

Conversation

@koushikthirupattur
Copy link
Contributor

@koushikthirupattur koushikthirupattur commented Jan 6, 2026

The method ckAssertReturnValueOK will invoke ckAssertReturnValueOK2 which makes multiple calls to JNI functions, such as FindClass or GetMethodID. These calls would be unsafe as there may be a pending exception at this time.
So adding exception check to return immediately and do not call any further JNI functions when there is exception pending.


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-8367024: JNI exception pending in Java_sun_security_pkcs11_wrapper_PKCS11_C_1DeriveKey of p11_keymgmt.c:950 (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 29054

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 6, 2026

👋 Welcome back koushikthirupattur! 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 Jan 6, 2026

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

8367024: JNI exception pending in Java_sun_security_pkcs11_wrapper_PKCS11_C_1DeriveKey of p11_keymgmt.c:950

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

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 (@haimaychao) 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 security security-dev@openjdk.org label Jan 6, 2026
@openjdk
Copy link

openjdk bot commented Jan 6, 2026

@koushikthirupattur 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 rfr Pull request is ready for review label Jan 6, 2026
@mlbridge
Copy link

mlbridge bot commented Jan 6, 2026

Webrevs

@openjdk
Copy link

openjdk bot commented Jan 8, 2026

⚠️ @koushikthirupattur the full name on your profile does not match the author name in this pull requests' HEAD commit. If this pull request gets integrated then the author name from this pull requests' HEAD commit will be used for the resulting commit. If you wish to push a new commit with a different author name, then please run the following commands in a local repository of your personal fork:

$ git checkout 8367024
$ git commit --author='Preferred Full Name <you@example.com>' --allow-empty -m 'Update full name'
$ git push

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 8, 2026
jKeyHandle =0L;
/* Do not continue if any copy-back operation raised an exception */
if ((*env)->ExceptionCheck(env)) {
goto cleanup;
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be necessary now; note that cleanup will be executed next whether the if branch is taken or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we might still need that. Cleanup will indeed execute either way, but the purpose of the ExceptionCheck() is not to ensure cleanup, it is to prevent further native logic from executing while a JNI exception is pending.

The copy-back helpers perform JNI operations that may raise exceptions independently of the PKCS#11 return value.

Copy link
Member

Choose a reason for hiding this comment

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

Well after c0eba30 there's no further native logic after this call, so there's nothing to prevent. The copy-back helpers are only invoked after a successful PKCS11 call now.

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

Labels

ready Pull request is ready to be integrated rfr Pull request is ready for review security security-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

3 participants