summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorJarkko Sakkinen <jarkko.sakkinen@opinsys.com>2025-09-30 15:58:02 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-01-08 12:14:15 +0300
commitb69492161c056d36789aee42a87a33c18c8ed5e1 (patch)
treebd1c71d8ca0f4d75b3b7cdea9f6bdadfbc18aac5 /include/linux
parent4d1c44cd98231d2fefcbc9bb75f8e4b4323beab3 (diff)
downloadlinux-b69492161c056d36789aee42a87a33c18c8ed5e1.tar.xz
tpm: Cap the number of PCR banks
commit faf07e611dfa464b201223a7253e9dc5ee0f3c9e upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/tpm.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index a3d8305e88a5..117e0f620d52 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -26,7 +26,9 @@
#include <crypto/aes.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
struct tpm_chip;
struct trusted_key_payload;
@@ -68,7 +70,7 @@ enum tpm2_curves {
struct tpm_digest {
u16 alg_id;
- u8 digest[TPM_MAX_DIGEST_SIZE];
+ u8 digest[TPM2_MAX_DIGEST_SIZE];
} __packed;
struct tpm_bank_info {
@@ -188,7 +190,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];