Lines Matching full:key

2 /* Key garbage collector
14 * Delay between key revocation/expiry in seconds
34 #define KEY_GC_KEY_EXPIRED 0 /* A key expired and needs unlinking */
40 * Any key whose type gets unregistered will be re-typed to this if it can't be
79 * Some key's cleanup time was met after it expired, so we need to get the
125 struct key *key = in key_gc_unused_keys() local
126 list_entry(keys->next, struct key, graveyard_link); in key_gc_unused_keys()
127 short state = key->state; in key_gc_unused_keys()
129 list_del(&key->graveyard_link); in key_gc_unused_keys()
131 kdebug("- %u", key->serial); in key_gc_unused_keys()
132 key_check(key); in key_gc_unused_keys()
135 remove_watch_list(key->watchers, key->serial); in key_gc_unused_keys()
136 key->watchers = NULL; in key_gc_unused_keys()
139 /* Throw away the key data if the key is instantiated */ in key_gc_unused_keys()
140 if (state == KEY_IS_POSITIVE && key->type->destroy) in key_gc_unused_keys()
141 key->type->destroy(key); in key_gc_unused_keys()
143 security_key_free(key); in key_gc_unused_keys()
145 /* deal with the user's key tracking and quota */ in key_gc_unused_keys()
146 if (test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) { in key_gc_unused_keys()
147 spin_lock(&key->user->lock); in key_gc_unused_keys()
148 key->user->qnkeys--; in key_gc_unused_keys()
149 key->user->qnbytes -= key->quotalen; in key_gc_unused_keys()
150 spin_unlock(&key->user->lock); in key_gc_unused_keys()
153 atomic_dec(&key->user->nkeys); in key_gc_unused_keys()
155 atomic_dec(&key->user->nikeys); in key_gc_unused_keys()
157 key_user_put(key->user); in key_gc_unused_keys()
158 key_put_tag(key->domain_tag); in key_gc_unused_keys()
159 kfree(key->description); in key_gc_unused_keys()
161 memzero_explicit(key, sizeof(*key)); in key_gc_unused_keys()
162 kmem_cache_free(key_jar, key); in key_gc_unused_keys()
181 #define KEY_GC_REAPING_DEAD_2 0x20 /* - We need to reap dead key links */ in key_garbage_collector()
183 #define KEY_GC_FOUND_DEAD_KEY 0x80 /* - We found at least one dead key */ in key_garbage_collector()
186 struct key *key; in key_garbage_collector() local
209 /* As only this function is permitted to remove things from the key in key_garbage_collector()
218 key = rb_entry(cursor, struct key, serial_node); in key_garbage_collector()
221 if (refcount_read(&key->usage) == 0) in key_garbage_collector()
225 if (key->type == key_gc_dead_keytype) { in key_garbage_collector()
227 set_bit(KEY_FLAG_DEAD, &key->flags); in key_garbage_collector()
228 key->perm = 0; in key_garbage_collector()
230 } else if (key->type == &key_type_keyring && in key_garbage_collector()
231 key->restrict_link) { in key_garbage_collector()
237 if (key->expiry > limit && key->expiry < new_timer) { in key_garbage_collector()
239 key_serial(key), key->expiry - limit); in key_garbage_collector()
240 new_timer = key->expiry; in key_garbage_collector()
245 if (key->type == key_gc_dead_keytype) in key_garbage_collector()
250 if (key->type == &key_type_keyring) in key_garbage_collector()
255 if (key->type == key_gc_dead_keytype) in key_garbage_collector()
326 /* We found an unreferenced key - once we've removed it from the tree, in key_garbage_collector()
330 kdebug("unrefd key %d", key->serial); in key_garbage_collector()
331 rb_erase(&key->serial_node, &key_serial_tree); in key_garbage_collector()
334 list_add_tail(&key->graveyard_link, &graveyard); in key_garbage_collector()
339 * it is associated with the dead key type. in key_garbage_collector()
343 keyring_restriction_gc(key, key_gc_dead_keytype); in key_garbage_collector()
353 keyring_gc(key, limit); in key_garbage_collector()
356 /* We found a dead key that is still referenced. Reset its type and in key_garbage_collector()
361 kdebug("destroy key %d", key->serial); in key_garbage_collector()
362 down_write(&key->sem); in key_garbage_collector()
363 key->type = &key_type_dead; in key_garbage_collector()
365 key_gc_dead_keytype->destroy(key); in key_garbage_collector()
366 memset(&key->payload, KEY_DESTROY, sizeof(key->payload)); in key_garbage_collector()
367 up_write(&key->sem); in key_garbage_collector()