]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
efi/libstub/x86: Avoid overflowing code32_start on PE entry
authorArd Biesheuvel <ardb@kernel.org>
Mon, 10 Feb 2020 16:02:31 +0000 (17:02 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Sat, 22 Feb 2020 22:37:37 +0000 (23:37 +0100)
commit04a7d0e15606769ef58d5cee912c5d08d93ded92
tree55df0d0cad3812a146ddd4407e51263a2978c4de
parente6d832ea9ac63316ee72df5e9f21698cfd486698
efi/libstub/x86: Avoid overflowing code32_start on PE entry

When using the native PE entry point (as opposed to the EFI handover
protocol entry point that is used more widely), we set code32_start,
which is a 32-bit wide field, to the effective symbol address of
startup_32, which could overflow given that the EFI loader may have
located the running image anywhere in memory, and we haven't reached
the point yet where we relocate ourselves.

Since we relocate ourselves if code32_start != pref_address, this
isn't likely to lead to problems in practice, given how unlikely
it is that the truncated effective address of startup_32 happens
to equal pref_address. But it is better to defer the assignment
of code32_start to after the relocation, when it is guaranteed to
fit.

While at it, move the call to efi_relocate_kernel() to an earlier
stage so it is more likely that our preferred offset in memory has
not been occupied by other memory allocations done in the mean time.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
arch/x86/boot/compressed/eboot.c