From 76c8afe3dea0d027ce7dd72c9ba51f508a7a05b0 Mon Sep 17 00:00:00 2001 From: Nicolas Frayer Date: Wed, 3 Dec 2025 13:01:57 +0100 Subject: [PATCH] appendedsig: Fix grub-mkimage with an unaligned appended signature size Related: #RHEL-24742 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 0526-appendedsig-Fix-grub-mkimage-with-an-unaligned-appen.patch diff --git a/0526-appendedsig-Fix-grub-mkimage-with-an-unaligned-appen.patch b/0526-appendedsig-Fix-grub-mkimage-with-an-unaligned-appen.patch new file mode 100644 index 0000000..abf351f --- /dev/null +++ b/0526-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 d12b1ba2bae3..0eb1c3fe88c5 100644 +--- a/util/grub-mkimagexx.c ++++ b/util/grub-mkimagexx.c +@@ -247,7 +247,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 393051a..90e053f 100644 --- a/grub.patches +++ b/grub.patches @@ -522,3 +522,4 @@ Patch0522: 0522-docs-Write-how-to-import-new-libgcrypt.patch Patch0523: 0523-Appended-sig-Fix-build.patch Patch0524: 0524-docs-fix-some-duplicated-sections.patch Patch0525: 0525-mkimage-Remove-duplicates.patch +Patch0526: 0526-appendedsig-Fix-grub-mkimage-with-an-unaligned-appen.patch diff --git a/grub2.spec b/grub2.spec index 8a47479..97f7e8d 100644 --- a/grub2.spec +++ b/grub2.spec @@ -16,7 +16,7 @@ Name: grub2 Epoch: 1 Version: 2.06 -Release: 119%{?dist} +Release: 120%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -538,6 +538,10 @@ fi %endif %changelog +* Wed Dec 03 2025 Nicolas Frayer 2.06-120 +- appendedsig: Fix grub-mkimage with an unaligned appended signature size +- Related: #RHEL-24742 + * Mon Nov 17 2025 Nicolas Frayer 2.06-119 - ieee1275: Upstream patches for appended signature support - Related: #RHEL-24742