]> git.baikalelectronics.ru Git - kernel.git/commit
efi/x86: Always relocate the kernel for EFI handover entry
authorArvind Sankar <nivedita@alum.mit.edu>
Thu, 9 Apr 2020 13:04:29 +0000 (15:04 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 14 Apr 2020 06:32:13 +0000 (08:32 +0200)
commit8265717e6f7be418adc1b9c7ec3adc1a20a15a71
tree11bb5e67b5cef831600784ae65b614b6582c0dc4
parent7094cf079e5ee8d331f7550eb8acc590a5994ded
efi/x86: Always relocate the kernel for EFI handover entry

Commit

  2d90a58130a7 ("efi/x86: Don't relocate the kernel unless necessary")

tries to avoid relocating the kernel in the EFI stub as far as possible.

However, when systemd-boot is used to boot a unified kernel image [1],
the image is constructed by embedding the bzImage as a .linux section in
a PE executable that contains a small stub loader from systemd that will
call the EFI stub handover entry, together with additional sections and
potentially an initrd. When this image is constructed, by for example
dracut, the initrd is placed after the bzImage without ensuring that at
least init_size bytes are available for the bzImage. If the kernel is
not relocated by the EFI stub, this could result in the compressed
kernel's startup code in head_{32,64}.S overwriting the initrd.

To prevent this, unconditionally relocate the kernel if the EFI stub was
entered via the handover entry point.

[1] https://systemd.io/BOOT_LOADER_SPECIFICATION/#type-2-efi-unified-kernel-images

Fixes: 2d90a58130a7 ("efi/x86: Don't relocate the kernel unless necessary")
Reported-by: Sergey Shatunov <me@prok.pw>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20200406180614.429454-2-nivedita@alum.mit.edu
Link: https://lore.kernel.org/r/20200409130434.6736-5-ardb@kernel.org
drivers/firmware/efi/libstub/x86-stub.c