]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/efistub: Don't clear BSS twice in mixed mode
authorArd Biesheuvel <ardb@kernel.org>
Fri, 22 Mar 2024 16:01:45 +0000 (17:01 +0100)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:20:13 +0000 (18:20 -0400)
commit5ad5dcfd7543d8478878a04dfbf638bd4aa39b81
tree47bba40db6f091003a7c09dbaa04d9b31ee88646
parentae863aa18493d287c96de239d7b4ee3e5e977ce2
x86/efistub: Don't clear BSS twice in mixed mode

[ Upstream commit df7ecce842b846a04d087ba85fdb79a90e26a1b0 ]

Clearing BSS should only be done once, at the very beginning.
efi_pe_entry() is the entrypoint from the firmware, which may not clear
BSS and so it is done explicitly. However, efi_pe_entry() is also used
as an entrypoint by the mixed mode startup code, in which case BSS will
already have been cleared, and doing it again at this point will corrupt
global variables holding the firmware's GDT/IDT and segment selectors.

So make the memset() conditional on whether the EFI stub is running in
native mode.

Fixes: b3810c5a2cc4a666 ("x86/efistub: Clear decompressor BSS in native EFI entrypoint")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/efi/libstub/x86-stub.c