From: Luis Henriques <lhenriques@suse.de>
To: Eric Biggers <ebiggers@kernel.org>,
"Theodore Y. Ts'o" <tytso@mit.edu>,
Jaegeuk Kim <jaegeuk@kernel.org>
Cc: David Howells <dhowells@redhat.com>,
Jarkko Sakkinen <jarkko@kernel.org>,
linux-fscrypt@vger.kernel.org, linux-kernel@vger.kernel.org,
Luis Henriques <lhenriques@suse.de>
Subject: [PATCH] fscrypt: clear keyring before calling key_put()
Date: Tue, 6 Feb 2024 10:16:19 +0000 [thread overview]
Message-ID: <20240206101619.8083-1-lhenriques@suse.de> (raw)
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);
}
next reply other threads:[~2024-02-06 10:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-06 10:16 Luis Henriques [this message]
2024-02-07 0:57 ` [PATCH] fscrypt: clear keyring before calling key_put() Eric Biggers
2024-02-07 9:37 ` Luis Henriques
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240206101619.8083-1-lhenriques@suse.de \
--to=lhenriques@suse.de \
--cc=dhowells@redhat.com \
--cc=ebiggers@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=jarkko@kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).