...
...
14
above zero. Whenever this happens, the key will be skipped.
14
above zero. Whenever this happens, the key will be skipped.
15
15
16
Cc: stable@vger.kernel.org # v6.1+
16
Cc: stable@vger.kernel.org # v6.1+
17
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@opinsys.com>
17
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@opinsys.com>
18
---
18
---
19
v8:
20
- One more rebasing error (2x list_splice_init, reported by Marek Szyprowski)
21
v7:
22
- Fixed multiple definitions (from rebasing).
19
v6:
23
v6:
20
- Rebase went wrong in v5.
24
- Rebase went wrong in v5.
21
v5:
25
v5:
22
- Rebased on top of v6.15-rc
26
- Rebased on top of v6.15-rc
23
- Updated commit message to explain how spin lock and refcount
27
- Updated commit message to explain how spin lock and refcount
...
...
36
v2:
40
v2:
37
- Rename key_gc_unused_keys as key_gc_graveyard, and re-document the
41
- Rename key_gc_unused_keys as key_gc_graveyard, and re-document the
38
function.
42
function.
39
---
43
---
40
include/linux/key.h | 7 ++-----
44
include/linux/key.h | 7 ++-----
41
security/keys/gc.c | 44 +++++++++++++++++++++++++---------------
45
security/keys/gc.c | 36 ++++++++++++++++++++----------------
42
security/keys/internal.h | 5 +++++
46
security/keys/internal.h | 5 +++++
43
security/keys/key.c | 7 +++++--
47
security/keys/key.c | 7 +++++--
44
4 files changed, 40 insertions(+), 23 deletions(-)
48
4 files changed, 32 insertions(+), 23 deletions(-)
45
49
46
diff --git a/include/linux/key.h b/include/linux/key.h
50
diff --git a/include/linux/key.h b/include/linux/key.h
47
index XXXXXXX..XXXXXXX 100644
51
index XXXXXXX..XXXXXXX 100644
48
--- a/include/linux/key.h
52
--- a/include/linux/key.h
49
+++ b/include/linux/key.h
53
+++ b/include/linux/key.h
...
...
70
     * - the desc is used to match a key against search criteria
74
     * - the desc is used to match a key against search criteria
71
diff --git a/security/keys/gc.c b/security/keys/gc.c
75
diff --git a/security/keys/gc.c b/security/keys/gc.c
72
index XXXXXXX..XXXXXXX 100644
76
index XXXXXXX..XXXXXXX 100644
73
--- a/security/keys/gc.c
77
--- a/security/keys/gc.c
74
+++ b/security/keys/gc.c
78
+++ b/security/keys/gc.c
75
@@ -XXX,XX +XXX,XX @@
76
#include <keys/keyring-type.h>
77
#include "internal.h"
78
79
+LIST_HEAD(key_graveyard);
80
+DEFINE_SPINLOCK(key_graveyard_lock);
81
+
82
+
83
/*
84
* Delay between key revocation/expiry in seconds
85
*/
86
@@ -XXX,XX +XXX,XX @@ static void key_garbage_collector(struct work_struct *work)
79
@@ -XXX,XX +XXX,XX @@ static void key_garbage_collector(struct work_struct *work)
87
    struct rb_node *cursor;
80
    struct rb_node *cursor;
88
    struct key *key;
81
    struct key *key;
89
    time64_t new_timer, limit, expiry;
82
    time64_t new_timer, limit, expiry;
90
+    unsigned long flags;
83
+    unsigned long flags;
...
...
138
+    key_put(key);
131
+    key_put(key);
139
132
140
    /* We've completed the pass. Set the timer if we need to and queue a
133
    /* We've completed the pass. Set the timer if we need to and queue a
141
     * new cycle if necessary. We keep executing cycles until we find one
134
     * new cycle if necessary. We keep executing cycles until we find one
142
@@ -XXX,XX +XXX,XX @@ static void key_garbage_collector(struct work_struct *work)
135
@@ -XXX,XX +XXX,XX @@ static void key_garbage_collector(struct work_struct *work)
143
        key_schedule_gc(new_timer);
144
    }
145
146
+    spin_lock(&key_graveyard_lock);
147
+    list_splice_init(&key_graveyard, &graveyard);
148
+    spin_unlock(&key_graveyard_lock);
149
+
150
    if (unlikely(gc_state & KEY_GC_REAPING_DEAD_2) ||
151
     !list_empty(&graveyard)) {
152
        /* Make sure that all pending keyring payload destructions are
153
@@ -XXX,XX +XXX,XX @@ static void key_garbage_collector(struct work_struct *work)
154
    kleave(" [end %x]", gc_state);
136
    kleave(" [end %x]", gc_state);
155
    return;
137
    return;
156
138
157
-    /* We found an unreferenced key - once we've removed it from the tree,
139
-    /* We found an unreferenced key - once we've removed it from the tree,
158
-     * we can safely drop the lock.
140
-     * we can safely drop the lock.
...
...
diff view generated by jsdifflib