mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
tpm: Fix heap buffer overflow in tpm_transmit_cmd()
struct tpm_buf now uses an embedded flexible array for data, which is
6 bytes shorter than TPM_BUFSIZE due to the struct header. But
tpm_transmit_cmd() still passes PAGE_SIZE to tpm_transmit(), and after
clamping to TPM_BUFSIZE in tpm_try_transmit(), chip->ops->recv() can
write past the end of data[] by 6 bytes.
Pass buf->capacity to tpm_transmit() instead.
Fixes: 3d9e043dab ("tpm-buf: Memory-safe allocations")
Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
Link: https://lore.kernel.org/r/20260901062850.379870-1-yijiangshan@kylinos.cn
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
This commit is contained in:
parent
6f8319e3e9
commit
1a70f0b718
|
|
@ -268,7 +268,7 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf,
|
|||
int err;
|
||||
ssize_t len;
|
||||
|
||||
len = tpm_transmit(chip, buf->data, PAGE_SIZE);
|
||||
len = tpm_transmit(chip, buf->data, buf->capacity);
|
||||
if (len < 0)
|
||||
return len;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user