Linux FSCRYPT development
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Luis Henriques <lhenriques@suse.de>
Cc: "Theodore Y. Ts'o" <tytso@mit.edu>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	David Howells <dhowells@redhat.com>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	linux-fscrypt@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fscrypt: clear keyring before calling key_put()
Date: Tue, 6 Feb 2024 16:57:31 -0800	[thread overview]
Message-ID: <20240207005731.GB35324@sol.localdomain> (raw)
In-Reply-To: <20240206101619.8083-1-lhenriques@suse.de>

On Tue, Feb 06, 2024 at 10:16:19AM +0000, Luis Henriques wrote:
> 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);

Applied, thanks.  I added a comment above the call to keyring_clear() to explain
why it's there:

        /* Clear the keyring so the quota gets released right away. */

- Eric

  reply	other threads:[~2024-02-07  0:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06 10:16 [PATCH] fscrypt: clear keyring before calling key_put() Luis Henriques
2024-02-07  0:57 ` Eric Biggers [this message]
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=20240207005731.GB35324@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=jaegeuk@kernel.org \
    --cc=jarkko@kernel.org \
    --cc=lhenriques@suse.de \
    --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