Skip to content

Commit dc10e41

Browse files
robertosassuJarkko Sakkinen
authored andcommitted
tpm: Initialize crypto_id of allocated_banks to HASH_ALGO__LAST
chip->allocated_banks, an array of tpm_bank_info structures, contains the list of TPM algorithm IDs of allocated PCR banks. It also contains the corresponding ID of the crypto subsystem, so that users of the TPM driver can calculate a digest for a PCR extend operation. However, if there is no mapping between TPM algorithm ID and crypto ID, the crypto_id field of tpm_bank_info remains set to zero (the array is allocated and initialized with kcalloc() in tpm2_get_pcr_allocation()). Zero should not be used as value for unknown mappings, as it is a valid crypto ID (HASH_ALGO_MD4). Thus, initialize crypto_id to HASH_ALGO__LAST. Cc: [email protected] # 5.1.x Fixes: 879b589 ("tpm: retrieve digest size of unknown algorithms with PCR read") Signed-off-by: Roberto Sassu <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent faaca0a commit dc10e41

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/char/tpm/tpm2-cmd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ static int tpm2_init_bank_info(struct tpm_chip *chip, u32 bank_index)
525525
return 0;
526526
}
527527

528+
bank->crypto_id = HASH_ALGO__LAST;
529+
528530
return tpm2_pcr_read(chip, 0, &digest, &bank->digest_size);
529531
}
530532

0 commit comments

Comments
 (0)