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

8289275: Remove incorrect __declspec(dllimport) attributes from pointers in jdk.crypto.cryptoki #9353

Closed
wants to merge 4 commits into from

Conversation

TheShermanTanker
Copy link
Contributor

@TheShermanTanker TheShermanTanker commented Jul 2, 2022

Several instances of function pointers in jdk.crypto.cryptoki are marked with the dllimport attribute, which should only be applied to symbol declarations, of which a typedef'd function pointer is not. This would only be useful if a function pointer defined in the linked dll is desired to be imported, not if the pointer itself is created locally and used to store a function address. In addition to being incorrect, at least on the versions of Visual C++ the JDK supports today, it is also redundant; Typically they are used to avoid an indirect stub that jumps to the proper entry in the import address table, but usage of these typedefs involves loading the address of a function and directly (Usually through GetProcAddress, even in other cases it would simply be set to the address of a function anyway) assigning it to the pointer before immediately dispatching when called, which bypasses this procedure entirely and makes the attribute pointless.


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-8289275: Remove incorrect __declspec(dllimport) attributes from pointers in jdk.crypto.cryptoki

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9353

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 2, 2022

👋 Welcome back jwaters! 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 changed the title 8289275 8289275: Remove incorrect __declspec(dllimport) attributes from pointers in jdk.crypto.cryptoki Jul 2, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 2, 2022
@openjdk
Copy link

openjdk bot commented Jul 2, 2022

@TheShermanTanker 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 2, 2022
@mlbridge
Copy link

mlbridge bot commented Jul 2, 2022

Webrevs

@valeriepeng
Copy link

pkcs11.h is a standard header file from OASIS. Best to leave it alone. Just my .02.

@TheShermanTanker
Copy link
Contributor Author

pkcs11.h is a standard header file from OASIS. Best to leave it alone. Just my .02.

The only change to pkcs11.h is in a comment though, the other changes are outside the ANSI C headers from the standard. Should I just revert the comment in that case?

@TheShermanTanker
Copy link
Contributor Author

TheShermanTanker commented Jul 10, 2022

Tested with Microsoft (R) C/C++ Optimizing Compiler Version 19.31.31104 while observing FPTR_VersionCheck used in the method JNIEXPORT jboolean JNICALL Java_sun_security_pkcs11_Secmod_nssVersionCheck (j2secmod.c, line 40 and line 54), no differences in the generated assembly snippets:

Without __declspec(dllimport):

   0:	48 83 ec 38          	sub    $0x38,%rsp
   4:	48 8d 0d 00 00 00 00 	lea    0x0(%rip),%rcx
   b:	ff 54 24 20          	call   *0x20(%rsp)
   f:	33 c0                	xor    %eax,%eax
  11:	48 83 c4 38          	add    $0x38,%rsp
  15:	c3                   	ret   

With __declspec(dllimport):

   0:	48 83 ec 38          	sub    $0x38,%rsp
   4:	48 8d 0d 00 00 00 00 	lea    0x0(%rip),%rcx
   b:	ff 54 24 20          	call   *0x20(%rsp)
   f:	33 c0                	xor    %eax,%eax
  11:	48 83 c4 38          	add    $0x38,%rsp
  15:	c3                   	ret    

@valeriepeng
Copy link

pkcs11.h is a standard header file from OASIS. Best to leave it alone. Just my .02.

The only change to pkcs11.h is in a comment though, the other changes are outside the ANSI C headers from the standard. Should I just revert the comment in that case?

Sounds good to me.
Will take a look at the rest of changes in a day or two.
Thanks!

@TheShermanTanker
Copy link
Contributor Author

pkcs11.h is a standard header file from OASIS. Best to leave it alone. Just my .02.

The only change to pkcs11.h is in a comment though, the other changes are outside the ANSI C headers from the standard. Should I just revert the comment in that case?

Sounds good to me. Will take a look at the rest of changes in a day or two. Thanks!

Alright, will do. I also do want to look at p11_md.h to see if my changes are appropriate in the meantime, as I have a feeling it can be accomplished somewhat more elegantly

Thanks for the review!

@openjdk
Copy link

openjdk bot commented Jul 19, 2022

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

8289275: Remove incorrect __declspec(dllimport) attributes from pointers in jdk.crypto.cryptoki

Reviewed-by: valeriep

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 82 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 (@valeriepeng) 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 Jul 20, 2022
@TheShermanTanker
Copy link
Contributor Author

/integrate

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

openjdk bot commented Jul 20, 2022

@TheShermanTanker
Your change (at version 3babccb) is now ready to be sponsored by a Committer.

@TheShermanTanker
Copy link
Contributor Author

@valeriepeng Might need you to sponsor this, thanks for the review!

@valeriepeng
Copy link

/sponsor

@openjdk
Copy link

openjdk bot commented Jul 21, 2022

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

  • 620c8a0: 8289643: File descriptor leak with ProcessBuilder.startPipeline
  • 7ec0132: 8286844: com/sun/jdi/RedefineCrossEvent.java failed with 1 threads completed while VM suspended
  • 80bd8c3: 8290504: Close streams returned by ModuleReader::list
  • 15f4b30: 8290115: ArrayCopyObject JMH has wrong package
  • 4c1cd66: 8288368: simplify code in ValueTaglet, remove redundant code
  • 6346c33: 8290826: validate-source failures after JDK-8290016
  • 604a115: 8290016: IGV: Fix graph panning when mouse dragged outside of window
  • 59e495e: 8290704: x86: TemplateTable::_new should not call eden_allocate() without contiguous allocs enabled
  • 799a2c8: 8276561: URL$DefaultFactory::PREFIX should be static final
  • 52cc6cd: 8288723: Avoid redundant ConcurrentHashMap.get call in java.time
  • ... and 116 more: https://git.openjdk.org/jdk/compare/dbab827bee5297c19b10f0923a962fe6c0ac5cbd...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 21, 2022
@openjdk openjdk bot closed this Jul 21, 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 Jul 21, 2022
@openjdk
Copy link

openjdk bot commented Jul 21, 2022

@valeriepeng @TheShermanTanker Pushed as commit 0dda3c1.

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

@TheShermanTanker TheShermanTanker deleted the typedefs branch July 21, 2022 19:12
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
2 participants