Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Stefan Mahnke-Hartmann and committed by
Jarkko Sakkinen
e57b2523 e0687fe9

+10 -1
+10 -1
drivers/char/tpm/tpm2-cmd.c
··· 400 400 if (!rc) { 401 401 out = (struct tpm2_get_cap_out *) 402 402 &buf.data[TPM_HEADER_SIZE]; 403 - *value = be32_to_cpu(out->value); 403 + /* 404 + * To prevent failing boot up of some systems, Infineon TPM2.0 405 + * returns SUCCESS on TPM2_Startup in field upgrade mode. Also 406 + * the TPM2_Getcapability command returns a zero length list 407 + * in field upgrade mode. 408 + */ 409 + if (be32_to_cpu(out->property_cnt) > 0) 410 + *value = be32_to_cpu(out->value); 411 + else 412 + rc = -ENODATA; 404 413 } 405 414 tpm_buf_destroy(&buf); 406 415 return rc;