tpm_tis_spi: Account for SPI header when allocating TPM SPI xfer buffer
authorMatthew R. Ochs <mochs@nvidia.com>
Wed, 22 May 2024 12:06:40 +0000 (15:06 +0300)
committerJarkko Sakkinen <jarkko@kernel.org>
Tue, 28 May 2024 10:03:57 +0000 (13:03 +0300)
commit195aba96b854dd664768f382cd1db375d8181f88
tree696d793032d6c1268ed7084e83674838248ce44d
parent2bfcfd584ff5ccc8bb7acde19b42570414bf880b
tpm_tis_spi: Account for SPI header when allocating TPM SPI xfer buffer

The TPM SPI transfer mechanism uses MAX_SPI_FRAMESIZE for computing the
maximum transfer length and the size of the transfer buffer. As such, it
does not account for the 4 bytes of header that prepends the SPI data
frame. This can result in out-of-bounds accesses and was confirmed with
KASAN.

Introduce SPI_HDRSIZE to account for the header and use to allocate the
transfer buffer.

Fixes: a86a42ac2bd6 ("tpm_tis_spi: Add hardware wait polling")
Signed-off-by: Matthew R. Ochs <mochs@nvidia.com>
Tested-by: Carol Soto <csoto@nvidia.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
drivers/char/tpm/tpm_tis_spi_main.c