Blame SOURCES/0001-smartcard-Cancel-cancellable-when-stopping.patch

1ff027
From a1c2685bc6b255f22b6ce4645c001d428cb67907 Mon Sep 17 00:00:00 2001
1ff027
From: Marek Kasik <mkasik@redhat.com>
1ff027
Date: Wed, 22 May 2019 14:56:42 +0200
1ff027
Subject: [PATCH] smartcard: Cancel cancellable when stopping
1ff027
1ff027
self->cancellable in GsdSmartcardManager is not cancelled
1ff027
at gsd_smartcard_manager_stop() and hence some callbacks are
1ff027
still called after unload_nss() which clears SECMODListLock
1ff027
which is used by SECMOD_GetReadLock() / SECMOD_ReleaseReadLock().
1ff027
1ff027
This leads to crashes in NSSRWLock_LockRead_Util() and
1ff027
NSSRWLock_UnlockRead_Util() probably.
1ff027
1ff027
Also check for return value of g_cancellable_connect()
1ff027
and initialize pointer to PK11SlotInfo.
1ff027
1ff027
See https://bugzilla.redhat.com/show_bug.cgi?id=1646359,
1ff027
https://bugzilla.redhat.com/show_bug.cgi?id=1688791 and
1ff027
their duplicates for additional info.
1ff027
---
1ff027
 plugins/smartcard/gsd-smartcard-manager.c | 7 +++++--
1ff027
 1 file changed, 5 insertions(+), 2 deletion(-)
1ff027
1ff027
diff --git a/plugins/smartcard/gsd-smartcard-manager.c b/plugins/smartcard/gsd-smartcard-manager.c
1ff027
index 014c17be..da1e0d6d 100644
1ff027
--- a/plugins/smartcard/gsd-smartcard-manager.c
1ff027
+++ b/plugins/smartcard/gsd-smartcard-manager.c
1ff027
@@ -184,7 +184,7 @@
1ff027
                              GError                   **error)
1ff027
 {
1ff027
         GsdSmartcardManagerPrivate *priv = self->priv;
1ff027
-        PK11SlotInfo *card, *old_card;
1ff027
+        PK11SlotInfo *card = NULL, *old_card;
1ff027
         CK_SLOT_ID slot_id;
1ff027
         gulong handler_id;
1ff027
         int old_slot_series = -1, slot_series;
1ff027
@@ -190,7 +190,8 @@ watch_one_event_from_driver (GsdSmartcardManager       *self,
1ff027
                                             operation,
1ff027
                                             NULL);
1ff027
 
1ff027
-        card = SECMOD_WaitForAnyTokenEvent (operation->driver, 0, PR_SecondsToInterval (1));
1ff027
+        if (handler_id != 0)
1ff027
+                card = SECMOD_WaitForAnyTokenEvent (operation->driver, 0, PR_SecondsToInterval (1));
1ff027
 
1ff027
         g_cancellable_disconnect (cancellable, handler_id);
1ff027
 
1ff027
@@ -773,6 +774,8 @@ gsd_smartcard_manager_stop (GsdSmartcardManager *self)
1ff027
 
1ff027
         g_debug ("Stopping smartcard manager");
1ff027
 
1ff027
+        g_cancellable_cancel (priv->cancellable);
1ff027
+
1ff027
         unload_nss (self);
1ff027
 
1ff027
         g_clear_object (&priv->settings);
1ff027
-- 
1ff027
2.23.0
1ff027