-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8328785: IOException: Symbol not found: C_GetInterface for PKCS11 interface prior to V3.0 #18588
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
Conversation
…erface prior to V3.0
👋 Welcome back valeriep! A progress list of the required criteria for merging this PR into |
@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:
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 137 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 |
@valeriepeng The following label will be automatically applied to this pull request:
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. |
Webrevs
|
C_GetInterface = (CK_C_GetInterface) dlsym(hModule, "C_GetInterface"); | ||
if ((C_GetInterface != NULL) && (dlerror() == NULL)) { | ||
if (C_GetInterface != NULL) { | ||
TRACE0("Connect: Found C_GetInterface func\n"); | ||
rv = (C_GetInterface)(NULL, NULL, &interface, 0L); | ||
if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) { | ||
goto setModuleData; | ||
} |
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.
Do we need an else goto cleanup
here?
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.
Not really, the intention is to continue with the C_GetFunctionList (or the method named by "getFunctionListStr").
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 that's the intention, then you shouldn't be using ckAssertReturnValueOK
, which throws an exception if rv
is anything other than CK_ASSERT_OK
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.
Good point, I will change it.
@@ -91,7 +91,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_connect | |||
jobject globalPKCS11ImplementationReference; | |||
char *systemErrorMessage; | |||
char *exceptionMessage; | |||
const char *getFunctionListStr = NULL; | |||
const char *getFunctionListStr = "C_GetFunctionList"; |
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 this value ever gets used by ReleaseStringUTFChars, the failure will be spectacular 🍿
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.
We do have checks for jGetFunctionList != NULL before calling ReleaseStringUTFChars() with it. So, this shouldn't be an issue?
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 will be an issue if jGetFunctionList != NULL
and dlopen
fails, resulting in goto cleanup
before getFunctionListStr
is reassigned.
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.
Hmm, ok, I will change it. Thanks~
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. One nit, feel free to ignore.
dlerror(); // clear any old error message not fetched | ||
C_GetFunctionList = (CK_C_GetFunctionList) dlsym(hModule, | ||
getFunctionListStr); | ||
if ((systemErrorMessage = dlerror()) != NULL){ |
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.
Would it make sense to move this check under if (C_GetFunctionList == NULL)
? If C_GetFunctionList
is non-null, do we care about the value of dlerror?
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.
Yes, makes sense, I'll change it.
@djelinski Thanks much for the review! |
TRACE0("Connect: Found C_GetFunctionList func\n"); | ||
TRACE1("Connect: No %s func\n", getFunctionListStr); | ||
p11ThrowIOException(env, "ERROR: C_GetFunctionList == NULL"); | ||
goto 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.
Just a small comment. The dlerror
is only for debugging purpose but the code above looks like it is used to determine whether to goto cleanup
.
How about this:
if (C_GetFunctionList == NULL) {
if ((systemErrorMessage = dlerror()) != NULL){
p11ThrowIOException(env, systemErrorMessage);
} else {
TRACE1("Connect: No %s func\n", getFunctionListStr);
p11ThrowIOException(env, "ERROR: C_GetFunctionList == NULL");
}
goto cleanup;
}
Also, why is TRACE1 not called when dlerror
is not NULL?
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.
Sure, thanks for the suggestion. I'll change and re-run the tests.
/integrate |
Going to push as commit 6276789.
Your commit was automatically rebased without conflicts. |
@valeriepeng Pushed as commit 6276789. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This PR fixes a problem regarding the usage of dlerror() where an earlier error message causes a premature error out. Added extra code to clear out earlier error message and made minor code refactoring.
No regression test as this can't be reproduced using the NSS library from artifactory and thus the noreg-hard label.
Thanks!
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18588/head:pull/18588
$ git checkout pull/18588
Update a local copy of the PR:
$ git checkout pull/18588
$ git pull https://git.openjdk.org/jdk.git pull/18588/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18588
View PR using the GUI difftool:
$ git pr show -t 18588
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18588.diff
Webrev
Link to Webrev Comment