]> git.baikalelectronics.ru Git - kernel.git/commit
tpm: Initialize crypto_id of allocated_banks to HASH_ALGO__LAST
authorRoberto Sassu <roberto.sassu@huawei.com>
Mon, 10 Feb 2020 10:00:41 +0000 (11:00 +0100)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Mon, 17 Feb 2020 18:47:06 +0000 (20:47 +0200)
commit9dda2af07e406bab26361ac3451135cfb3abfc6d
treeff3e92c4637bc033c146c962511465832ac918aa
parent18dcb2a2206962d1d5bf1ecb95f5f1b110bfe407
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: stable@vger.kernel.org # 5.1.x
Fixes: 7f75681c9bba ("tpm: retrieve digest size of unknown algorithms with PCR read")
Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
drivers/char/tpm/tpm2-cmd.c