Skip to content

Commit 5933a19

Browse files
StMaHagregkh
authored andcommitted
tpm: Fix buffer access in tpm2_get_tpm_pt()
commit e57b252 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: 2ab3241 ("tpm: migrate tpm2_get_tpm_pt() to use struct tpm_buf") Cc: [email protected] Signed-off-by: Stefan Mahnke-Hartmann <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0c56e5d commit 5933a19

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Diff for: drivers/char/tpm/tpm2-cmd.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,16 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value,
400400
if (!rc) {
401401
out = (struct tpm2_get_cap_out *)
402402
&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;
404413
}
405414
tpm_buf_destroy(&buf);
406415
return rc;

0 commit comments

Comments
 (0)