summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Mahnke-Hartmann <stefan.mahnke-hartmann@infineon.com>2022-05-13 15:41:51 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-06 08:24:22 +0200
commitda6e23e16a27a3c0cc6652034f2f2c10e2533b54 (patch)
tree4694c1fb1cf38eb0a78176bbf100cb0f866ba747
parentabee62676f9eac066077b9ee56055c42417dc756 (diff)
downloadlinux-stable-da6e23e16a27a3c0cc6652034f2f2c10e2533b54.tar.gz
linux-stable-da6e23e16a27a3c0cc6652034f2f2c10e2533b54.tar.bz2
linux-stable-da6e23e16a27a3c0cc6652034f2f2c10e2533b54.zip
tpm: Fix buffer access in tpm2_get_tpm_pt()
commit e57b2523bd37e6434f4e64c7a685e3715ad21e9a upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/char/tpm/tpm2-cmd.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index e71c6b24aed1..ce497b0691d7 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -717,7 +717,16 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value,
if (!rc) {
out = (struct tpm2_get_cap_out *)
&buf.data[TPM_HEADER_SIZE];
- *value = be32_to_cpu(out->value);
+ /*
+ * To prevent failing boot up of some systems, Infineon TPM2.0
+ * returns SUCCESS on TPM2_Startup in field upgrade mode. Also
+ * the TPM2_Getcapability command returns a zero length list
+ * in field upgrade mode.
+ */
+ if (be32_to_cpu(out->property_cnt) > 0)
+ *value = be32_to_cpu(out->value);
+ else
+ rc = -ENODATA;
}
tpm_buf_destroy(&buf);
return rc;