public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tpm: set TPM_CHIP_FLAG_SUSPENDED early
@ 2024-10-29 22:36 Jarkko Sakkinen
  2024-10-30 20:09 ` Jerry Snitselaar
  0 siblings, 1 reply; 7+ messages in thread
From: Jarkko Sakkinen @ 2024-10-29 22:36 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe, Jerry Snitselaar
  Cc: stable, Mike Seo, open list:TPM DEVICE DRIVER, open list

Setting TPM_CHIP_FLAG_SUSPENDED in the end of tpm_pm_suspend() can be racy
according to the bug report, as this leaves window for tpm_hwrng_read() to
be called while the operation is in progress. Move setting of the flag
into the beginning.

Cc: stable@vger.kernel.org # v6.4+
Fixes: 99d464506255 ("tpm: Prevent hwrng from activating during resume")
Reported-by: Mike Seo <mikeseohyungjin@gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219383
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
 drivers/char/tpm/tpm-interface.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 8134f002b121..3f96bc8b95df 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -370,6 +370,8 @@ int tpm_pm_suspend(struct device *dev)
 	if (!chip)
 		return -ENODEV;
 
+	chip->flags |= TPM_CHIP_FLAG_SUSPENDED;
+
 	if (chip->flags & TPM_CHIP_FLAG_ALWAYS_POWERED)
 		goto suspended;
 
@@ -390,8 +392,6 @@ int tpm_pm_suspend(struct device *dev)
 	}
 
 suspended:
-	chip->flags |= TPM_CHIP_FLAG_SUSPENDED;
-
 	if (rc)
 		dev_err(dev, "Ignoring error %d while suspending\n", rc);
 	return 0;
-- 
2.47.0


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

end of thread, other threads:[~2024-10-31 16:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29 22:36 [PATCH] tpm: set TPM_CHIP_FLAG_SUSPENDED early Jarkko Sakkinen
2024-10-30 20:09 ` Jerry Snitselaar
2024-10-30 23:36   ` Jarkko Sakkinen
2024-10-31 15:02     ` Jerry Snitselaar
2024-10-31 15:28       ` Jerry Snitselaar
2024-10-31 15:59         ` Jarkko Sakkinen
2024-10-31 16:02       ` Jarkko Sakkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox