[SRU] gsd-smartcard: segfault on startup

Bug #2016914 reported by Chorca
30
This bug affects 5 people
Affects Status Importance Assigned to Milestone
GNOME Settings Daemon
Fix Released
Unknown
gnome-settings-daemon (Ubuntu)
Fix Released
High
Unassigned
Jammy
Won't Fix
High
Nathan Teodosio
Noble
Fix Committed
High
Nathan Teodosio
Oracular
Won't Fix
Undecided
Unassigned
Plucky
Fix Released
Undecided
Unassigned

Bug Description

Impact
------

A smartcard reader attached to the computer on startup, containing a non-standard smartcard (in this case an NXP AV3 SAM card) causes gsd-smartcard to segfault and restart 200 times after login.

Test plan
---------

0.1. apt install pcscd.
0.2. Log out.

Reproduce the issue:

1.1. Insert a non-standard smartcard into your computer (if it has a slot for it) or into a smart card reader attached to your computer.
1.2. Log in.
* Verify that a couple of automatic error reporter windows appear and the crash is of gsd_smartcard.

Verify the fix:

2.1. Enable proposed: https://wiki.ubuntu.com/Testing/EnableProposed.
2.2. apt install gnome-settings-daemon/noble-proposed.
2.3. Log out.
2.4. Insert a non-standard smartcard into your computer (if it has a slot for it) or into a smart card reader attached to your computer.
2.5. Log in.
* Verify that no more error reporter windows appear for gsd_smartcard crashes.

Where things could go wrong
---------------------------

As the code changes are restricted to the smart card module, which is packed in the gsd-smartcard binary, it is very unlikely to accept other parts of the daemon. So possible regressions are mainly during authentication phase in Gnome using a smart card.

More information
----------------

System Info:
This is Ubuntu 22.04.2 LTS at Kernel 5.19.0-38-generic
The Smart Card reader is an Identiv uTrust 4711 F with both SAM and Contactless slots
The system is an HP ZBook Firefly 14 G7

Detailed issue:
When the smartcard reader is plugged into the system, and an NXP SAM AV3 card is inserted into the physical smartcard slot, upon login several (5) Ubuntu Error report windows will open asking to report a crash. The reader lights will flicker for about 5 minutes until they finally stop. No other issues are seen with the system during this time.

Upon looking at /var/log/syslog, the errors listed in the attachment are visible as it appears gsd-smartcard is in a loop of restarting and crashing following an error.

/var/crash contains two files from the crash loop, _usr_libexec_gsd_smartcard.1000.crash and _usr_libexec_gsd_smartcard_127.crash

Eventually the crashes seem to stop and the light stops flickering, but a logout and log back in will restart the issue again, as will rebooting the machine. Re-plugging the device while logged in does not seem to cause it to start the crash loop again.

To complete the standard questions:
1. I logged into my computer and saw error messages
2. I expected the smart card to be ignored if there was a card inserted that was unexpected or incompatible with the gnome settings daemon
3. I encountered several crash reporter messages upon logging in, which seem to have come from the gsd-smartcard program

Revision history for this message
Chorca (chorca) wrote :
Revision history for this message
Chorca (chorca) wrote :

Have attempted to use apport to attach the crash dump but have so far been unsuccessful. It doesn't seem to upload anything.

Revision history for this message
Erich Eickmeyer (eeickmeyer) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. Unfortunately, we cannot work on this bug because your description didn't include enough information. You may find it helpful to read "How to report bugs effectively" http://www.chiark.greenend.org.uk/~sgtatham/bugs.html. We'd be grateful if you would then provide a more complete description of the problem.

We have instructions on debugging some types of problems at http://wiki.ubuntu.com/DebuggingProcedures.

At a minimum, we need:

1. The specific steps or actions you took that caused you to encounter the problem.
2. The behavior you expected.
3. The behavior you actually encountered (in as much detail as possible).

Please also ensure that you include the release and flavour of Ubuntu that you are using.

Thank you!

Changed in gnome-settings-daemon (Ubuntu):
status: New → Incomplete
Revision history for this message
Chorca (chorca) wrote :

Sure!

I've gone ahead and updated the description with a better description of the problem. I have the crashdump files as well, if those can be uploaded somewhere.

description: updated
Chorca (chorca)
Changed in gnome-settings-daemon (Ubuntu):
status: Incomplete → New
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gnome-settings-daemon (Ubuntu):
status: New → Confirmed
Revision history for this message
Sebastien Bacher (seb128) wrote :

It sounds like some part of the system has crashed. To help us find the cause of the crash please follow these steps:

1. Look in /var/crash for crash files and if found run:
    ubuntu-bug YOURFILE.crash
Then tell us the ID of the newly-created bug.

2. If step 1 failed then look at https://errors.ubuntu.com/user/ID where ID is the content of file /var/lib/whoopsie/whoopsie-id on the machine. Do you find any links to recent problems on that page? If so then please send the links to us.

Please take care to avoid attaching .crash files to bugs as we are unable to process them as file attachments. It would also be a security risk for yourself.

Changed in gnome-settings-daemon (Ubuntu):
importance: Undecided → High
status: Confirmed → Incomplete
Revision history for this message
Chorca (chorca) wrote :

I've been able to upload the crashfile using ubuntu-bug, but an ID was not created. I found the relevant error report here: https://errors.ubuntu.com/oops/5a0ff543-eea3-11ed-bb84-fa163ef35206

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for gnome-settings-daemon (Ubuntu) because there has been no activity for 60 days.]

Changed in gnome-settings-daemon (Ubuntu):
status: Incomplete → Expired
Revision history for this message
stsp (stsp-0) wrote :

Thread 1 "gsd-smartcard" received signal SIGSEGV, Segmentation fault.
0x000055555556237f in sync_initial_tokens_from_driver (
    cancellable=0x555555592e50, smartcards=0x5555555ab1f0,
    module=<optimized out>, self=0x555555578170)
    at ../plugins/smartcard/gsd-smartcard-manager.c:436
Downloading source file /usr/src/gnome-settings-daemon-44.0-1ubuntu1/obj-x86_64-linux-gnu/../plugins/smartcard/gsd-smartcard-manager.c
warning: Source file is more recent than executable.
436 g_debug ("Detected smartcard '%s' in slot %lu at start up",
(gdb)
(gdb) bt
#0 0x000055555556237f in sync_initial_tokens_from_driver
    (cancellable=0x555555592e50, smartcards=0x5555555ab1f0, module=<optimized out>, self=0x555555578170) at ../plugins/smartcard/gsd-smartcard-manager.c:436
#1 watch_smartcards_from_module_async
    (callback=0x55555555f9c0 <on_smartcards_from_module_watched>, user_data=0x0, cancellable=0x555555592e50, module=<optimized out>, self=0x555555578170)
    at ../plugins/smartcard/gsd-smartcard-manager.c:476
#2 on_modules_initialized
    (source_object=<optimized out>, result=<optimized out>, user_data=0x0)
    at ../plugins/smartcard/gsd-smartcard-manager.c:551
#3 0x00007ffff7e65613 in () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#4 0x00007ffff7e6564d in () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#5 0x00007ffff7c6c36f in g_main_dispatch (context=0x555555576fc0)
    at ../../../glib/gmain.c:3460
#6 g_main_context_dispatch (context=0x555555576fc0)
    at ../../../glib/gmain.c:4200
#7 0x00007ffff7cc7178 in g_main_context_iterate.constprop.0
    (context=0x555555576fc0, block=<optimized out>, dispatch=1, self=<optimized out>) at ../../../glib/gmain.c:4276
#8 0x00007ffff7c6bbdf in g_main_loop_run (loop=0x5555555771d0)
    at ../../../glib/gmain.c:4479
#9 0x000055555555bfa5 in main (argc=<optimized out>, argv=<optimized out>)
    at ../plugins/common/daemon-skeleton.h:256
(gdb) list
431
432 for (l = full_slots; l; l = l->next) {
433 GckSlot *slot = l->data;
434 GckTokenInfo *token_info = gck_slot_get_token_info (slot);
435
436 g_debug ("Detected smartcard '%s' in slot %lu at start up",
437 token_info->label, gck_slot_get_handle (slot));
438
439 g_hash_table_replace (smartcards, g_object_ref (slot), token_info);
440
(gdb) p token_info
$1 = (GckTokenInfo *) 0x0

Why gck_slot_get_token_info() returns NULL
is what I don't know. Have that problem with
etoken.

Revision history for this message
Timothée COCAULT (tcocault) wrote :

Hi.

I happen to also be affected by this bug and managed to narrow it down.

I guess the problem lies in the function sync_initial_tokens_from_driver (https://gitlab.gnome.org/GNOME/gnome-settings-daemon/-/blob/master/plugins/smartcard/gsd-smartcard-manager.c#L461).
The code assumes that gck_slot_get_token_info won't return NULL.

However looking in gck, it does return NULL if C_GetTokenInfo returns an error (https://gitlab.gnome.org/GNOME/gcr/-/blob/master/gck/gck-slot.c#L688).

And this is precisely the behavior of opensc-pkcs11.so when it sees an unrecognized token. It returns the token in C_GetSlotList (as present), but returns an error when calling C_GetTokenInfo.

So if you login as a user with your USB token plugged in, gsd-smartcard will crash in a loop.

Changed in gnome-settings-daemon (Ubuntu):
status: Expired → Incomplete
Revision history for this message
Sebastien Bacher (seb128) wrote :

@Timothée, thanks for the debugging work, could you report your finding upstream in a gitlab ticket (or perhaps submit a fix there since you understand the problem)?

Changed in gnome-settings-daemon (Ubuntu):
status: Incomplete → Triaged
Revision history for this message
Timothée COCAULT (tcocault) wrote :

I had trouble creating an account on the gnome bugtracker, but it seems to work now.
I filled the following issue upstream: https://gitlab.gnome.org/GNOME/gnome-settings-daemon/-/issues/795

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks!

Changed in gnome-settings-daemon:
status: Unknown → New
Changed in gnome-settings-daemon:
status: New → Fix Released
Revision history for this message
Sebastien Bacher (seb128) wrote :
Changed in gnome-settings-daemon (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Sebastien Bacher (seb128) wrote :

The fix is included in 48/Plucky.

The corresponding error tracker report is https://errors.ubuntu.com/problem/9ce317314fbb071c4ae1c73065ebe18d091bc79f which shows 15k reports on Noble, it's probably worth SRUing

Changed in gnome-settings-daemon (Ubuntu):
status: Fix Committed → Fix Released
tags: added: udeng-6810
Changed in gnome-settings-daemon (Ubuntu Plucky):
status: New → Fix Released
Changed in gnome-settings-daemon (Ubuntu Oracular):
status: New → Won't Fix
Changed in gnome-settings-daemon (Ubuntu Noble):
assignee: nobody → Nathan Teodosio (nteodosio)
Changed in gnome-settings-daemon (Ubuntu Jammy):
assignee: nobody → Nathan Teodosio (nteodosio)
importance: Undecided → High
Changed in gnome-settings-daemon (Ubuntu Noble):
importance: Undecided → High
summary: - gsd-smartcard: segfault on startup
+ [SRU] gsd-smartcard: segfault on startup
Revision history for this message
Nathan Teodosio (nteodosio) wrote :

For 24.04 I'm uploading the patched package to this PPA: https://launchpad.net/~nteodosio/+archive/ubuntu/fixes.

For 22.04 the code diverges too much so it will take more time or maybe even be let be.

description: updated
Revision history for this message
Nathan Teodosio (nteodosio) wrote :

SRU reviewers: Due to the hardware-specific nature of the bug, no peer in the desktop team could verify this fix. #16 has the fix in the PPA but since it's been a while and the PPA package wasn't tried yet, I'm uploading to 24.04 for your review.

Changed in gnome-settings-daemon (Ubuntu Jammy):
status: New → Won't Fix
Jeremy Bícha (jbicha)
Changed in gnome-settings-daemon (Ubuntu Noble):
status: New → Triaged
Revision history for this message
Karl Grindley (karlg100) wrote :

note, redhat just released a backport for gsd-smartcard for older versions of gnome. may want to take a look at their patch and see if it's something we can use here.

Revision history for this message
Karl Grindley (karlg100) wrote :

note we see this issue with 22.04 and seeking a fix.

Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Chorca, or anyone else affected,

Accepted gnome-settings-daemon into noble-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/gnome-settings-daemon/46.0-1ubuntu1.24.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-noble to verification-done-noble. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-noble. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in gnome-settings-daemon (Ubuntu Noble):
status: Triaged → Fix Committed
tags: added: verification-needed verification-needed-noble
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.