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

opensc-pkcs11 driver crashes with cardos 5.0 card #547

Closed
bigon opened this issue Sep 9, 2015 · 5 comments · Fixed by #549
Closed

opensc-pkcs11 driver crashes with cardos 5.0 card #547

bigon opened this issue Sep 9, 2015 · 5 comments · Fixed by #549

Comments

@bigon
Copy link
Contributor

bigon commented Sep 9, 2015

Hello,

When running pkcs11-tool -I with a cardos 5 card connected to it, the driver is crashing. This is annoying as it make firefox crashes when the opensc-pkcs11 driver is loaded in it.

When compiling the git HEAD and running it in gdb, I'm getting the following backtrace:

#0  __strstr_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S:40
#1  0x00007ffff7aeb873 in fix_starcos_pkcs15_card (p15card=0x62afe0, p15card=0x62afe0) at pkcs15.c:427
#2  sc_pkcs15_bind (card=0x62a720, aid=aid@entry=0x0, p15card_out=0x62ad80) at pkcs15.c:1246
#3  0x00007ffff6ebe93e in pkcs15_bind (p11card=0x629340, app_info=<optimized out>) at framework-pkcs15.c:279
#4  0x00007ffff6ebb15f in card_detect (reader=reader@entry=0x629960) at slot.c:281
#5  0x00007ffff6ebb393 in initialize_reader (reader=0x629960) at slot.c:144
#6  0x00007ffff6ebb608 in card_detect_all () at slot.c:347
#7  0x00007ffff6eb64e5 in C_GetSlotList (tokenPresent=0 '\000', pSlotList=0x0, pulCount=0x615f88 <p11_num_slots>) at pkcs11-global.c:392
#8  0x0000000000407738 in list_slots (tokens=tokens@entry=0, print=print@entry=0, refresh=1) at pkcs11-tool.c:970
#9  0x0000000000401b3b in main (argc=2, argv=<optimized out>) at pkcs11-tool.c:730
@dengert
Copy link
Member

dengert commented Sep 9, 2015

looks like at pkcs15.c: line 427 strstr(p15card->tokeninfo->label,"D-TRUST")
is failing. It could be p15card->tokeninfo is NULL or not initialized,
or p15card->tokeninfo->label is NULL or not initialized.
Can you do some more tracing to see if these are valid?

The routine should check that the label is not NULL.

If the card has not been initialized or for some other reason the label may never have set label.

I am also surprised that a card specific routine is called from pkcs15.c
and the test is based on the short_name of the driver.

On 9/9/2015 9:20 AM, Laurent Bigonville wrote:

Hello,

When running pkcs11-tool -I with a cardos 5 card connected to it, the driver is crashing. This is annoying as it make firefox crashes when the opensc-pkcs11 driver is loaded in it.

When compiling the git HEAD and running it in gdb, I'm getting the following backtrace:

|#0 __strstr_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S:40 #1 0x00007ffff7aeb873 in fix_starcos_pkcs15_card (p15card=0x62afe0, p15card=0x62afe0) at pkcs15.c:427 #2
sc_pkcs15_bind (card=0x62a720, aid=aid@entry=0x0, p15card_out=0x62ad80) at pkcs15.c:1246 #3 0x00007ffff6ebe93e in pkcs15_bind (p11card=0x629340, app_info=) at framework-pkcs15.c:279 #4
0x00007ffff6ebb15f in card_detect (reader=reader@entry=0x629960) at slot.c:281 #5 0x00007ffff6ebb393 in initialize_reader (reader=0x629960) at slot.c:144 #6 0x00007ffff6ebb608 in card_detect_all () at
slot.c:347 #7 0x00007ffff6eb64e5 in C_GetSlotList (tokenPresent=0 '\000', pSlotList=0x0, pulCount=0x615f88 <p11_num_slots>) at pkcs11-global.c:392 #8 0x0000000000407738 in list_slots
(tokens=tokens@entry=0, print=print@entry=0, refresh=1) at pkcs11-tool.c:970 #9 0x0000000000401b3b in main (argc=2, argv=) at pkcs11-tool.c:730 |


Reply to this email directly or view it on GitHub #547.

Douglas E. Engert [email protected]

@frankmorgner
Copy link
Member

why the heck is fix_starcos_pkcs15_card even in pkcs15.c???

frankmorgner pushed a commit to frankmorgner/OpenSC that referenced this issue Sep 10, 2015
@frankmorgner
Copy link
Member

@bigon could you check wether #549 fixes your problem?

@bigon
Copy link
Contributor Author

bigon commented Sep 11, 2015

Looks like the p15card->tokeninfo is not initialized at all:

(gdb) p *p15card->tokeninfo
$2 = {version = 0, flags = 0, label = 0x0, serial_number = 0x0, manufacturer_id = 0x0, last_update = {gtime = 0x0, path = {value = '\000' <repeats 15 times>, len = 0, index = 0, count = 0, type = 0, aid = {
        value = '\000' <repeats 15 times>, len = 0}}}, profile_indication = {oid = {value = {-1 <repeats 16 times>}}, name = 0x0}, preferred_language = 0x0, seInfo = 0x0, num_seInfo = 0, supported_algos = {{
      reference = 0, mechanism = 0, operations = 0, algo_id = {value = {0 <repeats 16 times>}}, algo_ref = 0}, {reference = 0, mechanism = 0, operations = 0, algo_id = {value = {0 <repeats 16 times>}}, 
      algo_ref = 0}, {reference = 0, mechanism = 0, operations = 0, algo_id = {value = {0 <repeats 16 times>}}, algo_ref = 0}, {reference = 0, mechanism = 0, operations = 0, algo_id = {value = {
          0 <repeats 16 times>}}, algo_ref = 0}, {reference = 0, mechanism = 0, operations = 0, algo_id = {value = {0 <repeats 16 times>}}, algo_ref = 0}, {reference = 0, mechanism = 0, operations = 0, 
      algo_id = {value = {0 <repeats 16 times>}}, algo_ref = 0}, {reference = 0, mechanism = 0, operations = 0, algo_id = {value = {0 <repeats 16 times>}}, algo_ref = 0}, {reference = 0, mechanism = 0, 
      operations = 0, algo_id = {value = {0 <repeats 16 times>}}, algo_ref = 0}}}

With the patch from PR #549, it's not crashing anymore

@frankmorgner
Copy link
Member

maybe the TokenInfo file is missing on your card. I'll merge the fix.

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 a pull request may close this issue.

3 participants