GNOME Bugzilla – Bug 668950
gnome-settings-daemon segfaults from smartcard plugin
Last modified: 2012-07-31 16:01:40 UTC
When logging in using a smartcard, the login itself is fine and works (opensc and pam_pkcs11), but there is a smartcard plugin enabled by default in gnome-settings-daemon, if it's not disabled, then logging in using a smartcard freezes for about 30 seconds and then continues to a very basic looking desktop (default colours, etc.). Running gnome-settings-daemon manually from the commandline shows that it segfaults at SECMOD_WaitForAnyTokenEvent() from libnss3. I originally filed this report on the arch linux bug forum as can be seen here: https://bugs.archlinux.org/task/27920 Details from kern.log: Jan 12 22:57:33 localhost kernel: [ 2502.245260] gnome-settings-[19105]: segfault at 110 ip b3995e5f sp b377e120 error 4 in libnss3.so[b3940000+13c000] Jan 12 22:57:40 localhost kernel: [ 2509.515277] gnome-settings-[19111]: segfault at 110 ip b391de5f sp b370b120 error 4 in libnss3.so[b38c8000+13c000] gnome-settings-daemon --debug output: (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: GsdSmartcardPlugin initializing (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: initializing smartcard manager (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: GsdSmartcardPlugin Activating smartcard plugin (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: attempting to load NSS database '/etc/pki/nssdb' (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: NSS database sucessfully loaded (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: attempting to load driver... (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: Getting list of suitable modules (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: loading smartcard driver using spec 'library="/usr/lib/pkcs11/libcoolkeypk11.so"' (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: smartcard manager started (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: GsdSmartcardPlugin processing smartcard removal immediately user logged in with smartcard and it's not inserted (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: GsdSmartcardPlugin processing smartcard removal ** (gnome-settings-daemon:19106): DEBUG: GnomeSettingsManager: emitting plugin-activated smartcard ** (gnome-settings-daemon:19106): DEBUG: Plugin smartcard: active ** (gnome-settings-daemon:19106): DEBUG: GnomeSettingsModule 0x87db340 initialising ** (gnome-settings-daemon:19106): DEBUG: Loading /usr/lib/gnome-settings-daemon-3.0/libkeybindings.so ** (gnome-settings-daemon:19106): DEBUG: Creating object of type GsdKeybindingsPlugin (gnome-settings-daemon:19106): keybindings-plugin-DEBUG: GsdKeybindingsPlugin initializing (gnome-settings-daemon:19106): keybindings-plugin-DEBUG: Activating keybindings plugin (gnome-settings-daemon:19106): keybindings-plugin-DEBUG: Starting keybindings manager (gnome-settings-daemon:19106): smartcard-plugin-DEBUG: waiting for card event Segmentation fault GDB log;
+ Trace 229553
Thread 3018234688 (LWP 14266)
Thanks for taking the time to report this bug. Unfortunately, that stack trace is missing some elements that will help a lot to solve the problem, so it will be hard for the developers to fix that crash. Can you get us a stack trace with debugging symbols? Please see http://live.gnome.org/GettingTraces for more information on how to do so and reopen this bug or report a new one. Thanks in advance! (Missing NSS symbols)
We see this in Ubuntu too. It will crash if you logged in via smartcard but do not have coolkey installed. https://bugs.launchpad.net/ubuntu/+source/gnome-settings-daemon/+bug/1031034 I'll add a better trace in a sec. In looking at this, I think I see why there's a problem. In load_driver(), SECMOD_LoadUserModule() is called. If the module file doesn't exist, this will return a module object with a false module->loaded value. But the code in load_driver() does the following check: if (!SECMOD_HasRemovableSlots (module) || !module->loaded) { modules = g_list_prepend (modules, module); } else { g_debug ("fallback module found but not %s", SECMOD_HasRemovableSlots (module)? "removable" : "loaded"); SECMOD_DestroyModule (module); } Which seems backward. I would expect "if (SECMOD_HasRemovableSlots (module) && module->loaded)" especially based on the wording of the debug statement. And in fact earlier in that file in get_available_modules(), the following logic is used to skip bad modules: if (!SECMOD_HasRemovableSlots (tmp->module) || !tmp->module->loaded) continue; So I think this was an example of bad copy and pasting perhaps. An unloaded module gets added to the module list and ends up causing a crash. There are two instances of this logic in load_driver() that should be fixed.
Created attachment 219996 [details] [review] Proposed patch
Review of attachment 219996 [details] [review]: looks right, thanks for the patch.
commit fdfd97cd737257532c8797e2a551a10f5c74cf05 Author: Michael Terry <michael.terry@canonical.com> Date: Tue Jul 31 11:54:51 2012 -0400 [smartcard] Don't try to use smartcard drivers that didn't load https://bugzilla.gnome.org/show_bug.cgi?id=668950