CVE-2024-53085: tpm: Lock TPM chip in tpm_pm_suspend() first
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
tpm: Lock TPM chip in tpm_pm_suspend() first
Setting TPM_CHIP_FLAG_SUSPENDED in the end of tpm_pm_suspend() can be racy according, as this leaves window for tpm_hwrng_read() to be called while the operation is in progress. The recent bug report gives also evidence of this behaviour.
Aadress this by locking the TPM chip before checking any chip->flags both in tpm_pm_suspend() and tpm_hwrng_read(). Move TPM_CHIP_FLAG_SUSPENDED check inside tpm_get_random() so that it will be always checked only when the lock is reserved.
The Linux kernel CVE team has assigned CVE-2024-53085 to this issue.
Affected and fixed versions
===========================
Issue introduced in 6.4 with commit 99d464506255 and fixed in 6.11.8 with commit bc203fe416ab Issue introduced in 6.4 with commit 99d464506255 and fixed in 6.12 with commit 9265fed6db60 Issue introduced in 6.1.31 with commit 7cd46930b8bf Issue introduced in 6.3.5 with commit eeda114c92c7
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2024-53085
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/char/tpm/tpm-chip.c
drivers/char/tpm/tpm-interface.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/bc203fe416abdd1c29da594565a7c3c4e979488e https://git.kernel.org/stable/c/9265fed6db601ee2ec47577815387458ef4f047a