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
Improved Handling of CK_SLOT_ID values returned to C_GetSlotList #1947
Conversation
Previously the CK_SLOT_IDs where derived from the place on the virtual_slot list. This means that if a reader was removed, the position on the list could change. An application such as Firefox is also keeping track of data based on the previous slot list. So the application could get confused. PKCS11 v2.30 code in in OpenSC to keep deleted slots on the list until the application has see the slot once since itmiht have been deleted. But the slot also looked like an available hotplug which might g reused before the application ha seen it. This was fixed so it could not be reused until the application had a chance to see it. The CK_SLOT_ID now starts at 0, and increased by 1 each time a new slot is created which occues when a reader is inserted. There is an upper limit of 2^32 calls to create_slot. In practics this will never be reached but the code has a "TODO" to add code to reuse slot IDs. Pkcs11-tool.c has improved wording for listing slots. On branch PKCS11-SLOTS Changes to be committed: modified: pkcs11-global.c modified: sc-pkcs11.h modified: slot.c modified: ../tools/pkcs11-tool.c
|
|
I am still looking at this. I was able to get Firefox to not go into an infinite loop. It took a second cancel of the password prompt to end firefox. That was why I said partial fix. The slot id needs to be persistent. You can play around with current I expect Firefox will not do anything for a while. and only handle added devices. |
|
Using single card and OpenSC 0.17.0 (default in my Ubuntu system) and current master both show: But with 0.17.0 if I remove reader with card still in reader and hit enter it shows: But Current master if I remove reader with card and hot enter it shows: With 0.17.0 and firefox, C_GetSlotList would show one slot, but as a hot plug slot. Firefox may fail in different ways in both cases when the card is removed. One causes a loop, the other does not. |
|
I didn't find a reason why a virtual slot would make sense for itself (hotplugging is implemented by adding slots at runtime). We introduced a possible shrinking of the slot list in 7fb72cc, which also eliminates the virtual slot as placeholder for slots that the application has seen, but which aren't valid anymore (as seen in 0.17.0). My reading is that this is perfectly valid in terms of PKCS#11 and for users/applications it makes sense to remove this clutter. If we don't find a proper workaround for all the related problems in Firefox, a partial fix doesn't make sense. Mozilla will have to change its code anyway, so why not implement the proper fixes in Firefox? |
|
Yes I would like to hear from them.
…On Wed, Feb 19, 2020, 3:33 PM Frank Morgner ***@***.***> wrote:
I didn't find a reason why a virtual slot would make sense for itself
(hotplugging is implemented by adding slots at runtime). We introduced a
possible shrinking of the slot list in 7fb72cc
<7fb72cc>,
which also eliminates the virtual slot as placeholder for slots that the
application has seen, but which aren't valid anymore (as seen in 0.17.0).
My reading is that this is perfectly valid in terms of PKCS#11 and for
users/applications it makes sense to remove this clutter.
If we don't find a proper workaround for all the related problems in
Firefox, a partial fix doesn't make sense. Mozilla will have to change its
code anyway, so why not implement the proper fix*es* in Firefox?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1947?email_source=notifications&email_token=AAGTIMKEHKJNNLN3TGJKLT3RDWQUDA5CNFSM4KVPCBD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMJYPVQ#issuecomment-588482518>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGTIMIMUZP4R3EUCQJV6EDRDWQUDANCNFSM4KVPCBDQ>
.
|
|
OpenSSH mail list has related issue. from 2/21/2020, |
|
Many of the comments in this PR may be helpful, but the PR itself is not the complete answer. |
Partially Fixes #1945
Partially Fixes #1935
Firefox 72.0.2 still does not handle deleting of slots. See https://bugzilla.mozilla.org/show_bug.cgi?id=1613632
Previously the CK_SLOT_IDs where derived from the place on the
virtual_slot list. This means that if a reader was removed, the position
on the list could change. An application such as Firefox is also keeping
track of data based on the previous slot list. So the application
could get confused.
PKCS11 v2.30 code in in OpenSC to keep deleted slots on the list until the
application has see the slot once since itmiht have been deleted. But the
slot also looked like an available hotplug which might g reused before
the application ha seen it. This was fixed so it could not be reused until
the application had a chance to see it.
The CK_SLOT_ID now starts at 0, and increased by 1 each time a new slot
is created which occues when a reader is inserted. There is an upper limit
of 2^32 calls to create_slot. In practics this will never be reached but
the code has a "TODO" to add code to reuse slot IDs.
Pkcs11-tool.c has improved wording for listing slots.
On branch PKCS11-SLOTS
Changes to be committed:
modified: pkcs11-global.c
modified: sc-pkcs11.h
modified: slot.c
modified: ../tools/pkcs11-tool.c
Checklist