From: Nathan Chancellor <nathan@kernel.org>
To: Dimitri John Ledkov <dimitri.ledkov@surgut.co.uk>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
masahiroy@kernel.org, arnd@arndb.de,
linux-kbuild@vger.kernel.org, legion@kernel.org, nsc@kernel.org
Subject: Re: [PATCH] kbuild: align modinfo section for Secureboot Authenticode EDK2 compat
Date: Sun, 26 Oct 2025 14:56:35 -0700 [thread overview]
Message-ID: <20251026215635.GA2368369@ax162> (raw)
In-Reply-To: <20251026202100.679989-1-dimitri.ledkov@surgut.co.uk>
Hi Dimitri,
On Sun, Oct 26, 2025 at 08:21:00PM +0000, Dimitri John Ledkov wrote:
> Previously linker scripts would always generate vmlinuz that has sections
> aligned. And thus padded (correct Authenticode calculation) and unpadded
Was this something that was guaranteed to happen or did it just always
happen by coincidence? Is there a way to enforce this?
> 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.
I might be missing something here but .modinfo should not be in the
final vmlinux since it gets stripped out via the strip_relocs rule in
scripts/Makefile.vmlinux. Does this matter because an unaligned .modinfo
section could potentially leave sections after it in the linker scripts
unaligned as well?
> However, if bzImage is not further processed and is attempted to be loaded
> directly by EDK2 firmware, it calculates unpadded Authenticode digest and
Could this affect other bootloaders as well? I noticed this report about
rEFInd and pointed them here in case it was related:
https://lore.kernel.org/CAB95QARfqSUNJCCgyPcTPu0-hk10e-sOVVMrnpKd6OdV_PHrGA@mail.gmail.com/
> 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")
I took this change via the Kbuild tree for 6.18-rc1 so I can pick this
up for kbuild-fixes or Arnd can take this if he has anything pending for
fixes in the asm-generic tree.
> Cc: stable@vger.kernel.org
> Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@surgut.co.uk>
> ---
> include/asm-generic/vmlinux.lds.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index 8a9a2e732a65b..e04d56a5332e6 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -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) } \
> --
> 2.51.0
>
next prev parent reply other threads:[~2025-10-26 21:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-26 20:21 [PATCH] kbuild: align modinfo section for Secureboot Authenticode EDK2 compat Dimitri John Ledkov
2025-10-26 21:56 ` Nathan Chancellor [this message]
2025-10-26 23:05 ` Dimitri John Ledkov
2025-10-27 23:23 ` Nathan Chancellor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251026215635.GA2368369@ax162 \
--to=nathan@kernel.org \
--cc=arnd@arndb.de \
--cc=dimitri.ledkov@surgut.co.uk \
--cc=legion@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=nsc@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox