From: Jarkko Sakkinen <jarkko@kernel.org>
To: Ruoyu Wang <ruoyuw560@gmail.com>
Cc: linux-integrity@vger.kernel.org, peterhuewe@gmx.de, jgg@ziepe.ca,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] tpm: st33zp24: Validate locality read result
Date: Fri, 21 Aug 2026 04:12:29 +0300 [thread overview]
Message-ID: <aoel_e5R2AP8ocOI@kernel.org> (raw)
In-Reply-To: <20260813153032.3951878-2-ruoyuw560@gmail.com>
On Thu, Aug 13, 2026 at 11:30:32PM +0800, Ruoyu Wang wrote:
> check_locality() treats every nonzero transport return as success. SPI
> errors remain negative, while the I2C path can convert a negative write
> error through its byte-sized status variable. Either result is nonzero
> even though the TPM_ACCESS byte can remain unwritten, so indeterminate
> ACTIVE_LOCALITY and VALID bits can falsely report an active locality.
>
> Require recv() to return exactly the requested byte before examining
> TPM_ACCESS. Transport errors and short reads now report an inactive
> locality, while successful reads retain the existing behavior.
>
> This issue was found by a static analysis checker and confirmed by manual
> source review.
>
> Fixes: 251a7b08213a ("TPM: STMicroelectronics ST33 I2C KERNEL 3.x")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
> drivers/char/tpm/st33zp24/st33zp24.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c
> index 898e8d01d26698..0e2deff94c3672 100644
> --- a/drivers/char/tpm/st33zp24/st33zp24.c
> +++ b/drivers/char/tpm/st33zp24/st33zp24.c
> @@ -106,10 +106,10 @@ static bool check_locality(struct tpm_chip *chip)
> {
> struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
> u8 data;
> - u8 status;
> + int status;
>
> status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_ACCESS, &data, 1);
> - if (status && (data &
> + if (status == 1 && (data &
> (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
> (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
> return true;
> --
> 2.51.0
>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
next prev parent reply other threads:[~2026-08-21 1:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 15:30 [PATCH 1/2] tpm: st33zp24: Return zero on status read failure Ruoyu Wang
2026-08-13 15:30 ` [PATCH 2/2] tpm: st33zp24: Validate locality read result Ruoyu Wang
2026-08-21 1:12 ` Jarkko Sakkinen [this message]
2026-08-21 1:07 ` [PATCH 1/2] tpm: st33zp24: Return zero on status read failure 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=aoel_e5R2AP8ocOI@kernel.org \
--to=jarkko@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=ruoyuw560@gmail.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