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

Fix probing of C_GetInterface #535

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

xry111
Copy link
Contributor

@xry111 xry111 commented Jul 27, 2023

p11_dl_symbol (dl, "C_GetInterface") uses dlsym() to find C_GetInterface in the loaded pkcs11 module. For legacy (pre-3.0) pkcs11 modules, C_GetInterface is not defined in the module. But according to the documentation of dlsym():

The search performed by dlsym() is breadth first through the
dependency tree of these shared objects.

So if a pkcs11 module links to libp11-kit.so, the C_GetInterface implementation in libp11-kit.so itself will be found. This C_GetInterface will return the metadata of p11-kit-trust.so, causing "Refuse to load the p11-kit-proxy.so as a registered module".

To solve the issue, if p11_dl_symbol() returns the C_GetInterface in libp11-kit.so itself, we should ignore it and continue trying C_GetFunctionList.

@coveralls
Copy link

coveralls commented Jul 27, 2023

Coverage Status

coverage: 69.627% (-0.005%) from 69.632% when pulling 5edad66 on xry111:xry111/fix-get-interface-check into 4d58e40 on p11-glue:master.

`p11_dl_symbol (dl, "C_GetInterface")` uses dlsym() to find
C_GetInterface in the loaded pkcs11 module.  For legacy (pre-3.0) pkcs11
modules, C_GetInterface is not defined in the module.  But according to
the documentation of dlsym():

    The search performed by dlsym() is breadth first through the
    dependency tree of these shared objects.

So if a pkcs11 module links to libp11-kit.so, the C_GetInterface
implementation in libp11-kit.so itself will be found.  This
C_GetInterface will return the metadata of p11-kit-proxy.so, causing
"Refuse to load the p11-kit-proxy.so as a registered module".

To solve the issue, if p11_dl_symbol() returns the C_GetInterface in
libp11-kit.so itself, we should ignore it and continue trying
C_GetFunctionList.
@xry111 xry111 force-pushed the xry111/fix-get-interface-check branch from 06b3285 to 5edad66 Compare July 27, 2023 04:38
Copy link
Member

@ueno ueno left a comment

Choose a reason for hiding this comment

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

Looks sensible to me. Thank you!

@ueno ueno merged commit d1d4b0a into p11-glue:master Jul 27, 2023
12 checks passed
@mcatanzaro
Copy link

Hey, I notice this fix is not released yet. It seems p11-kit 0.25.0 breaks glib-networking's tests because its mock-pkcs11.so fails to load, and this pull request fixes it. Perhaps time for a 0.25.1 release?

@ZoltanFridrich
Copy link
Contributor

Hey, I notice this fix is not released yet. It seems p11-kit 0.25.0 breaks glib-networking's tests because its mock-pkcs11.so fails to load, and this pull request fixes it. Perhaps time for a 0.25.1 release

The new release is at least one feature and few bug fixes away. I guess we will make 0.25.1 release in October. Unless something very urgent comes.

@nickyang777
Copy link

I've also found that it seems p11-kit 0.25.0(466a31b) breaks glib-networking's tests, but this commit doesn't fix it completely, and there are still some test cases that fail.

@xry111
Copy link
Contributor Author

xry111 commented Sep 20, 2023

I've also found that it seems p11-kit 0.25.0(466a31b) breaks glib-networking's tests, but this commit doesn't fix it completely, and there are still some test cases that fail.

It makes the test result clean for me (with glib-networking-2.78.0):

[0/1] Running all tests.
1/5 gnome                           OK              0.05s
2/5 certificate-gnutls              OK              0.05s
3/5 file-database-gnutls            OK              0.15s
4/5 connection-gnutls-tls1.2        OK              5.96s
5/5 connection-gnutls               OK              6.23s

Ok:                 5   
Expected Fail:      0   
Fail:               0   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0   

I've not enabled libproxy or openssl though.

@nickyang777
Copy link

I've also found that it seems p11-kit 0.25.0(466a31b) breaks glib-networking's tests, but this commit doesn't fix it completely, and there are still some test cases that fail.

It makes the test result clean for me (with glib-networking-2.78.0):

[0/1] Running all tests.
1/5 gnome                           OK              0.05s
2/5 certificate-gnutls              OK              0.05s
3/5 file-database-gnutls            OK              0.15s
4/5 connection-gnutls-tls1.2        OK              5.96s
5/5 connection-gnutls               OK              6.23s

Ok:                 5   
Expected Fail:      0   
Fail:               0   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0   

I've not enabled libproxy or openssl though.

The patch of the community is integrated based on the 2.76.1 version, but the test case still fails.
1/6 gnome OK 0.03s
2/6 certificate-gnutls OK 0.04s
3/6 file-database-gnutls OK 0.10s
4/6 environment-libproxy OK 0.13s
5/6 connection-gnutls-tls1.2 FAIL 1.40s killed by signal 6 SIGABRT
6/6 connection-gnutls FAIL 1.81s killed by signal 6 SIGABRT

What are the versions of glib2 and gnutls you use?

@xry111
Copy link
Contributor Author

xry111 commented Sep 20, 2023

What are the versions of glib2 and gnutls you use?

glib-2.78.0 and gnutls-3.8.0. I'll update to gnutls-3.8.1 and try again...

@xry111
Copy link
Contributor Author

xry111 commented Sep 20, 2023

What are the versions of glib2 and gnutls you use?

glib-2.78.0 and gnutls-3.8.0. I'll update to gnutls-3.8.1 and try again...

Same result with gnutls-3.8.1.

@mcatanzaro
Copy link

Feel free to report a glib-networking issue (when GNOME GitLab recovers; currently it is broken) with a backtrace showing where the test is failing, unless you have some reason to believe p11-kit is to blame for those failures.

@nickyang777
Copy link

Thank you for your reply. I tried again and rebuilt it based on p11-kit. The glib-networking'test was successful

@ueno ueno added this to the 0.25.1 milestone Oct 19, 2023
oreo639 added a commit to oreo639/void-packages that referenced this pull request Mar 21, 2024
Fixes issue where the wrong C_GetInterface may get loaded.
p11-glue/p11-kit#535
oreo639 added a commit to oreo639/void-packages that referenced this pull request Mar 21, 2024
Fixes issue where the wrong C_GetInterface may get loaded.
p11-glue/p11-kit#535
oreo639 added a commit to oreo639/void-packages that referenced this pull request Mar 21, 2024
Fixes issue where the wrong C_GetInterface may get loaded.
p11-glue/p11-kit#535
oreo639 added a commit to oreo639/void-packages that referenced this pull request Mar 21, 2024
Fixes issue where the wrong C_GetInterface may get loaded.
p11-glue/p11-kit#535
oreo639 added a commit to oreo639/void-packages that referenced this pull request Mar 21, 2024
Fixes issue where the wrong C_GetInterface may get loaded.
p11-glue/p11-kit#535
oreo639 added a commit to oreo639/void-packages that referenced this pull request Mar 21, 2024
Fixes issue where the wrong C_GetInterface may get loaded.
p11-glue/p11-kit#535
oreo639 added a commit to void-linux/void-packages that referenced this pull request Mar 22, 2024
Fixes issue where the wrong C_GetInterface may get loaded.
p11-glue/p11-kit#535
atweiden added a commit to atweiden/voidpkgs that referenced this pull request Mar 22, 2024
Fixes issue where the wrong C_GetInterface may get loaded.
p11-glue/p11-kit#535

void-linux/void-packages@4653d29
snwnde pushed a commit to snwnde/void-packages that referenced this pull request Apr 18, 2024
Fixes issue where the wrong C_GetInterface may get loaded.
p11-glue/p11-kit#535
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants