summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJarkko Sakkinen <jarkko.sakkinen@opinsys.com>2025-12-29 19:38:42 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-01-19 13:12:03 +0100
commit8ceee7288152bc121a6bf92997261838c78bfe06 (patch)
treedaf682d4b214f4fa39cca02a63e66c28c1898646 /include
parent9f48638b2f7e5e8393e061b21e66ebfb3a4bca49 (diff)
tpm: Cap the number of PCR banks
[ Upstream commit faf07e611dfa464b201223a7253e9dc5ee0f3c9e ] tpm2_get_pcr_allocation() does not cap any upper limit for the number of banks. Cap the limit to eight banks so that out of bounds values coming from external I/O cause on only limited harm. Cc: stable@vger.kernel.org # v5.10+ Fixes: bcfff8384f6c ("tpm: dynamically allocate the allocated_banks array") Tested-by: Lai Yi <yi1.lai@linux.intel.com> Reviewed-by: Jonathan McDowell <noodles@meta.com> Reviewed-by: Roberto Sassu <roberto.sassu@huawei.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@opinsys.com> [ added backward-compatible define for TPM_MAX_DIGEST_SIZE to support older ima_init.c code still using that macro name ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/tpm.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index 7868e847eee0..6d9d90f01b63 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -25,7 +25,10 @@
#include <crypto/hash_info.h>
#define TPM_DIGEST_SIZE 20 /* Max TPM v1.2 PCR size */
-#define TPM_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE
+
+#define TPM2_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE
+#define TPM2_MAX_PCR_BANKS 8
+#define TPM_MAX_DIGEST_SIZE TPM2_MAX_DIGEST_SIZE
struct tpm_chip;
struct trusted_key_payload;
@@ -44,7 +47,7 @@ enum tpm_algorithms {
struct tpm_digest {
u16 alg_id;
- u8 digest[TPM_MAX_DIGEST_SIZE];
+ u8 digest[TPM2_MAX_DIGEST_SIZE];
} __packed;
struct tpm_bank_info {
@@ -150,7 +153,7 @@ struct tpm_chip {
unsigned int groups_cnt;
u32 nr_allocated_banks;
- struct tpm_bank_info *allocated_banks;
+ struct tpm_bank_info allocated_banks[TPM2_MAX_PCR_BANKS];
#ifdef CONFIG_ACPI
acpi_handle acpi_dev_handle;
char ppi_version[TPM_PPI_VERSION_LEN + 1];