After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 668950 - gnome-settings-daemon segfaults from smartcard plugin
gnome-settings-daemon segfaults from smartcard plugin
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: smartcard
3.2.x
Other Linux
: High critical
: ---
Assigned To: Ray Strode [halfline]
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2012-01-29 12:14 UTC by James
Modified: 2012-07-31 16:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (1.69 KB, patch)
2012-07-31 15:57 UTC, Michael Terry
accepted-commit_now Details | Review

Description James 2012-01-29 12:14:59 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;

Thread 3018234688 (LWP 14266)

  • #0 SECMOD_WaitForAnyTokenEvent
    from /usr/lib/libnss3.so
  • #1 gsd_smartcard_manager_worker_watch_for_and_process_event
    at gsd-smartcard-manager.c line 1256
  • #2 gsd_smartcard_manager_worker_run
    at gsd-smartcard-manager.c line 1386
  • #3 ??
    from /usr/lib/libglib-2.0.so.0
  • #4 start_thread
    from /lib/libpthread.so.0
  • #5 clone
    from /lib/libc.so.6

Comment 1 Bastien Nocera 2012-05-28 08:54:07 UTC
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)
Comment 2 Michael Terry 2012-07-31 15:52:25 UTC
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.
Comment 3 Michael Terry 2012-07-31 15:57:32 UTC
Created attachment 219996 [details] [review]
Proposed patch
Comment 4 Ray Strode [halfline] 2012-07-31 16:00:02 UTC
Review of attachment 219996 [details] [review]:

looks right, thanks for the patch.
Comment 5 Michael Terry 2012-07-31 16:01:40 UTC
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