|
|
4b1d23 |
From 4a925177a81c2566d2a81a0a450607a5ff4d9048 Mon Sep 17 00:00:00 2001
|
|
|
4b1d23 |
From: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
4b1d23 |
Date: Wed, 27 Feb 2019 12:25:20 +0100
|
|
|
4b1d23 |
Subject: [PATCH] modules: check gl.modules before iterates on it when freeing
|
|
|
4b1d23 |
|
|
|
4b1d23 |
In some circumstances, as described in the BZ, can happen that
|
|
|
4b1d23 |
free_modules_when_no_refs_unlocked() is called multiple times
|
|
|
4b1d23 |
when the module destructor is invoked.
|
|
|
4b1d23 |
We should check gl.modules before iterates on it in the
|
|
|
4b1d23 |
free_modules_when_no_refs_unlocked() functions, to avoid
|
|
|
4b1d23 |
a SIGSEGV.
|
|
|
4b1d23 |
|
|
|
4b1d23 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1680963
|
|
|
4b1d23 |
---
|
|
|
4b1d23 |
p11-kit/modules.c | 18 ++++++++++--------
|
|
|
4b1d23 |
1 file changed, 10 insertions(+), 8 deletions(-)
|
|
|
4b1d23 |
|
|
|
4b1d23 |
diff --git a/p11-kit/modules.c b/p11-kit/modules.c
|
|
|
4b1d23 |
index 0299eda..891ce4c 100644
|
|
|
4b1d23 |
--- a/p11-kit/modules.c
|
|
|
4b1d23 |
+++ b/p11-kit/modules.c
|
|
|
4b1d23 |
@@ -797,14 +797,16 @@ init_globals_unlocked (void)
|
|
|
4b1d23 |
static void
|
|
|
4b1d23 |
free_modules_when_no_refs_unlocked (void)
|
|
|
4b1d23 |
{
|
|
|
4b1d23 |
- Module *mod;
|
|
|
4b1d23 |
- p11_dictiter iter;
|
|
|
4b1d23 |
-
|
|
|
4b1d23 |
- /* Check if any modules have a ref count */
|
|
|
4b1d23 |
- p11_dict_iterate (gl.modules, &iter);
|
|
|
4b1d23 |
- while (p11_dict_next (&iter, (void **)&mod, NULL)) {
|
|
|
4b1d23 |
- if (mod->ref_count)
|
|
|
4b1d23 |
- return;
|
|
|
4b1d23 |
+ if (gl.modules) {
|
|
|
4b1d23 |
+ Module *mod;
|
|
|
4b1d23 |
+ p11_dictiter iter;
|
|
|
4b1d23 |
+
|
|
|
4b1d23 |
+ /* Check if any modules have a ref count */
|
|
|
4b1d23 |
+ p11_dict_iterate (gl.modules, &iter);
|
|
|
4b1d23 |
+ while (p11_dict_next (&iter, (void **)&mod, NULL)) {
|
|
|
4b1d23 |
+ if (mod->ref_count)
|
|
|
4b1d23 |
+ return;
|
|
|
4b1d23 |
+ }
|
|
|
4b1d23 |
}
|
|
|
4b1d23 |
|
|
|
4b1d23 |
p11_dict_free (gl.unmanaged_by_funcs);
|
|
|
4b1d23 |
--
|
|
|
4b1d23 |
2.20.1
|
|
|
4b1d23 |
|