OSDN Git Service

tpm: Fix buffer access in tpm2_get_tpm_pt()
authorStefan Mahnke-Hartmann <stefan.mahnke-hartmann@infineon.com>
Fri, 13 May 2022 13:41:51 +0000 (15:41 +0200)
committerJarkko Sakkinen <jarkko@kernel.org>
Mon, 23 May 2022 15:47:49 +0000 (18:47 +0300)
commite57b2523bd37e6434f4e64c7a685e3715ad21e9a
treebdf69a62db205486f29407390b3ccf984655bf35
parente0687fe958f763f1790f22ed5483025b7624e744
tpm: Fix buffer access in tpm2_get_tpm_pt()

Under certain conditions uninitialized memory will be accessed.
As described by TCG Trusted Platform Module Library Specification,
rev. 1.59 (Part 3: Commands), if a TPM2_GetCapability is received,
requesting a capability, the TPM in field upgrade mode may return a
zero length list.
Check the property count in tpm2_get_tpm_pt().

Fixes: 2ab3241161b3 ("tpm: migrate tpm2_get_tpm_pt() to use struct tpm_buf")
Cc: stable@vger.kernel.org
Signed-off-by: Stefan Mahnke-Hartmann <stefan.mahnke-hartmann@infineon.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
drivers/char/tpm/tpm2-cmd.c