]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
kbuild: align modinfo section for Secureboot Authenticode EDK2 compat
authorDimitri John Ledkov <dimitri.ledkov@surgut.co.uk>
Sun, 26 Oct 2025 20:21:00 +0000 (20:21 +0000)
committerNathan Chancellor <nathan@kernel.org>
Mon, 27 Oct 2025 23:21:24 +0000 (16:21 -0700)
Previously linker scripts would always generate vmlinuz that has sections
aligned. And thus padded (correct Authenticode calculation) and unpadded
calculation would be same. As in https://github.com/rhboot/pesign userspace
tool would produce the same authenticode digest for both of the following
commands:

    pesign --padding --hash --in ./arch/x86_64/boot/bzImage
    pesign --nopadding --hash --in ./arch/x86_64/boot/bzImage

The commit 3e86e4d74c04 ("kbuild: keep .modinfo section in
vmlinux.unstripped") added .modinfo section of variable length. Depending
on kernel configuration it may or may not be aligned.

All userspace signing tooling correctly pads such section to calculation
spec compliant authenticode digest.

However, if bzImage is not further processed and is attempted to be loaded
directly by EDK2 firmware, it calculates unpadded Authenticode digest and
fails to correct accept/reject such kernel builds even when propoer
Authenticode values are enrolled in db/dbx. One can say EDK2 requires
aligned/padded kernels in Secureboot.

Thus add ALIGN(8) to the .modinfo section, to esure kernels irrespective of
modinfo contents can be loaded by all existing EDK2 firmware builds.

Fixes: 3e86e4d74c04 ("kbuild: keep .modinfo section in vmlinux.unstripped")
Cc: stable@vger.kernel.org
Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@surgut.co.uk>
Link: https://patch.msgid.link/20251026202100.679989-1-dimitri.ledkov@surgut.co.uk
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
include/asm-generic/vmlinux.lds.h

index 8a9a2e732a65b04d18453e266900895ef41bb615..e04d56a5332e622a0530ed1a8c1b2898062edc32 100644 (file)
@@ -832,7 +832,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
 
 /* Required sections not related to debugging. */
 #define ELF_DETAILS                                                    \
-               .modinfo : { *(.modinfo) }                              \
+               .modinfo : { *(.modinfo) . = ALIGN(8); }                \
                .comment 0 : { *(.comment) }                            \
                .symtab 0 : { *(.symtab) }                              \
                .strtab 0 : { *(.strtab) }                              \