Commit 54993156 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'efi-fixes-for-v6.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi

Pull EFI fix from Ard Biesheuvel:

 - Followup fix for the EFI boot sequence refactor, which may result in
   physical KASLR putting the kernel in a region which is being used for
   a special purpose via a command line argument.

* tag 'efi-fixes-for-v6.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi:
  x86/efistub: Omit physical KASLR when memory reservations exist
parents 85672639 15aa8fb8
...@@ -776,6 +776,26 @@ static void error(char *str) ...@@ -776,6 +776,26 @@ static void error(char *str)
efi_warn("Decompression failed: %s\n", str); efi_warn("Decompression failed: %s\n", str);
} }
static const char *cmdline_memmap_override;
static efi_status_t parse_options(const char *cmdline)
{
static const char opts[][14] = {
"mem=", "memmap=", "efi_fake_mem=", "hugepages="
};
for (int i = 0; i < ARRAY_SIZE(opts); i++) {
const char *p = strstr(cmdline, opts[i]);
if (p == cmdline || (p > cmdline && isspace(p[-1]))) {
cmdline_memmap_override = opts[i];
break;
}
}
return efi_parse_options(cmdline);
}
static efi_status_t efi_decompress_kernel(unsigned long *kernel_entry) static efi_status_t efi_decompress_kernel(unsigned long *kernel_entry)
{ {
unsigned long virt_addr = LOAD_PHYSICAL_ADDR; unsigned long virt_addr = LOAD_PHYSICAL_ADDR;
...@@ -807,6 +827,10 @@ static efi_status_t efi_decompress_kernel(unsigned long *kernel_entry) ...@@ -807,6 +827,10 @@ static efi_status_t efi_decompress_kernel(unsigned long *kernel_entry)
!memcmp(efistub_fw_vendor(), ami, sizeof(ami))) { !memcmp(efistub_fw_vendor(), ami, sizeof(ami))) {
efi_debug("AMI firmware v2.0 or older detected - disabling physical KASLR\n"); efi_debug("AMI firmware v2.0 or older detected - disabling physical KASLR\n");
seed[0] = 0; seed[0] = 0;
} else if (cmdline_memmap_override) {
efi_info("%s detected on the kernel command line - disabling physical KASLR\n",
cmdline_memmap_override);
seed[0] = 0;
} }
boot_params_ptr->hdr.loadflags |= KASLR_FLAG; boot_params_ptr->hdr.loadflags |= KASLR_FLAG;
...@@ -883,7 +907,7 @@ void __noreturn efi_stub_entry(efi_handle_t handle, ...@@ -883,7 +907,7 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
} }
#ifdef CONFIG_CMDLINE_BOOL #ifdef CONFIG_CMDLINE_BOOL
status = efi_parse_options(CONFIG_CMDLINE); status = parse_options(CONFIG_CMDLINE);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_err("Failed to parse options\n"); efi_err("Failed to parse options\n");
goto fail; goto fail;
...@@ -892,7 +916,7 @@ void __noreturn efi_stub_entry(efi_handle_t handle, ...@@ -892,7 +916,7 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) { if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr | unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr |
((u64)boot_params->ext_cmd_line_ptr << 32)); ((u64)boot_params->ext_cmd_line_ptr << 32));
status = efi_parse_options((char *)cmdline_paddr); status = parse_options((char *)cmdline_paddr);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_err("Failed to parse options\n"); efi_err("Failed to parse options\n");
goto fail; goto fail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment