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 heap buffer overflow in tpm_transmit_cmd()
Date: Tue, 1 Sep 2026 16:47:44 +0300 [thread overview]
Message-ID: <apbXgGwsxAualfEK@kernel.org> (raw)
In-Reply-To: <20260901062850.379870-1-yijiangshan@kylinos.cn>
On Tue, Sep 01, 2026 at 02:28:50PM +0800, Jiangshan Yi wrote:
> struct tpm_buf now uses an embedded flexible array for data, which is
> 6 bytes shorter than TPM_BUFSIZE due to the struct header. But
> tpm_transmit_cmd() still passes PAGE_SIZE to tpm_transmit(), and after
> clamping to TPM_BUFSIZE in tpm_try_transmit(), chip->ops->recv() can
> write past the end of data[] by 6 bytes.
>
> Pass buf->capacity to tpm_transmit() instead.
>
> Fixes: 3d9e043dab0a ("tpm-buf: Memory-safe allocations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
> ---
> drivers/char/tpm/tpm-interface.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index f745a098908b..1ccdbde98b69 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -268,7 +268,7 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf,
> int err;
> ssize_t len;
>
> - len = tpm_transmit(chip, buf->data, PAGE_SIZE);
> + len = tpm_transmit(chip, buf->data, buf->capacity);
> if (len < 0)
> return len;
>
> --
> 2.25.1
>
Thank you good catch!
I'll apply this and put to rc2 PR.
BR, Jarkko
prev parent reply other threads:[~2026-09-01 13:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 6:28 [PATCH] tpm: Fix heap buffer overflow in tpm_transmit_cmd() Jiangshan Yi
2026-09-01 13:47 ` 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=apbXgGwsxAualfEK@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