Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tpm: add vendor flag to command code validation

Some TPM 2.0 devices have support for additional commands which are not
part of the TPM 2.0 specifications.
These commands are identified with bit 29 of the 32 bits command codes.
Contrarily to other fields of the TPMA_CC spec structure used to list
available commands, the Vendor flag also has to be present in the
command code itself (TPM_CC) when called.

Add this flag to tpm_find_cc() mask to prevent blocking vendor command
codes that can actually be supported by the underlying TPM device.

Signed-off-by: Julien Gomes <julien@arista.com>
Tested-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>

authored by

Julien Gomes and committed by
Jarkko Sakkinen
85b93bbd 1e2714bb

+4 -1
+3 -1
drivers/char/tpm/tpm2-cmd.c
··· 777 777 778 778 int tpm2_find_cc(struct tpm_chip *chip, u32 cc) 779 779 { 780 + u32 cc_mask; 780 781 int i; 781 782 783 + cc_mask = 1 << TPM2_CC_ATTR_VENDOR | GENMASK(15, 0); 782 784 for (i = 0; i < chip->nr_commands; i++) 783 - if (cc == (chip->cc_attrs_tbl[i] & GENMASK(15, 0))) 785 + if (cc == (chip->cc_attrs_tbl[i] & cc_mask)) 784 786 return i; 785 787 786 788 return -1;
+1
include/linux/tpm.h
··· 265 265 enum tpm2_cc_attrs { 266 266 TPM2_CC_ATTR_CHANDLES = 25, 267 267 TPM2_CC_ATTR_RHANDLE = 28, 268 + TPM2_CC_ATTR_VENDOR = 29, 268 269 }; 269 270 270 271 #define TPM_VID_INTEL 0x8086