|
|
5593c8 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
5593c8 |
From: Peter Jones <pjones@redhat.com>
|
|
|
5593c8 |
Date: Thu, 9 Sep 2021 10:59:28 -0400
|
|
|
5593c8 |
Subject: [PATCH] Arm: check for the PE magic for the compiled arch
|
|
|
5593c8 |
|
|
|
5593c8 |
In "arm64: Fix EFI loader kernel image allocation", Ben fixed the kernel
|
|
|
5593c8 |
alignment to match the alignment given in the PE header. In doing so, a
|
|
|
5593c8 |
check for valid PE magic was added, which was hard-coded to the value
|
|
|
5593c8 |
seen on Aarch64 (GRUB_PE32_PE64_MAGIC).
|
|
|
5593c8 |
|
|
|
5593c8 |
Unfortunately, this code is shared between 64-bit and 32-bit, and so
|
|
|
5593c8 |
that value broke 32-bit Arm systems.
|
|
|
5593c8 |
|
|
|
5593c8 |
This patch adds a constant definition for GRUB_PE32_PEXX_MAGIC, which is
|
|
|
5593c8 |
either GRUB_PE32_PE64_MAGIC or GRUB_PE32_PE32_MAGIC, depending on which
|
|
|
5593c8 |
platform is being built, and uses it in the header magic check.
|
|
|
5593c8 |
|
|
|
5593c8 |
Resolves: rhbz#2000756
|
|
|
5593c8 |
|
|
|
5593c8 |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
5593c8 |
---
|
|
|
5593c8 |
grub-core/loader/arm64/linux.c | 2 +-
|
|
|
5593c8 |
include/grub/arm/linux.h | 1 +
|
|
|
5593c8 |
include/grub/arm64/linux.h | 1 +
|
|
|
5593c8 |
3 files changed, 3 insertions(+), 1 deletion(-)
|
|
|
5593c8 |
|
|
|
5593c8 |
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
|
|
|
5593c8 |
index 4a252d5e7e9..f18d90bd749 100644
|
|
|
5593c8 |
--- a/grub-core/loader/arm64/linux.c
|
|
|
5593c8 |
+++ b/grub-core/loader/arm64/linux.c
|
|
|
5593c8 |
@@ -322,7 +322,7 @@ parse_pe_header (void *kernel, grub_uint64_t *total_size,
|
|
|
5593c8 |
|
|
|
5593c8 |
pe = (void *)((unsigned long)kernel + lh->hdr_offset);
|
|
|
5593c8 |
|
|
|
5593c8 |
- if (pe->opt.magic != GRUB_PE32_PE64_MAGIC)
|
|
|
5593c8 |
+ if (pe->opt.magic != GRUB_PE32_PEXX_MAGIC)
|
|
|
5593c8 |
return grub_error(GRUB_ERR_BAD_OS, "Invalid PE optional header magic");
|
|
|
5593c8 |
|
|
|
5593c8 |
*total_size = pe->opt.image_size;
|
|
|
5593c8 |
diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
|
|
|
5593c8 |
index b582f67f661..966a5074f53 100644
|
|
|
5593c8 |
--- a/include/grub/arm/linux.h
|
|
|
5593c8 |
+++ b/include/grub/arm/linux.h
|
|
|
5593c8 |
@@ -44,6 +44,7 @@ struct grub_arm_linux_pe_header
|
|
|
5593c8 |
|
|
|
5593c8 |
#if defined(__arm__)
|
|
|
5593c8 |
# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE
|
|
|
5593c8 |
+# define GRUB_PE32_PEXX_MAGIC GRUB_PE32_PE32_MAGIC
|
|
|
5593c8 |
# define linux_arch_kernel_header linux_arm_kernel_header
|
|
|
5593c8 |
# define grub_armxx_linux_pe_header grub_arm_linux_pe_header
|
|
|
5593c8 |
#endif
|
|
|
5593c8 |
diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
|
|
|
5593c8 |
index ea030312df3..422bf2bf24b 100644
|
|
|
5593c8 |
--- a/include/grub/arm64/linux.h
|
|
|
5593c8 |
+++ b/include/grub/arm64/linux.h
|
|
|
5593c8 |
@@ -48,6 +48,7 @@ struct grub_arm64_linux_pe_header
|
|
|
5593c8 |
|
|
|
5593c8 |
#if defined(__aarch64__)
|
|
|
5593c8 |
# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE
|
|
|
5593c8 |
+# define GRUB_PE32_PEXX_MAGIC GRUB_PE32_PE64_MAGIC
|
|
|
5593c8 |
# define linux_arch_kernel_header linux_arm64_kernel_header
|
|
|
5593c8 |
# define grub_armxx_linux_pe_header grub_arm64_linux_pe_header
|
|
|
5593c8 |
#endif
|