* Re: [PATCH] hwrng: tpm: Do not enable by default [not found] ` <96df7b4d-cf1b-471d-9b4b-8741a80fbcc3@siemens.com> @ 2026-05-09 15:18 ` Jarkko Sakkinen 2026-05-10 20:42 ` Jan Kiszka 0 siblings, 1 reply; 3+ messages in thread From: Jarkko Sakkinen @ 2026-05-09 15:18 UTC (permalink / raw) To: Niedermayr, BENEDIKT Cc: Kiszka, Jan, Peter Huewe, linux-integrity@vger.kernel.org, Linux Kernel Mailing List, Ilias Apalodimas, Jens Wiklander, OP-TEE TrustedFirmware, linux-crypto@vger.kernel.org, Bauer, Sven, Zeschg, Thomas, Gylstorff, Quirin On Wed, Apr 29, 2026 at 02:33:20PM +0000, Niedermayr, BENEDIKT wrote: > On 10/27/25 20:51, Jarkko Sakkinen wrote: > > On Tue, Oct 21, 2025 at 02:46:15PM +0200, Jan Kiszka wrote: > >> From: Jan Kiszka <jan.kiszka@siemens.com> > >> > >> As seen with optee_ftpm, which uses ms-tpm-20-ref [1], a TPM may write > >> the current time epoch to its NV storage every 4 seconds if there are > >> commands sent to it. The 60 seconds periodic update of the entropy pool > >> that the hwrng kthread does triggers this, causing about 4 writes per > >> requests. Makes 2 millions per year for a 24/7 device, and that is a lot > >> for its backing NV storage. > >> > >> It is therefore better to make the user intentionally enable this, > >> providing a chance to read the warning. > >> > >> [1] https://github.com/Microsoft/ms-tpm-20-ref > >> > >> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> > > > > Looking at DRBG_* from [1] I don't see anything you describe. If OPTEE > > writes NVRAM, then the implementation is broken. > > > > Also AFAIK, it is pre-seeded per power cycle. There's nothing that even > > distantly relates on using NVRAM. > > > > [1] https://trustedcomputinggroup.org/wp-content/uploads/TPM-2.0-1.83-Part-4-Supporting-Routines-Code.pdf > > Hi all, > > we recently also stumbled over this issue which led me here to this > thread and maybe adding our observations helps to clarify things here a > bit (hopefully) or at least augments the information related to firmware > TPM based implementation based on ms-tpm-20-ref. > > Based on the optee_ftpm repo, as Jan already described, which currently > references commit 98b60a44aba7 of [1] suffers this exact issue because > of the NV_CLOCK_UPDATE_INTERVAL [2] which is set to "12" and issues a > write for each command after ~4 seconds have passed. > > This config has been changed to "22" (on current master branch [3]) > which is the allowed maximum when following the TPM spec (chapter 36.3.2 > in [4]) which leads to round about 70 minutes, but optee_ftpm didn't > move ahead to this commit, yet. > This config exists for being able to adapt the write cycles to the > specific wear conditions of the hardware. > > Moreover the ms-tpm-20-ref repo seems to not be maintained anymore and > one should rather switch to [6]. > > So there are currently firmware TPM implementations out there that lead > to these frequent writes. Really this would need a product and official bug bulletin for it to even consider a workaround. Speculation does not count. > > AFAIK since the tpm-20-ref implementation basically only supports a file > on disk or RAM backing storage, the optee_ftpm repo [5] provides it's > own _plat_NV* implementations that replace the default ones and finally > call OP-TEE's TEE_* secure storage API, which then routes to whatever > backend OP-TEE is configured with (REE-FS or RPMB) – In our case the RPMB. > > Because there are currently implementations out there (e.g. start using > optee_ftpm) it may make sense to add this information to the kernel > config's help text at least? Your first forum to report such issues is the TPM vendor. > > We are currently trying to bump optee_ftpm to use the more recent v1.84, > but since we're no TCG member the PRs on github could get a bit > adventurous (PR's not upstream, yet). > Until then this is a valid issue that exists... > > > [2] > https://github.com/microsoft/ms-tpm-20-ref/blob/98b60a44aba79b15fcce1c0d1e46cf5918400f6a/TPMCmd/tpm/include/TpmProfile.h#L199 > > > [3] > https://github.com/microsoft/ms-tpm-20-ref/blob/98b60a44aba79b15fcce1c0d1e46cf5918400f6a/TPMCmd/tpm/include/TpmProfile.h#L200 > > [4] > https://trustedcomputinggroup.org/wp-content/uploads/TPM-2.0-1.83-Part-1-Architecture.pdf > > [5] https://github.com/OP-TEE/optee_ftpm > > [6] https://github.com/TrustedComputingGroup/TPM > > BR, > Benedikt > BR, Jarkko ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwrng: tpm: Do not enable by default 2026-05-09 15:18 ` [PATCH] hwrng: tpm: Do not enable by default Jarkko Sakkinen @ 2026-05-10 20:42 ` Jan Kiszka 2026-05-11 3:31 ` James Bottomley 0 siblings, 1 reply; 3+ messages in thread From: Jan Kiszka @ 2026-05-10 20:42 UTC (permalink / raw) To: Jarkko Sakkinen, Niedermayr, BENEDIKT Cc: Peter Huewe, linux-integrity@vger.kernel.org, Linux Kernel Mailing List, Ilias Apalodimas, Jens Wiklander, OP-TEE TrustedFirmware, linux-crypto@vger.kernel.org, Bauer, Sven, Zeschg, Thomas, Gylstorff, Quirin On 09.05.26 17:18, Jarkko Sakkinen wrote: > On Wed, Apr 29, 2026 at 02:33:20PM +0000, Niedermayr, BENEDIKT wrote: >> On 10/27/25 20:51, Jarkko Sakkinen wrote: >>> On Tue, Oct 21, 2025 at 02:46:15PM +0200, Jan Kiszka wrote: >>>> From: Jan Kiszka <jan.kiszka@siemens.com> >>>> >>>> As seen with optee_ftpm, which uses ms-tpm-20-ref [1], a TPM may write >>>> the current time epoch to its NV storage every 4 seconds if there are >>>> commands sent to it. The 60 seconds periodic update of the entropy pool >>>> that the hwrng kthread does triggers this, causing about 4 writes per >>>> requests. Makes 2 millions per year for a 24/7 device, and that is a lot >>>> for its backing NV storage. >>>> >>>> It is therefore better to make the user intentionally enable this, >>>> providing a chance to read the warning. >>>> >>>> [1] https://github.com/Microsoft/ms-tpm-20-ref >>>> >>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> >>> >>> Looking at DRBG_* from [1] I don't see anything you describe. If OPTEE >>> writes NVRAM, then the implementation is broken. >>> >>> Also AFAIK, it is pre-seeded per power cycle. There's nothing that even >>> distantly relates on using NVRAM. >>> >>> [1] https://trustedcomputinggroup.org/wp-content/uploads/TPM-2.0-1.83-Part-4-Supporting-Routines-Code.pdf >> >> Hi all, >> >> we recently also stumbled over this issue which led me here to this >> thread and maybe adding our observations helps to clarify things here a >> bit (hopefully) or at least augments the information related to firmware >> TPM based implementation based on ms-tpm-20-ref. >> >> Based on the optee_ftpm repo, as Jan already described, which currently >> references commit 98b60a44aba7 of [1] suffers this exact issue because >> of the NV_CLOCK_UPDATE_INTERVAL [2] which is set to "12" and issues a >> write for each command after ~4 seconds have passed. >> >> This config has been changed to "22" (on current master branch [3]) >> which is the allowed maximum when following the TPM spec (chapter 36.3.2 >> in [4]) which leads to round about 70 minutes, but optee_ftpm didn't >> move ahead to this commit, yet. >> This config exists for being able to adapt the write cycles to the >> specific wear conditions of the hardware. >> >> Moreover the ms-tpm-20-ref repo seems to not be maintained anymore and >> one should rather switch to [6]. >> >> So there are currently firmware TPM implementations out there that lead >> to these frequent writes. > > Really this would need a product and official bug bulletin for it to > even consider a workaround. Speculation does not count. > The key point Benedikt tries to make here is that the TPM 2 spec forces any vendor to do something about persisting the last seen time at least every 70 min. If they didn't do that, then they would violate the space - arguably a bug. But, correct, it does not tell us anything about how this happens in a random firmware TPM implementation. >> >> AFAIK since the tpm-20-ref implementation basically only supports a file >> on disk or RAM backing storage, the optee_ftpm repo [5] provides it's >> own _plat_NV* implementations that replace the default ones and finally >> call OP-TEE's TEE_* secure storage API, which then routes to whatever >> backend OP-TEE is configured with (REE-FS or RPMB) – In our case the RPMB. >> >> Because there are currently implementations out there (e.g. start using >> optee_ftpm) it may make sense to add this information to the kernel >> config's help text at least? > > Your first forum to report such issues is the TPM vendor. I would still not recommend anyone relying on a firmware TPM to turn on CONFIG_HW_RANDOM_TPM if there are viable alternatives. In case of the open source stack with optee_os + optee_ftpm, we know that at least one exists: CONFIG_HW_RANDOM_OPTEE. So, if there is no good place to document this in the kernel, maybe it is worth to document it in optee_ftpm instead. Jan -- Siemens AG, Foundational Technologies Linux Expert Center ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwrng: tpm: Do not enable by default 2026-05-10 20:42 ` Jan Kiszka @ 2026-05-11 3:31 ` James Bottomley 0 siblings, 0 replies; 3+ messages in thread From: James Bottomley @ 2026-05-11 3:31 UTC (permalink / raw) To: Jan Kiszka, Jarkko Sakkinen, Niedermayr, BENEDIKT Cc: Peter Huewe, linux-integrity@vger.kernel.org, Linux Kernel Mailing List, Ilias Apalodimas, Jens Wiklander, OP-TEE TrustedFirmware, linux-crypto@vger.kernel.org, Bauer, Sven, Zeschg, Thomas, Gylstorff, Quirin On Sun, 2026-05-10 at 22:42 +0200, Jan Kiszka wrote: > On 09.05.26 17:18, Jarkko Sakkinen wrote: > > On Wed, Apr 29, 2026 at 02:33:20PM +0000, Niedermayr, BENEDIKT > > wrote: > > > On 10/27/25 20:51, Jarkko Sakkinen wrote: > > > > On Tue, Oct 21, 2025 at 02:46:15PM +0200, Jan Kiszka wrote: > > > > > From: Jan Kiszka <jan.kiszka@siemens.com> > > > > > > > > > > As seen with optee_ftpm, which uses ms-tpm-20-ref [1], a TPM > > > > > may write the current time epoch to its NV storage every 4 > > > > > seconds if there are commands sent to it. The 60 seconds > > > > > periodic update of the entropy pool that the hwrng kthread > > > > > does triggers this, causing about 4 writes per requests. > > > > > Makes 2 millions per year for a 24/7 device, and that is a > > > > > lot for its backing NV storage. > > > > > > > > > > It is therefore better to make the user intentionally enable > > > > > this, providing a chance to read the warning. > > > > > > > > > > [1] https://github.com/Microsoft/ms-tpm-20-ref > > > > > > > > > > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> > > > > > > > > Looking at DRBG_* from [1] I don't see anything you describe. > > > > If OPTEE writes NVRAM, then the implementation is broken. > > > > > > > > Also AFAIK, it is pre-seeded per power cycle. There's nothing > > > > that even distantly relates on using NVRAM. > > > > > > > > [1] > > > > https://trustedcomputinggroup.org/wp-content/uploads/TPM-2.0-1.83-Part-4-Supporting-Routines-Code.pdf > > > > > > Hi all, > > > > > > we recently also stumbled over this issue which led me here to > > > this thread and maybe adding our observations helps to clarify > > > things here a bit (hopefully) or at least augments the > > > information related to firmware TPM based implementation based on > > > ms-tpm-20-ref. > > > > > > Based on the optee_ftpm repo, as Jan already described, which > > > currently references commit 98b60a44aba7 of [1] suffers this > > > exact issue because of the NV_CLOCK_UPDATE_INTERVAL [2] which is > > > set to "12" and issues a write for each command after ~4 seconds > > > have passed. You keep quoting this to us, and other parts of the spec. However, you forgot to quote from the Section 7 compliance statement in the same spec which says: the NV subsystem of the reference implementation is not representative of the actual implementation of most physical NV implementations but is a crude analog. I get that the the optee people failed to realize this and only just corrected the mistake, but the fact is that all other TPM implementations, both physical and firmware don't have this wear problem you've given yourselves because they noticed. > > > This config has been changed to "22" (on current master branch > > > [3]) which is the allowed maximum when following the TPM spec > > > (chapter 36.3.2 in [4]) which leads to round about 70 minutes, > > > but optee_ftpm didn't move ahead to this commit, yet. > > > This config exists for being able to adapt the write cycles to > > > the specific wear conditions of the hardware. > > > > > > Moreover the ms-tpm-20-ref repo seems to not be maintained > > > anymore and one should rather switch to [6]. > > > > > > So there are currently firmware TPM implementations out there > > > that lead to these frequent writes. Yours is the only one I've ever come across. > > Really this would need a product and official bug bulletin for it > > to even consider a workaround. Speculation does not count. > > > > The key point Benedikt tries to make here is that the TPM 2 spec > forces any vendor to do something about persisting the last seen time > at least every 70 min. If they didn't do that, then they would > violate the space That's correct, but a red herring: if the optee TPM had done this 70 minute flush ab initio you wouldn't have the wear problem because the seed writes would be much less frequent. > - arguably a bug. Well, not following the spec is a bug, yes, but it's not a bug in the kernel ... Regards, James ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-11 3:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <bbc41534-a2d9-42dc-ac8a-ff8a0b4fd41f@siemens.com>
[not found] ` <aP_NN3HwO4Hp0-9T@kernel.org>
[not found] ` <96df7b4d-cf1b-471d-9b4b-8741a80fbcc3@siemens.com>
2026-05-09 15:18 ` [PATCH] hwrng: tpm: Do not enable by default Jarkko Sakkinen
2026-05-10 20:42 ` Jan Kiszka
2026-05-11 3:31 ` James Bottomley
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox