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

Segmentation fault after calling C_GenerateKeyPair, when finishing the key generation process #2198

Open
fucicek23 opened this issue Jan 8, 2021 · 6 comments

Comments

@fucicek23
Copy link

fucicek23 commented Jan 8, 2021

Problem Description

We are calling C_GenerateKeyPair from "opensc-pkcs11.so" by our system, but intermittently(but mostly) segmentation fault is thrown. When I check it by debugging my system, I saw this error in debugging logs: "malloc: Incorrect checksum for freed object 0x14b0c2040: probably modified after being freed."

After calling C_GenerateKeyPair, exception is thrown approximately after 1 minute.

Steps to reproduce

We call C_GenerateKeyPair from our system like this:

    CK_RV rv;
    {
        ScopedSystemTokenLocker locker;
	rv = pFunctionList_->C_GenerateKeyPair(session, &mechanism,
	                                       publicKeyTemplate, sizeof(publicKeyTemplate) / sizeof(CK_ATTRIBUTE),
	                                       privateKeyTemplate, sizeof(privateKeyTemplate) / sizeof(CK_ATTRIBUTE),
	                                       &publicKeyHandle, &privateKeyHandle);
    }

My version of OpenSC: OpenSC-0.20.0, rev: 45e2905, commit-time: 2019-12-29 13:42:06 +0100
My Operating System: Mac OS X Big Sur 11.1

Logs

Thread dump after crash is shown below:

0   libsystem_malloc.dylib        	0x00007fff2017528e tiny_free_list_remove_ptr + 255
1   libsystem_malloc.dylib        	0x00007fff20174748 tiny_free_no_lock + 1018
2   libsystem_malloc.dylib        	0x00007fff201741f9 free_tiny + 442
3   libopensc.6.dylib             	0x000000011e7ae1d3 pgp_calculate_and_store_fingerprint + 2627
4   libopensc.6.dylib             	0x000000011e7acbdf pgp_parse_and_set_pubkey_output + 1887
5   libopensc.6.dylib             	0x000000011e7aa2e1 pgp_gen_key + 2321
6   libopensc.6.dylib             	0x000000011e7a553c pgp_card_ctl + 460
7   libopensc.6.dylib             	0x000000011e726a7e sc_card_ctl + 158
8   libopensc.6.dylib             	0x000000011e93e06d openpgp_generate_key_rsa + 1405
9   libopensc.6.dylib             	0x000000011e93cd82 openpgp_generate_key + 162
10  libopensc.6.dylib             	0x000000011e8d7b9f sc_pkcs15init_generate_key + 2895
11  opensc-pkcs11.so              	0x000000011e51df2b pkcs15_gen_keypair + 2923
12  opensc-pkcs11.so              	0x000000011e50f3c5 C_GenerateKeyPair + 501
@frankmorgner
Copy link
Member

please upgrade to 0.21.0 and try again

@fucicek23
Copy link
Author

Hello, I upgraded but the issue still occurs.

@frankmorgner
Copy link
Member

Can you create a debug log of 0.21.0, please?

@fucicek23
Copy link
Author

debuglog.log
Log is added.

@fucicek23
Copy link
Author

Hello, did you find some time to check the logs?

@frankmorgner
Copy link
Member

I cannot immediately see where the problem is. above, you've printed some backtrace, could you do that with OpenSC debug symbols? That would show the exact problem. thank you.

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

No branches or pull requests

2 participants