]> www.infradead.org Git - linux.git/commit
tpm: fix signed/unsigned bug when checking event logs
authorGregory Price <gourry@gourry.net>
Fri, 13 Sep 2024 23:19:51 +0000 (19:19 -0400)
committerArd Biesheuvel <ardb@kernel.org>
Tue, 15 Oct 2024 18:27:29 +0000 (20:27 +0200)
commite6d654e9f5a97742cfe794b1c4bb5d3fb2d25e98
treeb87836391d58966792aa1a107604c0f8d6450ddf
parentc004703ed7ae6be30ee7dcb37801bda4c6a24c3b
tpm: fix signed/unsigned bug when checking event logs

A prior bugfix that fixes a signed/unsigned error causes
another signed unsigned error.

A situation where log_tbl->size is invalid can cause the
size passed to memblock_reserve to become negative.

log_size from the main event log is an unsigned int, and
the code reduces to the following

u64 value = (int)unsigned_value;

This results in sign extension, and the value sent to
memblock_reserve becomes effectively negative.

Fixes: be59d57f9806 ("efi/tpm: Fix sanity check of unsigned tbl_size being less than zero")
Signed-off-by: Gregory Price <gourry@gourry.net>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/tpm.c