Skip to content

Commit

Permalink
tpm: add vendor flag to command code validation
Browse files Browse the repository at this point in the history
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 <[email protected]>
Tested-by: Jarkko Sakkinen <[email protected]>
Reviewed-by: Jarkko Sakkinen <[email protected]>
Signed-off-by: Jarkko Sakkinen <[email protected]>
  • Loading branch information
gomesj authored and jarkkojs committed Feb 13, 2023
1 parent 1e2714b commit 85b93bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/char/tpm/tpm2-cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,10 +777,12 @@ int tpm2_auto_startup(struct tpm_chip *chip)

int tpm2_find_cc(struct tpm_chip *chip, u32 cc)
{
u32 cc_mask;
int i;

cc_mask = 1 << TPM2_CC_ATTR_VENDOR | GENMASK(15, 0);
for (i = 0; i < chip->nr_commands; i++)
if (cc == (chip->cc_attrs_tbl[i] & GENMASK(15, 0)))
if (cc == (chip->cc_attrs_tbl[i] & cc_mask))
return i;

return -1;
Expand Down
1 change: 1 addition & 0 deletions include/linux/tpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ enum tpm2_startup_types {
enum tpm2_cc_attrs {
TPM2_CC_ATTR_CHANDLES = 25,
TPM2_CC_ATTR_RHANDLE = 28,
TPM2_CC_ATTR_VENDOR = 29,
};

#define TPM_VID_INTEL 0x8086
Expand Down

0 comments on commit 85b93bb

Please sign in to comment.