Commit 59476f80 authored by Arvind Sankar's avatar Arvind Sankar Committed by Ard Biesheuvel

efi/x86: Only copy upto the end of setup_header

When copying the setup_header into the boot_params buffer, only the data
that is actually part of the setup_header should be copied.

efi_pe_entry() currently copies the entire second sector, which
initializes some of the fields in boot_params beyond the setup_header
with garbage (i.e. part of the real-mode boot code gets copied into
those fields).

This does not cause any issues currently because the fields that are
overwritten are padding, BIOS EDD information that won't get used, and
the E820 table which will get properly filled in later.

Fix this to only copy data that is actually part of the setup_header
structure.
Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 0bda49f3
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/efi.h> #include <linux/efi.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/stddef.h>
#include <asm/efi.h> #include <asm/efi.h>
#include <asm/e820/types.h> #include <asm/e820/types.h>
...@@ -388,8 +389,9 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, ...@@ -388,8 +389,9 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
hdr = &boot_params->hdr; hdr = &boot_params->hdr;
/* Copy the second sector to boot_params */ /* Copy the setup header from the second sector to boot_params */
memcpy(&hdr->jump, image_base + 512, 512); memcpy(&hdr->jump, image_base + 512,
sizeof(struct setup_header) - offsetof(struct setup_header, jump));
/* /*
* Fill out some of the header fields ourselves because the * Fill out some of the header fields ourselves because the
......
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