stub: allocate and zero enough space in legacy x86 handover protocol
authorLuca Boccassi <bluca@debian.org>
Wed, 31 Jul 2024 00:45:06 +0000 (01:45 +0100)
committerLuca Boccassi <bluca@debian.org>
Wed, 31 Jul 2024 00:46:25 +0000 (01:46 +0100)
commit19812661f1f65ebe777d1626b5abf6475faababc
tree5bdebec89f88a196542b02aa34ac84df52a0be12
parent7767896d127264f660e1e8a714e5cd760840921f
stub: allocate and zero enough space in legacy x86 handover protocol

A PE image's memory footprint might be larger than its file size due
to uninitialized memory sections. Normally all PE headers should be
parsed to check the actual required size, but the legacy EFI handover
protocol is only used for x86 Linux bzImages, so we know only the last
section will require extra memory. Use SizeOfImage from the PE header
and if it is larger than the file size, allocate and zero extra memory
before using it.

Fixes https://github.com/systemd/systemd/issues/33816
src/boot/efi/boot.c
src/boot/efi/linux.c
src/boot/efi/linux.h
src/boot/efi/linux_x86.c
src/boot/efi/pe.c
src/boot/efi/pe.h