-
Notifications
You must be signed in to change notification settings - Fork 713
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
SIGSEGV in sc_pin_cmd() #373
Comments
The free_p11card is there because line 223: p11card = slot->card; But that does not explain what is going on. The code path that fails maybe caused by how libp11 Or one of the routines called in card_detect save the pointer to the p11card in a slot or reader structure. I assume you compiled and installed OpenSC, then compiled and installed libp11, then compiled An OpenSC debug log would be helpful... On 2/6/2015 12:53 PM, philipWendland wrote:
Douglas E. Engert [email protected] |
I have spend some more time in gdb - the problem is sc_pin_cmd() that is being called with a dangling pointer:
C_GetTokenInfo() calls slot_get_token() and passes slot->card->card, a invalid pointer, to sc_pin_cmd(). Let's continue with slot_get_token() - it calls slot_get_slot(), which in return uses a "virtual_slots" list, a global variable in pkcs11-global.c. I think this is where the p11card is supposed to be referenced. Thus, it might be that p11card is not free'd and 3a92bf7 from a few days ago should be partially reverted. Maybe this was a false positive memory leak from coverity.
Remember the address from "card".
I need to observe the "allocation side" tomorrow and try to find out how the pointer finds it way to virtual_slots. Will also post OpenSC logs. Sorry that I have not done so already, need to get AFK ASAP. P.S. this is not limited to engine_pkcs11 or libp11:
This SIGSEGV does also not appear when not free'ing p11card. |
b94c163 - invalid, non-tested 11881a6 -- src/libopensc/card-iasecc.c -- return from select has to be ignored, 3a92bf7 -- src/pkcs11/slot.c -- SEGFAULT issue OpenSC#373 3a92bf7 -- src/tools/piv-tool.c -- confirmed by author 6759c04 -- src/pkcs15init/pkcs15-lib.c -- file instantiation error has to be ignored
b94c163 - invalid, non-tested 11881a6 -- src/libopensc/card-iasecc.c -- return from select has to be ignored, 3a92bf7 -- src/pkcs11/slot.c -- SEGFAULT issue #373 3a92bf7 -- src/tools/piv-tool.c -- confirmed by author 6759c04 -- src/pkcs15init/pkcs15-lib.c -- file instantiation error has to be ignored
@philipWendland thanks for analyse, I will revert or partially revert some of the recent commits |
I think this is it: slot.c |
Thanks, the issue is solved with 08eb700. |
Hello,
recently introduced, a segmentation fault in OpenSC when using PKCS#11 applications (in particular OpenSSL, others not tested).
I could trace it back to changes to the file pkcs11/slot.c in commit 3a92bf7. The free-ing of "p11card" causes the issue. But to me it is not exactly clear why. Removing the free(p11card) again solves the issue. Maybe someone with more insight can have a look at it.
The text was updated successfully, but these errors were encountered: