p11-glue / p11-kit

Provides a way to load and enumerate PKCS#11 modules.
https://p11-glue.github.io/p11-glue/p11-kit.html
Other
148 stars 88 forks source link

Firefox crashes when smart card is removed #293

Open ZeiP opened 4 years ago

ZeiP commented 4 years ago

I'm running Fedora 31. When I insert my Finnish Fineid smart card to the laptop's integrated smart card reader (Bus 001 Device 003: ID 058f:9540 Alcor Micro Corp. AU9540 Smartcard Reader) it usually works ok. However, when I remove the smart card from the slot, all the Firefox instances on my computer crash.

The crash report for a single Firefox instance crashing on smart card removal is available at https://crash-stats.mozilla.org/report/index/57f1e3a0-8f88-4a8a-b927-d5ed20200421 . When browsing through the crash report, I noticed that there's a similar bug report for Yubikey removal at https://bugzilla.mozilla.org/show_bug.cgi?id=1612098. The crash signature is a bit different, but the conditions seem quite similar and the actual failing component is apparently p11-kit in both cases.

Let me know if you need any additional information on the crash or if the root cause of the crash doesn't seem to be p11-kit.

ueno commented 4 years ago

As p11-kit-proxy.so (which is the component loaded by Firefox) merely aggregates the access to multiple smartcard drivers (PKCS#11 modules), the problem can be in the driver as well.

If would be nice if you could collect a meaningful backtrace by installing debuginfo packages (p11-kit and opensc).

ZeiP commented 4 years ago

I'm a bit inexperienced with desktop software development, but I installed the debuginfo packages for p11-kit, opensc and also firefox and got a gdb trace for a browser instance that crashes. Does this help or should I do something differently? gdb.txt

samsapti commented 2 years ago

@ueno @ZeiP

I can confirm that this is still an issue as of today (2021-09-27). For me, the problem occurs on Firefox 92.0 on Fedora 34 when using my YubiKey 5 series (with OpenPGP smartcard functionality). As soon as I insert my YubiKey, tabs start to act strangely, they just keep loading forever and some of them entirely stops loading and the reload button becomes greyed out. When I go into Settings > Privacy & Security > Security Devices and unload p11-kit-proxy, Firefox suddenly starts to work as normal (if it doesn't crash before then). If I unplug my YubiKey without having unloaded the module, Firefox crashes after some time.

This doesn't happen on other distros, such as Artix, where the module inside Firefox' Security Devices menu is called OpenSC instead of p11-kit-proxy.

samsapti commented 2 years ago

Here is a gdb trace for Firefox. Appearently, Firefox doesn't crash when I remove my YubiKey, but it acts as described above while it is plugged in. Some time after I unplug my YubiKey, it starts to act normally again.

I have marked some key events inside the file (at approximate locations).

firefox-gdb.log

jblz commented 1 year ago

Firefox is crashing for me as well when removing a Yubikey series 5 device -- it seems fine while inserted, however, and it works correctly for authentication purposes in Firefox and elsewhere.

As it's not using a mounted filesystem, I'm not given any interface to "eject" the device -- I'm just pulling it out of the slot.

I'm running Fedora 36. Happy to try and get more info if someone can point me in the right direction.