mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: "A. Sverdlin" <alexander.sverdlin@siemens.com>
Cc: linux-integrity@vger.kernel.org, Peter Huewe <peterhuewe@gmx.de>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Jay Freyensee <why2jjj.linux@gmail.com>,
	Jerry Snitselaar <jsnitsel@redhat.com>,
	Nayna Jain <nayna@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] tpm: tpm2_probe: propagate transport errors
Date: Fri, 2 Oct 2026 06:44:34 +0300	[thread overview]
Message-ID: <ar8oot0ceRNTMF7p@kernel.org> (raw)
In-Reply-To: <20261001060114.1582092-1-alexander.sverdlin@siemens.com>

On Thu, Oct 01, 2026 at 08:01:11AM +0200, A. Sverdlin wrote:
> From: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> 
> tpm2_probe() reads the protocol version from the response tag and is
> documented to return -errno on failure, but it always returns 0.  A
> transport error (tpm_transmit_cmd() < 0) is thus swallowed together with
> the intentionally ignored TPM response code, leaving TPM_CHIP_FLAG_TPM2
> unset. A transient bus failure on the first command then misdetects a
> TPM 2.0 as a 1.2 and the probe fails on the TPM 1.2 path:
> 
>   tpm_tis_i2c 0-002e: 1.2 TPM (device-id 0x1C, rev-id 22)
>   tpm tpm0: A TPM error (-62) occurred attempting to determine the timeouts
> 
> Return the transport error instead; rc >= 0 still means a valid header was
> received and the TPM's own response code is still ignored.
> 
> Fixes: 94e266ba1fa3 ("tpm: migrate tpm2_probe() to use struct tpm_buf")
> Cc: stable@vger.kernel.org
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> ---
>  drivers/char/tpm/tpm2-cmd.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
> index a94f4395c198a..4b2bb2ddc321a 100644
> --- a/drivers/char/tpm/tpm2-cmd.c
> +++ b/drivers/char/tpm/tpm2-cmd.c
> @@ -483,8 +483,9 @@ int tpm2_probe(struct tpm_chip *chip)
>  		out = (struct tpm_header *)buf->data;
>  		if (be16_to_cpu(out->tag) == TPM2_ST_NO_SESSIONS)
>  			chip->flags |= TPM_CHIP_FLAG_TPM2;
> +		return 0;
>  	}
> -	return 0;
> +	return rc;
>  }
>  EXPORT_SYMBOL_GPL(tpm2_probe);
>  
> -- 
> 2.55.0
> 

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

Thanks.

Br, Jarkko

      reply	other threads:[~2026-10-02  3:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01  6:01 A. Sverdlin
2026-10-02  3:44 ` 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=ar8oot0ceRNTMF7p@kernel.org \
    --to=jarkko@kernel.org \
    --cc=alexander.sverdlin@siemens.com \
    --cc=jgg@ziepe.ca \
    --cc=jsnitsel@redhat.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nayna@linux.vnet.ibm.com \
    --cc=peterhuewe@gmx.de \
    --cc=stable@vger.kernel.org \
    --cc=why2jjj.linux@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

all inboxes | Powered by JetHome®