• Ard Biesheuvel's avatar
    x86/efistub: Clear BSS in EFI handover protocol entrypoint · d7156b98
    Ard Biesheuvel authored
    
    
    The so-called EFI handover protocol is value-add from the distros that
    permits a loader to simply copy a PE kernel image into memory and call
    an alternative entrypoint that is described by an embedded boot_params
    structure.
    
    Most implementations of this protocol do not bother to check the PE
    header for minimum alignment, section placement, etc, and therefore also
    don't clear the image's BSS, or even allocate enough memory for it.
    
    Allocating more memory on the fly is rather difficult, but at least
    clear the BSS region explicitly when entering in this manner, so that
    the EFI stub code does not get confused by global variables that were
    not zero-initialized correctly.
    
    When booting in mixed mode, this BSS clearing must occur before any
    global state is created, so clear it in the 32-bit asm entry point.
    Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
    Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/20230807162720.545787-7-ardb@kernel.org
    d7156b98
efi_mixed.S 9.55 KB