grub2/0255-Fix-up-linux-params-usage.patch
Peter Jones 752ceb1640 Rebased to newer upstream for fedora-29
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-07-10 15:12:02 -04:00

64 lines
2.5 KiB
Diff

From 0bcd68876e531078880a7a4ddd15474f1ca81b68 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 30 May 2017 14:16:07 -0400
Subject: [PATCH] Fix up linux params usage...
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/loader/i386/efi/linux.c | 4 ++--
grub-core/loader/i386/linux.c | 5 ++++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
index bed5919cab3..6ff796f56ff 100644
--- a/grub-core/loader/i386/efi/linux.c
+++ b/grub-core/loader/i386/efi/linux.c
@@ -161,7 +161,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_file_t file = 0;
- struct linux_kernel_header *lh;
+ struct linux_i386_kernel_header *lh;
grub_ssize_t len, start, filelen;
void *kernel = NULL;
int setup_header_end_offset;
@@ -224,7 +224,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
grub_memcpy ((grub_uint8_t *)params + 0x1f1,
(grub_uint8_t *)kernel + 0x1f1,
MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1);
- lh = (struct linux_kernel_header *)params;
+ lh = (struct linux_i386_kernel_header *)params;
grub_dprintf ("linuxefi", "lh is at %p\n", lh);
grub_dprintf ("linuxefi", "checking lh->boot_flag\n");
if (lh->boot_flag != grub_cpu_to_le16 (0xaa55))
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
index 626ec9fef0c..35055431247 100644
--- a/grub-core/loader/i386/linux.c
+++ b/grub-core/loader/i386/linux.c
@@ -680,6 +680,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
{
grub_file_t file = 0;
struct linux_i386_kernel_header lh;
+ grub_uint8_t *linux_params_ptr;
grub_uint8_t setup_sects;
grub_size_t real_size, prot_size, prot_file_size, kernel_offset;
grub_ssize_t len;
@@ -811,6 +812,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
preferred_address))
goto fail;
+
grub_memset (&linux_params, 0, sizeof (linux_params));
grub_memcpy (&linux_params.setup_sects, &lh.setup_sects, sizeof (lh) - 0x1F1);
@@ -820,7 +822,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
len = sizeof (linux_params) - sizeof (lh);
- grub_memcpy (&linux_params + sizeof (lh), kernel + kernel_offset, len);
+ linux_params_ptr = (void *)&linux_params;
+ grub_memcpy (linux_params_ptr + sizeof (lh), kernel + kernel_offset, len);
kernel_offset += len;
linux_params.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE;