All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Gunnar Kudrjavets <gunnarku@amazon.com>
Cc: jbouron@amazon.com, jgg@ziepe.ca,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
	mhijaz@amazon.com, noodles@meta.com, peterhuewe@gmx.de
Subject: Re: [PATCH v2] tpm: Initialize name_size_alg for non-NULL name in tpm_buf_append_name()
Date: Sun, 10 May 2026 21:26:48 +0300	[thread overview]
Message-ID: <agDN6EbJWXoSB63e@kernel.org> (raw)
In-Reply-To: <20260510171152.4607-1-gunnarku@amazon.com>

On Sun, May 10, 2026 at 05:11:27PM +0000, Gunnar Kudrjavets wrote:
> tpm_buf_append_name() supports callers passing a pre-computed name
> for handles. When name is non-NULL, the code skips the
> tpm2_read_public() path but leaves name_size_alg uninitialized
> before it is used as the memcpy size argument.
> 
> No current in-tree caller passes a non-NULL name, but future use
> cases such as name caching would exercise this path. Initialize
> name_size_alg by calling name_size() on the caller-provided name,
> sharing the error check and assignment with the existing
> tpm2_read_public() path. This prevents unmasking a latent bug when
> the non-NULL name path is eventually used.
> 
> Assisted-by: Kiro:claude-opus-4.6
> Reviewed-by: Justinien Bouron <jbouron@amazon.com>
> Reviewed-by: Muhammad Hammad Ijaz <mhijaz@amazon.com>
> Signed-off-by: Gunnar Kudrjavets <gunnarku@amazon.com>
> ---
>  drivers/char/tpm/tpm2-sessions.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm2-sessions.c b/drivers/char/tpm/tpm2-sessions.c
> index c4da6fde748f..795cd99dc6fe 100644
> --- a/drivers/char/tpm/tpm2-sessions.c
> +++ b/drivers/char/tpm/tpm2-sessions.c
> @@ -285,11 +285,14 @@ int tpm_buf_append_name(struct tpm_chip *chip, struct tpm_buf *buf,
>  	    mso == TPM2_MSO_NVRAM) {
>  		if (!name) {
>  			ret = tpm2_read_public(chip, handle, auth->name[slot]);
> -			if (ret < 0)
> -				goto err;
> -
> -			name_size_alg = ret;
> +		} else {
> +			ret = name_size(name);
>  		}
> +
> +		if (ret < 0)
> +			goto err;
> +
> +		name_size_alg = ret;
>  	} else {
>  		if (name) {
>  			dev_err(&chip->dev, "handle 0x%08x does not use a name\n",
> 
> base-commit: 44bd97559c26bb4d7abac09d29e58a4152d88567
> --
> 2.47.3
> 

Thank you. Applied.

BR, Jarkko

      reply	other threads:[~2026-05-10 18:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07 20:18 [PATCH] tpm: Fix uninitialized name_size_alg in tpm_buf_append_name() Gunnar Kudrjavets
2026-05-09 19:35 ` Jarkko Sakkinen
2026-05-09 22:34   ` [PATCH v2] " Gunnar Kudrjavets
2026-05-10  1:42     ` Jarkko Sakkinen
2026-05-10 17:11       ` [PATCH v2] tpm: Initialize name_size_alg for non-NULL name " Gunnar Kudrjavets
2026-05-10 18:26         ` Jarkko Sakkinen [this message]

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=agDN6EbJWXoSB63e@kernel.org \
    --to=jarkko@kernel.org \
    --cc=gunnarku@amazon.com \
    --cc=jbouron@amazon.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhijaz@amazon.com \
    --cc=noodles@meta.com \
    --cc=peterhuewe@gmx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.