diff options
Diffstat (limited to 'security/keys/gc.c')
-rw-r--r-- | security/keys/gc.c | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/security/keys/gc.c b/security/keys/gc.c index d67c97bb1025..d3222b6d7d59 100644 --- a/security/keys/gc.c +++ b/security/keys/gc.c | |||
@@ -131,50 +131,6 @@ void key_gc_keytype(struct key_type *ktype) | |||
131 | } | 131 | } |
132 | 132 | ||
133 | /* | 133 | /* |
134 | * Garbage collect pointers from a keyring. | ||
135 | * | ||
136 | * Not called with any locks held. The keyring's key struct will not be | ||
137 | * deallocated under us as only our caller may deallocate it. | ||
138 | */ | ||
139 | static void key_gc_keyring(struct key *keyring, time_t limit) | ||
140 | { | ||
141 | struct keyring_list *klist; | ||
142 | int loop; | ||
143 | |||
144 | kenter("%x", key_serial(keyring)); | ||
145 | |||
146 | if (keyring->flags & ((1 << KEY_FLAG_INVALIDATED) | | ||
147 | (1 << KEY_FLAG_REVOKED))) | ||
148 | goto dont_gc; | ||
149 | |||
150 | /* scan the keyring looking for dead keys */ | ||
151 | rcu_read_lock(); | ||
152 | klist = rcu_dereference(keyring->payload.subscriptions); | ||
153 | if (!klist) | ||
154 | goto unlock_dont_gc; | ||
155 | |||
156 | loop = klist->nkeys; | ||
157 | smp_rmb(); | ||
158 | for (loop--; loop >= 0; loop--) { | ||
159 | struct key *key = rcu_dereference(klist->keys[loop]); | ||
160 | if (key_is_dead(key, limit)) | ||
161 | goto do_gc; | ||
162 | } | ||
163 | |||
164 | unlock_dont_gc: | ||
165 | rcu_read_unlock(); | ||
166 | dont_gc: | ||
167 | kleave(" [no gc]"); | ||
168 | return; | ||
169 | |||
170 | do_gc: | ||
171 | rcu_read_unlock(); | ||
172 | |||
173 | keyring_gc(keyring, limit); | ||
174 | kleave(" [gc]"); | ||
175 | } | ||
176 | |||
177 | /* | ||
178 | * Garbage collect a list of unreferenced, detached keys | 134 | * Garbage collect a list of unreferenced, detached keys |
179 | */ | 135 | */ |
180 | static noinline void key_gc_unused_keys(struct list_head *keys) | 136 | static noinline void key_gc_unused_keys(struct list_head *keys) |
@@ -392,8 +348,7 @@ found_unreferenced_key: | |||
392 | */ | 348 | */ |
393 | found_keyring: | 349 | found_keyring: |
394 | spin_unlock(&key_serial_lock); | 350 | spin_unlock(&key_serial_lock); |
395 | kdebug("scan keyring %d", key->serial); | 351 | keyring_gc(key, limit); |
396 | key_gc_keyring(key, limit); | ||
397 | goto maybe_resched; | 352 | goto maybe_resched; |
398 | 353 | ||
399 | /* We found a dead key that is still referenced. Reset its type and | 354 | /* We found a dead key that is still referenced. Reset its type and |