OpenSC segfaulting Firefox 1.0.6

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenSC segfaulting Firefox 1.0.6

Markus Lervik
Hello!

First off, I'm terribly sorry for the long e-mail.

I seem to be having quite a lot of problems with OpenSC. I grabbed the latest
version (rev 2512) from the subversion server, and also the latest version (rev 1624)
of PCSC-Lite. I have an SCM SCR531 smart card reader and a brand-spanking new
FinEID card (issued after June 10th, 2005, so it's one of those "new models", apparently
FINEID S4-1 v. 2.1A from what I can gather off www.fineid.fi).

It doesn't seem to be properly identified, and the ATR isn't listed in the file card-setcos.c

mle@linux:~> opensc-tool -na
3b:7b:94:00:00:80:62:11:51:56:46:69:6e:45:49:44
Unidentified card

pkcs15-tool seems to semi-work, it appears to read stuff from the card,
except it (and pkcs11-tool) complains about invalid ASN.1 type: 19.

mle@linux:~> pkcs15-tool -c
asn1.c:1017:asn1_decode_entry: invalid ASN.1 type: 19
asn1.c:1022:asn1_decode_entry: decoding of ASN.1 object 'TokenInfo' failed: Invalid ASN.1 object
pkcs15.c:88:parse_tokeninfo: ASN.1 parsing of EF(TokenInfo) failed: Invalid ASN.1 object
X.509 Certificate [todentamis- ja salausvarmenne]
        Flags    : 0
        Authority: no
        Path     : 3F004331
        ID       : 45

X.509 Certificate [allekirjoitusvarmenne]
        Flags    : 0
        Authority: no
        Path     : 3F0050164332
        ID       : 46

X.509 Certificate [VRK Gov. Root CA]
        Flags    : 0
        Authority: yes
        Path     : 3F004334
        ID       : 48

X.509 Certificate [VRK Gov. CA for Citizen Qualified Certificates]
        Flags    : 0
        Authority: yes
        Path     : 3F004333
        ID       : 47

pkcs11-tool --login --test works fine, doesn't report any errors (except for the ASN.1)

mle@linux:~> pkcs11-tool -I
asn1.c:1017:asn1_decode_entry: invalid ASN.1 type: 19
asn1.c:1022:asn1_decode_entry: decoding of ASN.1 object 'TokenInfo' failed: Invalid ASN.1 object
pkcs15.c:88:parse_tokeninfo: ASN.1 parsing of EF(TokenInfo) failed: Invalid ASN.1 object
Cryptoki version 2.11
Manufacturer     OpenSC Project (www.opensc.org)
Library          smart card PKCS#11 API (ver 1.0)


Now, I tried to use Firefox 1.0.6 and clicked  
Edit=>Preferences=>Advanced=>Manage Security Devices and tried to load opensc-pkcs11.so.
Clicking Ok caused an instant segfault.

So I decided to try pkcs11-spy, which gave me

mle@linux:~> firefox
*************** OpenSC PKCS#11 spy *****************
Loaded: "default module"

0: C_GetFunctionList
Returned:  0 CKR_OK

1: C_Initialize
Returned:  0 CKR_OK

2: C_GetInfo
      cryptokiVersion:         2.11
      manufacturerID:         'OpenSC Project (www.opensc.org) '
      flags:                   0
      libraryDescription:     'SmartCard PKCS#11 API           '
      libraryVersion:          1.0
Returned:  0 CKR_OK

3: C_GetSlotList
[in] tokenPresent = 0x0
[out] pSlotList:
Count is 8
[out] *pulCount = 0x8
Returned:  0 CKR_OK

4: C_GetSlotList
[in] tokenPresent = 0x0
[out] pSlotList:
Slot 0
Slot 1
Slot 2
Slot 3
Slot 4
Slot 5
Slot 6
Slot 7
[out] *pulCount = 0x8
Returned:  0 CKR_OK

5: C_GetSlotInfo
[in] slotID = 0x0
/usr/bin/firefox: line 259: 10285 Segmentation fault      $MOZ_PROGRAM $MOZ_LANG

Peeking with gdb:

mle@linux:~> LD_LIBRARY_PATH=/opt/MozillaFirefox/lib gdb /opt/MozillaFirefox/lib/firefox-bin
[snip]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1086286048 (LWP 10311)]
0x416cfdfe in card_detect (reader=0) at slot.c:88
88                      strcpy_bp(slot->slot_info.slotDescription,
(gdb) bt
#0  0x416cfdfe in card_detect (reader=0) at slot.c:88
#1  0x416ccaa9 in C_GetSlotInfo (slotID=0, pInfo=0xbfff6350) at pkcs11-global.c:209
#2  0x407d4202 in PK11_InitSlot () from /opt/MozillaFirefox/lib/libnss3.so
#3  0x407ce23d in SECMOD_LoadPKCS11Module () from /opt/MozillaFirefox/lib/libnss3.so
#4  0x407ddc8a in SECMOD_AddModule () from /opt/MozillaFirefox/lib/libnss3.so
#5  0x407ddd18 in SECMOD_AddNewModuleEx () from /opt/MozillaFirefox/lib/libnss3.so
#6  0x407dddf8 in SECMOD_AddNewModule () from /opt/MozillaFirefox/lib/libnss3.so
#7  0x088f53fe in nsPkcs11::Addmodule ()
[snip]
(gdb) list slot.c:88
83              sc_debug(context, "%d: Detecting SmartCard\n", reader);
84              for (i = card->max_slots; i--; ) {
85                      struct sc_pkcs11_slot *slot;
86
87                      slot = virtual_slots + card->first_slot + i;
88                      strcpy_bp(slot->slot_info.slotDescription,
89                                      context->reader[reader]->name, 64);
90                      slot->reader = reader;
91              }
92
(gdb) print slot->slot_info.slotDescription
$1 = "Virtual slot", ' ' <repeats 52 times>
(gdb) print context->reader[reader]->name
Cannot access memory at address 0x10
(gdb) print context->reader
$2 = {0x0, 0x0, 0x0, 0x90af5e0, 0x0 <repeats 12 times>}
(gdb) print reader
$3 = 0
(gdb) print context->reader[0]
$4 = (struct sc_reader *) 0x0
(gdb) print *context->reader[0]
Cannot access memory at address 0x0

Is this problem due to the fact that my FinEID card doesn't seem to be
properly detected? I'm not quite sure as to how I'd go about to solve this
problem, as I have limited knowledge in C. I hope someone has some ideas
as to what I'm doing wrong and/or know how to fix this in case it's a bug :)


Regards,
Markus

--
Markus Lervik
Chief Technology Officer
[hidden email]
http://www.necora.fi
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: OpenSC segfaulting Firefox 1.0.6

Nils Larsch
Markus Lervik wrote:

> Hello!
>
> First off, I'm terribly sorry for the long e-mail.
>
> I seem to be having quite a lot of problems with OpenSC. I grabbed the latest
> version (rev 2512) from the subversion server, and also the latest version (rev 1624)
> of PCSC-Lite. I have an SCM SCR531 smart card reader and a brand-spanking new
> FinEID card (issued after June 10th, 2005, so it's one of those "new models", apparently
> FINEID S4-1 v. 2.1A from what I can gather off www.fineid.fi).
>
> It doesn't seem to be properly identified, and the ATR isn't listed in the file card-setcos.c

this should be a minor problem, just add a
  { "3b:7b:94:00:00:80:62:11:51:56:46:69:6e:45:49:44", NULL,
    SC_CARD_TYPE_SETCOS_FINEID_V2, 0 }
entry to the atr table in card-setcos.c

>
> mle@linux:~> opensc-tool -na
> 3b:7b:94:00:00:80:62:11:51:56:46:69:6e:45:49:44
> Unidentified card
>
> pkcs15-tool seems to semi-work, it appears to read stuff from the card,
> except it (and pkcs11-tool) complains about invalid ASN.1 type: 19.

could you send us the debug log (just set the debug level in the
opensc.conf to 6 and let opensc dump the log to a file) ? I would
like know where exactly this asn.1 error occurs.

...

> pkcs11-tool --login --test works fine, doesn't report any errors (except for the ASN.1)
>
> mle@linux:~> pkcs11-tool -I
> asn1.c:1017:asn1_decode_entry: invalid ASN.1 type: 19
> asn1.c:1022:asn1_decode_entry: decoding of ASN.1 object 'TokenInfo' failed: Invalid ASN.1 object
> pkcs15.c:88:parse_tokeninfo: ASN.1 parsing of EF(TokenInfo) failed: Invalid ASN.1 object
> Cryptoki version 2.11
> Manufacturer     OpenSC Project (www.opensc.org)
> Library          smart card PKCS#11 API (ver 1.0)
>
>
> Now, I tried to use Firefox 1.0.6 and clicked  
> Edit=>Preferences=>Advanced=>Manage Security Devices and tried to load opensc-pkcs11.so.
> Clicking Ok caused an instant segfault.
>
> So I decided to try pkcs11-spy, which gave me
>
> mle@linux:~> firefox
> *************** OpenSC PKCS#11 spy *****************
> Loaded: "default module"
>
> 0: C_GetFunctionList
> Returned:  0 CKR_OK
>
> 1: C_Initialize
> Returned:  0 CKR_OK
>
> 2: C_GetInfo
>       cryptokiVersion:         2.11
>       manufacturerID:         'OpenSC Project (www.opensc.org) '
>       flags:                   0
>       libraryDescription:     'SmartCard PKCS#11 API           '
>       libraryVersion:          1.0
> Returned:  0 CKR_OK
>
> 3: C_GetSlotList
> [in] tokenPresent = 0x0
> [out] pSlotList:
> Count is 8
> [out] *pulCount = 0x8
> Returned:  0 CKR_OK
>
> 4: C_GetSlotList
> [in] tokenPresent = 0x0
> [out] pSlotList:
> Slot 0
> Slot 1
> Slot 2
> Slot 3
> Slot 4
> Slot 5
> Slot 6
> Slot 7
> [out] *pulCount = 0x8
> Returned:  0 CKR_OK
>
> 5: C_GetSlotInfo
> [in] slotID = 0x0
> /usr/bin/firefox: line 259: 10285 Segmentation fault      $MOZ_PROGRAM $MOZ_LANG
>
> Peeking with gdb:
>
> mle@linux:~> LD_LIBRARY_PATH=/opt/MozillaFirefox/lib gdb /opt/MozillaFirefox/lib/firefox-bin
> [snip]
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1086286048 (LWP 10311)]
> 0x416cfdfe in card_detect (reader=0) at slot.c:88
> 88                      strcpy_bp(slot->slot_info.slotDescription,
> (gdb) bt
> #0  0x416cfdfe in card_detect (reader=0) at slot.c:88
> #1  0x416ccaa9 in C_GetSlotInfo (slotID=0, pInfo=0xbfff6350) at pkcs11-global.c:209
> #2  0x407d4202 in PK11_InitSlot () from /opt/MozillaFirefox/lib/libnss3.so
> #3  0x407ce23d in SECMOD_LoadPKCS11Module () from /opt/MozillaFirefox/lib/libnss3.so
> #4  0x407ddc8a in SECMOD_AddModule () from /opt/MozillaFirefox/lib/libnss3.so
> #5  0x407ddd18 in SECMOD_AddNewModuleEx () from /opt/MozillaFirefox/lib/libnss3.so
> #6  0x407dddf8 in SECMOD_AddNewModule () from /opt/MozillaFirefox/lib/libnss3.so
> #7  0x088f53fe in nsPkcs11::Addmodule ()
> [snip]
> (gdb) list slot.c:88
> 83              sc_debug(context, "%d: Detecting SmartCard\n", reader);
> 84              for (i = card->max_slots; i--; ) {
> 85                      struct sc_pkcs11_slot *slot;
> 86
> 87                      slot = virtual_slots + card->first_slot + i;
> 88                      strcpy_bp(slot->slot_info.slotDescription,
> 89                                      context->reader[reader]->name, 64);
> 90                      slot->reader = reader;
> 91              }
> 92
> (gdb) print slot->slot_info.slotDescription
> $1 = "Virtual slot", ' ' <repeats 52 times>
> (gdb) print context->reader[reader]->name
> Cannot access memory at address 0x10
> (gdb) print context->reader
> $2 = {0x0, 0x0, 0x0, 0x90af5e0, 0x0 <repeats 12 times>}
> (gdb) print reader
> $3 = 0
> (gdb) print context->reader[0]
> $4 = (struct sc_reader *) 0x0
> (gdb) print *context->reader[0]
> Cannot access memory at address 0x0
>
> Is this problem due to the fact that my FinEID card doesn't seem to be
> properly detected?

this is no reason for a segfault ... need to look at it.

Nils
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: OpenSC segfaulting Firefox 1.0.6

Ludovic Rousseau
Hello,

On 23/08/05, Nils Larsch <[hidden email]> wrote:

> Markus Lervik wrote:
> > I seem to be having quite a lot of problems with OpenSC. I grabbed the latest
> > version (rev 2512) from the subversion server, and also the latest version (rev 1624)
> > of PCSC-Lite. I have an SCM SCR531 smart card reader and a brand-spanking new
> > FinEID card (issued after June 10th, 2005, so it's one of those "new models", apparently
> > FINEID S4-1 v. 2.1A from what I can gather off www.fineid.fi).
> >
> > It doesn't seem to be properly identified, and the ATR isn't listed in the file card-setcos.c
>
> this should be a minor problem, just add a
>   { "3b:7b:94:00:00:80:62:11:51:56:46:69:6e:45:49:44", NULL,
>     SC_CARD_TYPE_SETCOS_FINEID_V2, 0 }
> entry to the atr table in card-setcos.c

The solution is minor but the problem is not, it is an application crash :-(
Would it be possible that the lib returns an error code instead of crashing?

Bye,

--
 Dr. Ludovic Rousseau
 For private mail use [hidden email] and not "big brother" Google
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: OpenSC segfaulting Firefox 1.0.6

Nils Larsch
Ludovic Rousseau wrote:

> Hello,
>
> On 23/08/05, Nils Larsch <[hidden email]> wrote:
>
>>Markus Lervik wrote:
>>
>>>I seem to be having quite a lot of problems with OpenSC. I grabbed the latest
>>>version (rev 2512) from the subversion server, and also the latest version (rev 1624)
>>>of PCSC-Lite. I have an SCM SCR531 smart card reader and a brand-spanking new
>>>FinEID card (issued after June 10th, 2005, so it's one of those "new models", apparently
>>>FINEID S4-1 v. 2.1A from what I can gather off www.fineid.fi).
>>>
>>>It doesn't seem to be properly identified, and the ATR isn't listed in the file card-setcos.c
>>
>>this should be a minor problem, just add a
>>  { "3b:7b:94:00:00:80:62:11:51:56:46:69:6e:45:49:44", NULL,
>>    SC_CARD_TYPE_SETCOS_FINEID_V2, 0 }
>>entry to the atr table in card-setcos.c
>
>
> The solution is minor but the problem is not, it is an application crash :-(
> Would it be possible that the lib returns an error code instead of crashing?

I was talking about the wrong class problem and the card detection
and _not_ about the segfault (actually I didn't had the time so far
to find out why it crashes).

Nils
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel