diff options
author | Luis Henriques <lhenriques@suse.de> | 2024-01-30 10:13:44 +0000 |
---|---|---|
committer | Jarkko Sakkinen <jarkko@kernel.org> | 2024-05-09 16:28:58 +0300 |
commit | 9578e327b2b4935a25d49e3891b8fcca9b6c10c6 (patch) | |
tree | 5b61b324bd79925ebcc6cae2139a4b81a084bd0e /security/keys/gc.c | |
parent | 45db3ab70092637967967bfd8e6144017638563c (diff) | |
download | linux-9578e327b2b4935a25d49e3891b8fcca9b6c10c6.tar.gz linux-9578e327b2b4935a25d49e3891b8fcca9b6c10c6.tar.bz2 linux-9578e327b2b4935a25d49e3891b8fcca9b6c10c6.zip |
keys: update key quotas in key_put()
Delaying key quotas update when key's refcount reaches 0 in key_put() has
been causing some issues in fscrypt testing, specifically in fstest
generic/581. This commit fixes this test flakiness by dealing with the
quotas immediately, and leaving all the other clean-ups to the key garbage
collector.
This is done by moving the updates to the qnkeys and qnbytes fields in
struct key_user from key_gc_unused_keys() into key_put(). Unfortunately,
this also means that we need to switch to the irq-version of the spinlock
that protects these fields and use spin_lock_{irqsave,irqrestore} in all
the code that touches these fields.
Signed-off-by: Luis Henriques <lhenriques@suse.de>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@kernel.org>
Diffstat (limited to 'security/keys/gc.c')
-rw-r--r-- | security/keys/gc.c | 8 |
1 files changed, 0 insertions, 8 deletions
diff --git a/security/keys/gc.c b/security/keys/gc.c index eaddaceda14e..7d687b0962b1 100644 --- a/security/keys/gc.c +++ b/security/keys/gc.c @@ -155,14 +155,6 @@ static noinline void key_gc_unused_keys(struct list_head *keys) security_key_free(key); - /* deal with the user's key tracking and quota */ - if (test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) { - spin_lock(&key->user->lock); - key->user->qnkeys--; - key->user->qnbytes -= key->quotalen; - spin_unlock(&key->user->lock); - } - atomic_dec(&key->user->nkeys); if (state != KEY_IS_UNINSTANTIATED) atomic_dec(&key->user->nikeys); |