Open es-fabricemarie opened 1 month ago
with some old fashion debugging printf I get this:
DEBUG DEBUG In pkcs11_get_session(): ctx is at 0x7405f0
DEBUG DEBUG In pkcs11_get_session(): ctx->method is at 0x7f38cf2fe220
DEBUG DEBUG In pkcs11_get_session(): ctx->method->C_GetSessionInfo function at 0x7f38cdcd799e
DEBUG DEBUG In pkcs11_get_session(): returning
DEBUG DEBUG: in pkcs11_get_evp_key_rsa(), before pkcs11_get_rsa(), key=0x87bbc0 slot=0x860390 ctx=0x7405f0 methods=0x7f38cf2fe220
DEBUG DEBUG: in pkcs11_get_rsa, before pkcs11_get_session(), key=0x87bbc0 slot=0x860390 ctx=0x7405f0 methods=0x7f38cf2fe220
DEBUG DEBUG In pkcs11_get_session(): ctx is at 0x7405f0
DEBUG DEBUG In pkcs11_get_session(): ctx->method is at 0x7f38cf2fe220
DEBUG DEBUG In pkcs11_get_session(): ctx->method->C_GetSessionInfo function at 0x7f38cdcd799e
DEBUG DEBUG In pkcs11_get_session(): after slot session head manipulation: ctx is at 0x7405f0
DEBUG DEBUG In pkcs11_get_session(): after slot session head manipulation: ctx->method is at 0x7f38cf2fe220
DEBUG DEBUG In pkcs11_get_session() after slot session head manipulation: ctx->method->C_GetSessionInfo function at 0x7f38cdcd799e
DEBUG DEBUG In pkcs11_get_session(): returning
DEBUG DEBUG: in pkcs11_get_rsa, after pkcs11_get_session(), key=0x87bbc0 slot=0x860390 ctx=0x7405f0 methods=0x7f38cf2fe220
DEBUG DEBUG: in pkcs11_get_rsa, after pkcs11_getattr_bn-1, key=0x87bbc0 slot=0x860390 ctx=0x7405f0 methods=0x7f38cf2fe220
DEBUG DEBUG: in pkcs11_get_rsa, we're in 'success:', key=0x87bbc0 slot=0x860390 ctx=0x7405f0 methods=0x7f38cf2fe220
DEBUG DEBUG: in pkcs11_get_rsa, in 'success:', after pkcs11_put_session key=0x87bbc0 slot=0x860390 ctx=0x7405f0 methods=0x7f38cf2fe220
DEBUG DEBUG: in pkcs11_get_rsa, in 'success:', after pkcs11_put_session key=0x87bbc0 slot=0x860390 ctx=0x7405f0 methods=0x7f38cf2fe220
DEBUG DEBUG: in pkcs11_get_rsa RETURNING key=0x87bbc0 slot=0x860390 ctx=0x7405f0 methods=0x7f38cf2fe220
DEBUG DEBUG: in pkcs11_get_evp_key_rsa(), after pkcs11_get_rsa(), key=0x87bbc0 slot=0x860390 ctx=0x7405f0 methods=0x7f38cf2fe220
DEBUG DEBUG: in pkcs11_get_evp_key_rsa(), before pkcs11_get_rsa(), key=0x87bbc0 slot=0x860390 ctx=0x7405f0 methods=0x2e3031342e322e31
DEBUG DEBUG: in pkcs11_get_rsa, before pkcs11_get_session(), key=0x87bbc0 slot=0x860390 ctx=0x7405f0 methods=0x2e3031342e322e31
DEBUG DEBUG In pkcs11_get_session(): ctx is at 0x7405f0
DEBUG DEBUG In pkcs11_get_session(): ctx->method is at 0x2e3031342e322e31
I believe the methods pointer should always stay the same for a specific ctx? Here it gets changed somehow.
As soon as the lib calls C_GetSessionInfo
on the "modified" ctx->methods pointer it sigsevs.
On Fedora 40, when I do something like this:
echo "We are going to use Fedora 39 openssl lib just to sign the binary"
mkdir /var/tmp/fedora-39-ssl-libs/
gunzip fedora39_libcrypto.so.3.gz
gunzip fedora39_libssl.so.3.gz
mv fedora39_libcrypto.so.3 /var/tmp/fedora-39-ssl-libs/libcrypto.so.3
mv fedora39_libssl.so.3 /var/tmp/fedora-39-ssl-libs/libssl.so.3
export LD_LIBRARY_PATH=/var/tmp/fedora-39-ssl-libs/
Then everything works and there is no segmentation violation.
The difference of OpenSSL versions are as such:
Fedora 39:
Fedora 40:
I've created a bug report for Google KMS PKCS11 library but it looks like it could be a libp11 issue: GoogleCloudPlatform/kms-integrations#28
I'm using the latest packages of Fedora 40.
openssl-pkcs11-0.4.12-8.fc40.x86_64
The backtrace of the coredump is:
I'm happy to help with the debugging/testing.
Thanks.