From: Jarkko Sakkinen <jarkko@kernel.org>
To: Jiangshan Yi <yijiangshan@kylinos.cn>
Cc: peterhuewe@gmx.de, jgg@ziepe.ca, ross.philipson@oracle.com,
stefanb@linux.ibm.com, linux-integrity@vger.kernel.org,
linux-kernel@vger.kernel.org, 13667453960@163.com,
stable@vger.kernel.org
Subject: Re: [PATCH] tpm: Fix auth session leak in tpm2_get_random() error path
Date: Wed, 9 Sep 2026 18:57:42 +0300 [thread overview]
Message-ID: <aqGB9gxUv5IThT_q@kernel.org> (raw)
In-Reply-To: <20260902074839.417419-1-yijiangshan@kylinos.cn>
On Wed, Sep 02, 2026 at 03:48:39PM +0800, Jiangshan Yi wrote:
> When tpm_buf_fill_hmac_session() fails in tpm2_get_random(), the error
> path returns without calling tpm2_end_auth_session(), leaking the auth
> session. All other error paths in the function handle this correctly.
>
> Fixes: 3d9e043dab0a ("tpm-buf: Memory-safe allocations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
> ---
> drivers/char/tpm/tpm2-cmd.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
> index 48cec39995fe..96e0e06bbbf0 100644
> --- a/drivers/char/tpm/tpm2-cmd.c
> +++ b/drivers/char/tpm/tpm2-cmd.c
> @@ -281,8 +281,10 @@ int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max)
> }
> tpm_buf_append_u16(buf, num_bytes);
> err = tpm_buf_fill_hmac_session(chip, buf);
> - if (err)
> + if (err) {
> + tpm2_end_auth_session(chip);
> return err;
> + }
>
> err = tpm_transmit_cmd(chip, buf,
> offsetof(struct tpm2_get_random_out,
> --
> 2.25.1
>
Thanks for the fix.
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
next prev parent reply other threads:[~2026-09-09 15:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 7:48 Jiangshan Yi
2026-09-09 15:57 ` Jarkko Sakkinen [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-04-02 18:11 Gunnar Kudrjavets
2026-04-08 9:00 ` 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=aqGB9gxUv5IThT_q@kernel.org \
--to=jarkko@kernel.org \
--cc=13667453960@163.com \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=ross.philipson@oracle.com \
--cc=stable@vger.kernel.org \
--cc=stefanb@linux.ibm.com \
--cc=yijiangshan@kylinos.cn \
/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
all inboxes | Powered by JetHome®