]> git.baikalelectronics.ru Git - kernel.git/commit
efi/x86: Don't blow away existing initrd
authorArvind Sankar <nivedita@alum.mit.edu>
Wed, 27 May 2020 23:26:02 +0000 (19:26 -0400)
committerBorislav Petkov <bp@suse.de>
Thu, 28 May 2020 12:18:43 +0000 (14:18 +0200)
commit73933ac3eb7877cc4bfd8b3af2c5b5a6f6d7f968
tree36b2793b3aca5ca16f3d717e0ef3e7c05d14ee11
parentf8a75732211774829ac1ff591d6e1f58089479bc
efi/x86: Don't blow away existing initrd

Commit

  910097a1f600 ("efi/x86: Move command-line initrd loading to efi_main")

moved the command-line initrd loading into efi_main(), with a check
to ensure that it was attempted only if the EFI stub was booted via
efi_pe_entry rather than the EFI handover entry.

However, in the case where it was booted via handover entry, and thus an
initrd may have already been loaded by the bootloader, it then wrote 0
for the initrd address and size, removing any existing initrd.

Fix this by checking if size is positive before setting the fields in
the bootparams structure.

Fixes: 910097a1f600 ("efi/x86: Move command-line initrd loading to efi_main")
Reported-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lkml.kernel.org/r/20200527232602.21596-1-nivedita@alum.mit.edu
drivers/firmware/efi/libstub/x86-stub.c