Linux Integrity Measurement development
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Zhenwen Liang <zhenwenliang@google.com>
Cc: Mimi Zohar <zohar@linux.ibm.com>,
	David Howells <dhowells@redhat.com>,
	James Bottomley <James.Bottomley@hansenpartnership.com>,
	Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	keyrings@vger.kernel.org, linux-integrity@vger.kernel.org,
	linux-security-module@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 2/2] KEYS: trusted: Wait for RCU callbacks before module unload
Date: Thu, 26 Nov 2026 22:42:32 +0200	[thread overview]
Message-ID: <awiZuKwNUP6mi6Yg@kernel.org> (raw)
In-Reply-To: <20261126200103.2806716-2-zhenwenliang@google.com>

On Thu, Nov 26, 2026 at 08:01:03PM +0000, Zhenwen Liang wrote:
> trusted_update() frees the old payload with call_rcu(), and the
> callback, trusted_rcu_free(), is part of trusted.ko. cleanup_trusted()
> calls the trust source's exit callback, which unregisters the key type,
> but nothing waits for callbacks that are already queued, so the module
> can be freed while a trusted_rcu_free() callback is still pending.

+1

> 
> Add an rcu_barrier() after the exit callback. As for encrypted keys, no
> new callback can be queued once unregister_key_type() has returned. If
> no trust source was found, the key type was never registered and
> trusted_key_exit is NULL; the barrier is then harmless.
> 
> Tested in QEMU (x86_64, TCG) without a trust source, so only the
> trusted_key_exit == NULL case ran: trusted.ko loads and unloads cleanly
> with this patch (5 runs). The trusted_update() path itself was not run,
> because no TPM was available.
> 
> The problem was found, and this patch prepared, with the help of a
> formal analysis tool we are developing that uses AI assistance; I have
> reviewed the analysis and the patch.
> 
> Fixes: d00a1c72f7f4 ("keys: add new trusted key-type")
> Link: https://lore.kernel.org/all/20261126023538.4160950-1-zhenwenliang@google.com/
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhenwen Liang <zhenwenliang@google.com>
> ---
>  security/keys/trusted-keys/trusted_core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c
> index 0509d9955f2a..5efd1e6ef111 100644
> --- a/security/keys/trusted-keys/trusted_core.c
> +++ b/security/keys/trusted-keys/trusted_core.c
> @@ -401,6 +401,7 @@ static void __exit cleanup_trusted(void)
>  {
>  	if (trusted_key_exit)
>  		(*trusted_key_exit)();
> +	rcu_barrier();
>  }
>  
>  late_initcall(init_trusted);

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

Br, Jarkko

  reply	other threads:[~2026-11-26 20:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 20:01 [PATCH 1/2] KEYS: encrypted: Wait for RCU callbacks before module unload Zhenwen Liang
2026-11-26 20:01 ` [PATCH 2/2] KEYS: trusted: " Zhenwen Liang
2026-11-26 20:42   ` Jarkko Sakkinen [this message]
2026-11-26 20:44     ` Jarkko Sakkinen
2026-11-26 20:41 ` [PATCH 1/2] KEYS: encrypted: " Jarkko Sakkinen

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=awiZuKwNUP6mi6Yg@kernel.org \
    --to=jarkko@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=dhowells@redhat.com \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=serge@hallyn.com \
    --cc=stable@vger.kernel.org \
    --cc=zhenwenliang@google.com \
    --cc=zohar@linux.ibm.com \
    /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