|
|
4fe85b |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
4fe85b |
From: Peter Jones <pjones@redhat.com>
|
|
|
4fe85b |
Date: Wed, 24 May 2017 15:58:18 -0400
|
|
|
4fe85b |
Subject: [PATCH] Clean up some errors in the linuxefi loader
|
|
|
4fe85b |
|
|
|
4fe85b |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
4fe85b |
---
|
|
|
4fe85b |
grub-core/loader/i386/efi/linux.c | 16 ++++++++--------
|
|
|
4fe85b |
1 file changed, 8 insertions(+), 8 deletions(-)
|
|
|
4fe85b |
|
|
|
4fe85b |
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
|
|
|
4fe85b |
index c123afad19c..7166ec17f8f 100644
|
|
|
4fe85b |
--- a/grub-core/loader/i386/efi/linux.c
|
|
|
4fe85b |
+++ b/grub-core/loader/i386/efi/linux.c
|
|
|
4fe85b |
@@ -161,8 +161,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|
|
4fe85b |
int argc, char *argv[])
|
|
|
4fe85b |
{
|
|
|
4fe85b |
grub_file_t file = 0;
|
|
|
4fe85b |
- struct linux_kernel_header *lh;
|
|
|
4fe85b |
- grub_ssize_t len, start, filelen;
|
|
|
4fe85b |
+ struct linux_kernel_header *lh = NULL;
|
|
|
4fe85b |
+ grub_ssize_t start, filelen;
|
|
|
4fe85b |
void *kernel = NULL;
|
|
|
4fe85b |
int setup_header_end_offset;
|
|
|
4fe85b |
int rc;
|
|
|
4fe85b |
@@ -212,18 +212,19 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|
|
4fe85b |
goto fail;
|
|
|
4fe85b |
}
|
|
|
4fe85b |
|
|
|
4fe85b |
- grub_dprintf ("linuxefi", "params = %p\n", (unsigned long) params);
|
|
|
4fe85b |
+ grub_dprintf ("linuxefi", "params = %p\n", params);
|
|
|
4fe85b |
|
|
|
4fe85b |
grub_memset (params, 0, sizeof(*params));
|
|
|
4fe85b |
|
|
|
4fe85b |
setup_header_end_offset = *((grub_uint8_t *)kernel + 0x201);
|
|
|
4fe85b |
grub_dprintf ("linuxefi", "copying %lu bytes from %p to %p\n",
|
|
|
4fe85b |
- MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1,
|
|
|
4fe85b |
+ MIN((grub_size_t)0x202+setup_header_end_offset,
|
|
|
4fe85b |
+ sizeof (*params)) - 0x1f1,
|
|
|
4fe85b |
(grub_uint8_t *)kernel + 0x1f1,
|
|
|
4fe85b |
(grub_uint8_t *)params + 0x1f1);
|
|
|
4fe85b |
grub_memcpy ((grub_uint8_t *)params + 0x1f1,
|
|
|
4fe85b |
(grub_uint8_t *)kernel + 0x1f1,
|
|
|
4fe85b |
- MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1);
|
|
|
4fe85b |
+ MIN((grub_size_t)0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1);
|
|
|
4fe85b |
lh = (struct linux_kernel_header *)params;
|
|
|
4fe85b |
grub_dprintf ("linuxefi", "lh is at %p\n", lh);
|
|
|
4fe85b |
grub_dprintf ("linuxefi", "checking lh->boot_flag\n");
|
|
|
4fe85b |
@@ -254,7 +255,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|
|
4fe85b |
goto fail;
|
|
|
4fe85b |
}
|
|
|
4fe85b |
|
|
|
4fe85b |
-#ifdef defined(__x86_64__) || defined(__aarch64__)
|
|
|
4fe85b |
+#if defined(__x86_64__) || defined(__aarch64__)
|
|
|
4fe85b |
grub_dprintf ("linuxefi", "checking lh->xloadflags\n");
|
|
|
4fe85b |
if (!(lh->xloadflags & LINUX_XLF_KERNEL_64))
|
|
|
4fe85b |
{
|
|
|
4fe85b |
@@ -298,7 +299,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|
|
4fe85b |
handover_offset = lh->handover_offset;
|
|
|
4fe85b |
|
|
|
4fe85b |
start = (lh->setup_sects + 1) * 512;
|
|
|
4fe85b |
- len = grub_file_size(file) - start;
|
|
|
4fe85b |
|
|
|
4fe85b |
kernel_mem = grub_efi_allocate_pages(lh->pref_address,
|
|
|
4fe85b |
BYTES_TO_PAGES(lh->init_size));
|
|
|
4fe85b |
@@ -344,7 +344,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|
|
4fe85b |
loaded = 0;
|
|
|
4fe85b |
}
|
|
|
4fe85b |
|
|
|
4fe85b |
- if (linux_cmdline && !loaded)
|
|
|
4fe85b |
+ if (linux_cmdline && lh && !loaded)
|
|
|
4fe85b |
grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)
|
|
|
4fe85b |
linux_cmdline,
|
|
|
4fe85b |
BYTES_TO_PAGES(lh->cmdline_size + 1));
|