From: Thomas Fourier <fourier.thomas@gmail.com>
Cc: Thomas Fourier <fourier.thomas@gmail.com>,
stable@vger.kernel.org, Peter Huewe <peterhuewe@gmx.de>,
Jarkko Sakkinen <jarkko@kernel.org>,
Jason Gunthorpe <jgg@ziepe.ca>,
Jerry Snitselaar <jsnitsel@redhat.com>,
linux-integrity@vger.kernel.org (open list:TPM DEVICE DRIVER),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] tpm: Fix barriers to prevent hwrng from activating during resume
Date: Mon, 3 Aug 2026 11:13:24 +0200 [thread overview]
Message-ID: <20260803092240.18348-2-fourier.thomas@gmail.com> (raw)
The memory barrier is placed after clearing the suspened flag so
memory reordering between the wake up and clearing the flag is allowed.
The reader of the flag is missing the corresponding barrier.
Clear the flag after the memory barrier and add a memory barrier in
the reader.
Fixes: 99d464506255 ("tpm: Prevent hwrng from activating during resume")
Cc: <stable@vger.kernel.org>
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
drivers/char/tpm/tpm-chip.c | 3 +++
drivers/char/tpm/tpm-interface.c | 3 +--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 12b7394b34bd..7f500797b7a7 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -173,6 +173,9 @@ int tpm_try_get_ops(struct tpm_chip *chip)
if (chip->flags & TPM_CHIP_FLAG_SUSPENDED)
goto out_lock;
+ /* Ensure that device is fully resumed */
+ rmb();
+
rc = tpm_chip_start(chip);
if (rc)
goto out_lock;
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index f745a098908b..2de12b02f62b 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -474,13 +474,12 @@ int tpm_pm_resume(struct device *dev)
if (chip == NULL)
return -ENODEV;
- chip->flags &= ~TPM_CHIP_FLAG_SUSPENDED;
-
/*
* Guarantee that SUSPENDED is written last, so that hwrng does not
* activate before the chip has been fully resumed.
*/
wmb();
+ chip->flags &= ~TPM_CHIP_FLAG_SUSPENDED;
return 0;
}
--
2.43.0
next reply other threads:[~2026-08-03 9:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 9:13 Thomas Fourier [this message]
2026-08-03 12:00 ` [PATCH] tpm: Fix barriers to prevent hwrng from activating during resume 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=20260803092240.18348-2-fourier.thomas@gmail.com \
--to=fourier.thomas@gmail.com \
--cc=jarkko@kernel.org \
--cc=jgg@ziepe.ca \
--cc=jsnitsel@redhat.com \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=stable@vger.kernel.org \
/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