]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:50:47 +0000 (19:50 +0100)
commit8d1e8505859f491ed205c74aa4f86004db3590df
tree95796ab887c0db2ca34d298d050f78f4ff0085a7
parent2d88cf062b865ab57dc5ff36929c0306b6d0209f
tpm: fix signed/unsigned bug when checking event logs

[ Upstream commit e6d654e9f5a97742cfe794b1c4bb5d3fb2d25e98 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/efi/tpm.c