tpm: Prevent hwrng from activating during resume
authorJarkko Sakkinen <jarkko@kernel.org>
Wed, 26 Apr 2023 17:29:28 +0000 (20:29 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 May 2023 13:03:16 +0000 (14:03 +0100)
commit7cd46930b8bf37b84777410ac21bfdf1179021d5
treec453feb0fe67e32e194e6291d6f029751df5a2c8
parent25d38d5eaa1f7a4d8075d23633f1722b38c8c7a7
tpm: Prevent hwrng from activating during resume

[ Upstream commit 99d46450625590d410f86fe4660a5eff7d3b8343 ]

Set TPM_CHIP_FLAG_SUSPENDED in tpm_pm_suspend() and reset in
tpm_pm_resume(). While the flag is set, tpm_hwrng() gives back zero
bytes. This prevents hwrng from racing during resume.

Cc: stable@vger.kernel.org
Fixes: 6e592a065d51 ("tpm: Move Linux RNG connection to hwrng")
Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/tpm/tpm-chip.c
drivers/char/tpm/tpm-interface.c
include/linux/tpm.h