]> git.hungrycats.org Git - linux/commit
firmware: google: Add bounds checks in coreboot_table_populate()
authorTitouan Ameline de Cadeville <titouan.ameline@gmail.com>
Sun, 26 Apr 2026 21:47:39 +0000 (23:47 +0200)
committerTzung-Bi Shih <tzungbi@kernel.org>
Tue, 28 Apr 2026 02:30:10 +0000 (02:30 +0000)
commit7b1a1af4556a4f95ef273e91435fe804cbfcd223
tree1d1fee8419db775468293aff6dbe8f8ecd6044ad
parent254f49634ee16a731174d2ae34bc50bd5f45e731
firmware: google: Add bounds checks in coreboot_table_populate()

coreboot_table_populate() iterates over firmware-provided table entries
with no validation that the entries stay within the mapped memory
region.  A corrupt table with a large `entry->size` advances `ptr_entry`
past the mapped region, causing an out-of-bounds read on the next
iteration.

Add a check before dereferencing `ptr_entry` to ensure the entry header
is readable, and a second check after reading `entry->size` to ensure
the full entry stays within the mapped region.

Pass `len` from coreboot_table_probe() into coreboot_table_populate() to
make the mapped region size available for validation.

Signed-off-by: Titouan Ameline de Cadeville <titouan.ameline@gmail.com>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Link: https://lore.kernel.org/r/20260426214739.117131-1-titouan.ameline@gmail.com
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
drivers/firmware/google/coreboot_table.c