From d5ce85e0f9d91d1834067638c666dec5b1122ee1 Mon Sep 17 00:00:00 2001 From: Nicolas Frayer Date: Wed, 3 Dec 2025 11:18:30 +0100 Subject: [PATCH] mkimage/appendedsig: Fix grub-mkimage with an unaligned appended signature size Related: #RHEL-24510 Signed-off-by: Nicolas Frayer --- ...grub-mkimage-with-an-unaligned-appen.patch | 43 +++++++++++++++++++ grub.patches | 1 + grub2.spec | 6 ++- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 0410-appendedsig-Fix-grub-mkimage-with-an-unaligned-appen.patch diff --git a/0410-appendedsig-Fix-grub-mkimage-with-an-unaligned-appen.patch b/0410-appendedsig-Fix-grub-mkimage-with-an-unaligned-appen.patch new file mode 100644 index 0000000..bba2f55 --- /dev/null +++ b/0410-appendedsig-Fix-grub-mkimage-with-an-unaligned-appen.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Sudhakar Kuppusamy +Date: Wed, 3 Dec 2025 13:19:57 +0530 +Subject: [PATCH] appendedsig: Fix grub-mkimage with an unaligned appended + signature size + +The grub-mkimage does not add zero padding when creating core.elf with an +appended signature size that is not aligned to a multiple of 4 bytes. +Firmware is unable to read the magic string "~Module signature appended~" +from core.elf. + +To fix this, round an appended signature size + appended signature ELF note +size up to the nearest multiple of a 4-byte alignment and truncate it to the +appended signature size. + +Example: +grub-mkimage -O powerpc-ieee1275 -o core.elf -d grub-core -p /grub2 -x \ + kernel.der --appended-signature-size 490 ... + +Signed-off-by: Sudhakar Kuppusamy +--- + util/grub-mkimagexx.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c +index d185246f1010..c99c7f99c787 100644 +--- a/util/grub-mkimagexx.c ++++ b/util/grub-mkimagexx.c +@@ -248,7 +248,13 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc + if (appsig_size) + { + phnum++; +- footer_size += ALIGN_UP (sizeof (struct grub_appended_signature_note), 4); ++ /* ++ * Rounds a appended signature size + appended signature note size up to ++ * the nearest multiple of a 4-byte alignment. ++ */ ++ footer_size += ALIGN_UP (sizeof (struct grub_appended_signature_note) + appsig_size, 4); ++ /* Truncating to appended signature size. */ ++ footer_size -= appsig_size; + } + + if (image_target->id != IMAGE_LOONGSON_ELF) diff --git a/grub.patches b/grub.patches index 8211694..36c8713 100644 --- a/grub.patches +++ b/grub.patches @@ -406,3 +406,4 @@ Patch0406: 0406-docs-grub-Document-appended-signature.patch Patch0407: 0407-libtasn1-Fix-include-path-for-grub.patch Patch0408: 0408-docs-fix-duplicated-entries.patch Patch0409: 0409-powerpc-ieee1275-Add-support-for-signing-GRUB-with-a.patch +Patch0410: 0410-appendedsig-Fix-grub-mkimage-with-an-unaligned-appen.patch diff --git a/grub2.spec b/grub2.spec index db2501d..d013a08 100644 --- a/grub2.spec +++ b/grub2.spec @@ -17,7 +17,7 @@ Name: grub2 Epoch: 1 Version: 2.12 -Release: 34%{?dist} +Release: 35%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPL-3.0-or-later URL: http://www.gnu.org/software/grub/ @@ -574,6 +574,10 @@ fi %endif %changelog +* Wed Dec 03 2025 Nicolas Frayer 2.12-35 +- mkimage/appendedsig: Fix grub-mkimage with an unaligned appended signature size +- Related: #RHEL-24510 + * Fri Nov 21 2025 Nicolas Frayer 2.12-34 - powerpc: Add appended signature feature - Resolves: #RHEL-24510