lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220506123145.229058-1-stefan.mahnke-hartmann@infineon.com>
Date:   Fri, 6 May 2022 14:31:46 +0200
From:   Stefan Mahnke-Hartmann <stefan.mahnke-hartmann@...ineon.com>
To:     <jarkko@...nel.org>, <linux-integrity@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
CC:     <Marten.Lindahl@...s.com>, <martenli@...s.com>, <jgg@...pe.ca>,
        <jsnitsel@...hat.com>, <nayna@...ux.vnet.ibm.com>,
        <johannes.holland@...ineon.com>, <peterhuewe@....de>,
        Stefan Mahnke-Hartmann <stefan.mahnke-hartmann@...ineon.com>,
        <stable@...r.kernel.org>
Subject: [PATCH 1/2] 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@...r.kernel.org
Signed-off-by: Stefan Mahnke-Hartmann <stefan.mahnke-hartmann@...ineon.com>
---
 drivers/char/tpm/tpm2-cmd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 4704fa553098..e62a644ce26b 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -400,7 +400,10 @@ 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);
+		if (be32_to_cpu(out->property_cnt) > 0)
+			*value = be32_to_cpu(out->value);
+		else
+			rc = -ENODATA;
 	}
 	tpm_buf_destroy(&buf);
 	return rc;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ