linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] tpm: Add check for Failure mode for TPM2 modules
@ 2022-07-05 13:24 Mårten Lindahl
  2022-07-11  2:52 ` Jarkko Sakkinen
  0 siblings, 1 reply; 3+ messages in thread
From: Mårten Lindahl @ 2022-07-05 13:24 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen
  Cc: Jason Gunthorpe, linux-integrity, kernel, Mårten Lindahl,
	stable

In commit 0aa698787aa2 ("tpm: Add Upgrade/Reduced mode support for
TPM2 modules") it was said that:

"If the TPM is in Failure mode, it will successfully respond to both
tpm2_do_selftest() and tpm2_startup() calls. Although, will fail to
answer to tpm2_get_cc_attrs_tbl(). Use this fact to conclude that TPM
is in Failure mode."

But a check was never added in the commit when calling
tpm2_get_cc_attrs_tbl() to conclude that the TPM is in Failure mode.
This commit corrects this by adding a check.

Fixes: 0aa698787aa2 ("tpm: Add Upgrade/Reduced mode support for TPM2 modules")
Cc: stable@vger.kernel.org # v5.17+
Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
---

v3:
 - Add Jarkkos Reviewed-by tag.
 - Add Fixes tag and Cc.

v2:
 - Add missed check for TPM error code.

 drivers/char/tpm/tpm2-cmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index c1eb5d223839..65d03867e114 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -752,6 +752,12 @@ int tpm2_auto_startup(struct tpm_chip *chip)
 	}
 
 	rc = tpm2_get_cc_attrs_tbl(chip);
+	if (rc == TPM2_RC_FAILURE || (rc < 0 && rc != -ENOMEM)) {
+		dev_info(&chip->dev,
+			 "TPM in field failure mode, requires firmware upgrade\n");
+		chip->flags |= TPM_CHIP_FLAG_FIRMWARE_UPGRADE;
+		rc = 0;
+	}
 
 out:
 	/*
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] tpm: Add check for Failure mode for TPM2 modules
  2022-07-05 13:24 [PATCH v3] tpm: Add check for Failure mode for TPM2 modules Mårten Lindahl
@ 2022-07-11  2:52 ` Jarkko Sakkinen
  2022-08-01 12:55   ` Marten Lindahl
  0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Sakkinen @ 2022-07-11  2:52 UTC (permalink / raw)
  To: M??rten Lindahl
  Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, kernel, stable

On Tue, Jul 05, 2022 at 03:24:23PM +0200, M??rten Lindahl wrote:
> In commit 0aa698787aa2 ("tpm: Add Upgrade/Reduced mode support for
> TPM2 modules") it was said that:
> 
> "If the TPM is in Failure mode, it will successfully respond to both
> tpm2_do_selftest() and tpm2_startup() calls. Although, will fail to
> answer to tpm2_get_cc_attrs_tbl(). Use this fact to conclude that TPM
> is in Failure mode."
> 
> But a check was never added in the commit when calling
> tpm2_get_cc_attrs_tbl() to conclude that the TPM is in Failure mode.
> This commit corrects this by adding a check.
> 
> Fixes: 0aa698787aa2 ("tpm: Add Upgrade/Reduced mode support for TPM2 modules")
> Cc: stable@vger.kernel.org # v5.17+
> Signed-off-by: M??rten Lindahl <marten.lindahl@axis.com>

The characters here are messed up.

> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
> ---
> 
> v3:
>  - Add Jarkkos Reviewed-by tag.
>  - Add Fixes tag and Cc.
> 
> v2:
>  - Add missed check for TPM error code.
> 
>  drivers/char/tpm/tpm2-cmd.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
> index c1eb5d223839..65d03867e114 100644
> --- a/drivers/char/tpm/tpm2-cmd.c
> +++ b/drivers/char/tpm/tpm2-cmd.c
> @@ -752,6 +752,12 @@ int tpm2_auto_startup(struct tpm_chip *chip)
>  	}
>  
>  	rc = tpm2_get_cc_attrs_tbl(chip);
> +	if (rc == TPM2_RC_FAILURE || (rc < 0 && rc != -ENOMEM)) {
> +		dev_info(&chip->dev,
> +			 "TPM in field failure mode, requires firmware upgrade\n");
> +		chip->flags |= TPM_CHIP_FLAG_FIRMWARE_UPGRADE;
> +		rc = 0;
> +	}
>  
>  out:
>  	/*
> -- 
> 2.30.2
> 

BR, Jarkko

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] tpm: Add check for Failure mode for TPM2 modules
  2022-07-11  2:52 ` Jarkko Sakkinen
@ 2022-08-01 12:55   ` Marten Lindahl
  0 siblings, 0 replies; 3+ messages in thread
From: Marten Lindahl @ 2022-08-01 12:55 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: Mårten Lindahl, Peter Huewe, Jason Gunthorpe,
	linux-integrity@vger.kernel.org, kernel, stable@vger.kernel.org

On Mon, Jul 11, 2022 at 04:52:11AM +0200, Jarkko Sakkinen wrote:
> On Tue, Jul 05, 2022 at 03:24:23PM +0200, M??rten Lindahl wrote:
> > In commit 0aa698787aa2 ("tpm: Add Upgrade/Reduced mode support for
> > TPM2 modules") it was said that:
> > 
> > "If the TPM is in Failure mode, it will successfully respond to both
> > tpm2_do_selftest() and tpm2_startup() calls. Although, will fail to
> > answer to tpm2_get_cc_attrs_tbl(). Use this fact to conclude that TPM
> > is in Failure mode."
> > 
> > But a check was never added in the commit when calling
> > tpm2_get_cc_attrs_tbl() to conclude that the TPM is in Failure mode.
> > This commit corrects this by adding a check.
> > 
> > Fixes: 0aa698787aa2 ("tpm: Add Upgrade/Reduced mode support for TPM2 modules")
> > Cc: stable@vger.kernel.org # v5.17+
> > Signed-off-by: M??rten Lindahl <marten.lindahl@axis.com>
> 
> The characters here are messed up.

Hi!

Sorry, I don't know why it looks like that. The patch looks fine as far
as I can see. I will resend it again.

Kind regards
Mårten

> 
> > Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
> > ---
> > 
> > v3:
> >  - Add Jarkkos Reviewed-by tag.
> >  - Add Fixes tag and Cc.
> > 
> > v2:
> >  - Add missed check for TPM error code.
> > 
> >  drivers/char/tpm/tpm2-cmd.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
> > index c1eb5d223839..65d03867e114 100644
> > --- a/drivers/char/tpm/tpm2-cmd.c
> > +++ b/drivers/char/tpm/tpm2-cmd.c
> > @@ -752,6 +752,12 @@ int tpm2_auto_startup(struct tpm_chip *chip)
> >  	}
> >  
> >  	rc = tpm2_get_cc_attrs_tbl(chip);
> > +	if (rc == TPM2_RC_FAILURE || (rc < 0 && rc != -ENOMEM)) {
> > +		dev_info(&chip->dev,
> > +			 "TPM in field failure mode, requires firmware upgrade\n");
> > +		chip->flags |= TPM_CHIP_FLAG_FIRMWARE_UPGRADE;
> > +		rc = 0;
> > +	}
> >  
> >  out:
> >  	/*
> > -- 
> > 2.30.2
> > 
> 
> BR, Jarkko

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-01 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-05 13:24 [PATCH v3] tpm: Add check for Failure mode for TPM2 modules Mårten Lindahl
2022-07-11  2:52 ` Jarkko Sakkinen
2022-08-01 12:55   ` Marten Lindahl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).