summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArvind Sankar <nivedita@alum.mit.edu>2020-05-27 19:26:02 -0400
committerBorislav Petkov <bp@suse.de>2020-05-28 14:18:43 +0200
commite9524fb97ab5b41b85e1d3408f8e513433798f3c (patch)
tree36b2793b3aca5ca16f3d717e0ef3e7c05d14ee11
parentd1343da330f6ff3f40abf1f360d4701af784b85a (diff)
downloadlinux-e9524fb97ab5b41b85e1d3408f8e513433798f3c.tar.bz2
efi/x86: Don't blow away existing initrd
Commit 987053a30016 ("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: 987053a30016 ("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
-rw-r--r--drivers/firmware/efi/libstub/x86-stub.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index 99a0cfb0c7ad..5a48d996ed71 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -768,10 +768,12 @@ unsigned long efi_main(efi_handle_t handle,
efi_err("Failed to load initrd!\n");
goto fail;
}
- efi_set_u64_split(addr, &hdr->ramdisk_image,
- &boot_params->ext_ramdisk_image);
- efi_set_u64_split(size, &hdr->ramdisk_size,
- &boot_params->ext_ramdisk_size);
+ if (size > 0) {
+ efi_set_u64_split(addr, &hdr->ramdisk_image,
+ &boot_params->ext_ramdisk_image);
+ efi_set_u64_split(size, &hdr->ramdisk_size,
+ &boot_params->ext_ramdisk_size);
+ }
}
/*