|
|
bf0270 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
bf0270 |
From: Peter Jones <pjones@redhat.com>
|
|
|
bf0270 |
Date: Tue, 22 Mar 2022 10:57:20 -0400
|
|
|
bf0270 |
Subject: [PATCH] nx: set the nx compatible flag in EFI grub images
|
|
|
bf0270 |
|
|
|
bf0270 |
For NX, we need the grub binary to announce that it is compatible with
|
|
|
bf0270 |
the NX feature. This implies that when loading the executable grub
|
|
|
bf0270 |
image, several attributes are true:
|
|
|
bf0270 |
|
|
|
bf0270 |
- the binary doesn't need an executable stack
|
|
|
bf0270 |
- the binary doesn't need sections to be both executable and writable
|
|
|
bf0270 |
- the binary knows how to use the EFI Memory Attributes protocol on code
|
|
|
bf0270 |
it is loading.
|
|
|
bf0270 |
|
|
|
bf0270 |
This patch adds a definition for the PE DLL Characteristics flag
|
|
|
bf0270 |
GRUB_PE32_NX_COMPAT, and changes grub-mkimage to set that flag.
|
|
|
bf0270 |
|
|
|
bf0270 |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
bf0270 |
(cherry picked from commit 0c7f1aed5a87f75051b421903a900ccb4bbd795a)
|
|
|
bf0270 |
(cherry picked from commit 2f9446d488da96de963f4ffe03b0a1c60a4664f5)
|
|
|
c6c771 |
[rharwood: fix uninitialized use of stack_attrs]
|
|
|
c6c771 |
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
|
|
|
bf0270 |
---
|
|
|
bf0270 |
util/mkimage.c | 1 +
|
|
|
bf0270 |
1 file changed, 1 insertion(+)
|
|
|
bf0270 |
|
|
|
bf0270 |
diff --git a/util/mkimage.c b/util/mkimage.c
|
|
|
bf0270 |
index 16418e245d..c77025904c 100644
|
|
|
bf0270 |
--- a/util/mkimage.c
|
|
|
bf0270 |
+++ b/util/mkimage.c
|
|
|
bf0270 |
@@ -1358,6 +1358,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
|
|
|
bf0270 |
section = (struct grub_pe32_section_table *)(o64 + 1);
|
|
|
bf0270 |
}
|
|
|
bf0270 |
|
|
|
bf0270 |
+ PE_OHDR (o32, o64, dll_characteristics) = grub_host_to_target16 (GRUB_PE32_NX_COMPAT);
|
|
|
bf0270 |
PE_OHDR (o32, o64, header_size) = grub_host_to_target32 (header_size);
|
|
|
bf0270 |
PE_OHDR (o32, o64, entry_addr) = grub_host_to_target32 (layout.start_address);
|
|
|
bf0270 |
PE_OHDR (o32, o64, image_base) = 0;
|