public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fscrypt: clear keyring before calling key_put()
@ 2024-02-06 10:16 Luis Henriques
  2024-02-07  0:57 ` Eric Biggers
  0 siblings, 1 reply; 3+ messages in thread
From: Luis Henriques @ 2024-02-06 10:16 UTC (permalink / raw)
  To: Eric Biggers, Theodore Y. Ts'o, Jaegeuk Kim
  Cc: David Howells, Jarkko Sakkinen, linux-fscrypt, linux-kernel,
	Luis Henriques

Now that the key quotas are handled immediately on key_put() instead of
being postponed to the key management garbage collection worker, a call to
keyring_clear() is all that is required in fscrypt_put_master_key() so that
the keyring clean-up is also done synchronously.  This patch should fix the
fstest generic/581 flakiness.

Signed-off-by: Luis Henriques <lhenriques@suse.de>
---
Hi!

I know that patch "keys: update key quotas in key_put()" isn't yet merged
but since David and Jarkko seem to be OK with it, it doesn't hurt to send
this follow-up patch immediately.

Cheers,
-- 
Luis

 fs/crypto/keyring.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c
index 0edf0b58daa7..dfdaae16b83a 100644
--- a/fs/crypto/keyring.c
+++ b/fs/crypto/keyring.c
@@ -74,8 +74,11 @@ void fscrypt_put_master_key(struct fscrypt_master_key *mk)
 	 * that concurrent keyring lookups can no longer find it.
 	 */
 	WARN_ON_ONCE(refcount_read(&mk->mk_active_refs) != 0);
-	key_put(mk->mk_users);
-	mk->mk_users = NULL;
+	if (mk->mk_users) {
+		keyring_clear(mk->mk_users);
+		key_put(mk->mk_users);
+		mk->mk_users = NULL;
+	}
 	call_rcu(&mk->mk_rcu_head, fscrypt_free_master_key);
 }
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-07  9:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-06 10:16 [PATCH] fscrypt: clear keyring before calling key_put() Luis Henriques
2024-02-07  0:57 ` Eric Biggers
2024-02-07  9:37   ` Luis Henriques

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox