Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ecd237e authored by Stefan Mahnke-Hartmann's avatar Stefan Mahnke-Hartmann Committed by Greg Kroah-Hartman
Browse files

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: 2ab32411 ("tpm: migrate tpm2_get_tpm_pt() to use struct tpm_buf")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarStefan Mahnke-Hartmann <stefan.mahnke-hartmann@infineon.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 396d1f51
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -706,7 +706,16 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value,
	if (!rc) {
	if (!rc) {
		out = (struct tpm2_get_cap_out *)
		out = (struct tpm2_get_cap_out *)
			&buf.data[TPM_HEADER_SIZE];
			&buf.data[TPM_HEADER_SIZE];
		/*
		 * 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);
			*value = be32_to_cpu(out->value);
		else
			rc = -ENODATA;
	}
	}
	tpm_buf_destroy(&buf);
	tpm_buf_destroy(&buf);
	return rc;
	return rc;