Skip to content

Commit 039018b

Browse files
nathanchancegregkh
authored andcommitted
kbuild: Strip trailing padding bytes from modules.builtin.modinfo
commit a26a6c93edfeee82cb73f55e87d995eea59ddfe8 upstream. After commit d50f21091358 ("kbuild: align modinfo section for Secureboot Authenticode EDK2 compat"), running modules_install with certain versions of kmod (such as 29.1 in Ubuntu Jammy) in certain configurations may fail with: depmod: ERROR: kmod_builtin_iter_next: unexpected string without modname prefix The additional padding bytes to ensure .modinfo is aligned within vmlinux.unstripped are unexpected by kmod, as this section has always just been null-terminated strings. Strip the trailing padding bytes from modules.builtin.modinfo after it has been extracted from vmlinux.unstripped to restore the format that kmod expects while keeping .modinfo aligned within vmlinux.unstripped to avoid regressing the Authenticode calculation fix for EDK2. Cc: [email protected] Fixes: d50f21091358 ("kbuild: align modinfo section for Secureboot Authenticode EDK2 compat") Reported-by: Omar Sandoval <[email protected]> Reported-by: Samir M <[email protected]> Reported-by: Venkat Rao Bagalkote <[email protected]> Closes: https://lore.kernel.org/[email protected]/ Tested-by: Omar Sandoval <[email protected]> Tested-by: Samir M <[email protected]> Tested-by: Venkat Rao Bagalkote <[email protected]> Reviewed-by: Nicolas Schier <[email protected]> Link: https://patch.msgid.link/20251105-kbuild-fix-builtin-modinfo-for-kmod-v1-1-b419d8ad4606@kernel.org Signed-off-by: Nathan Chancellor <[email protected]> [nathan: Apply to scripts/Makefile.vmlinux_o, location of modules.builtin.modinfo rule prior to 39cfd5b12160] Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7fa9e0e commit 039018b

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

scripts/Makefile.vmlinux_o

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,24 @@ targets += vmlinux.o
7676
# modules.builtin.modinfo
7777
# ---------------------------------------------------------------------------
7878

79+
# .modinfo in vmlinux.unstripped is aligned to 8 bytes for compatibility with
80+
# tools that expect vmlinux to have sufficiently aligned sections but the
81+
# additional bytes used for padding .modinfo to satisfy this requirement break
82+
# certain versions of kmod with
83+
#
84+
# depmod: ERROR: kmod_builtin_iter_next: unexpected string without modname prefix
85+
#
86+
# Strip the trailing padding bytes after extracting .modinfo to comply with
87+
# what kmod expects to parse.
88+
quiet_cmd_modules_builtin_modinfo = GEN $@
89+
cmd_modules_builtin_modinfo = $(cmd_objcopy); \
90+
sed -i 's/\x00\+$$/\x00/g' $@
91+
7992
OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
8093

8194
targets += modules.builtin.modinfo
8295
modules.builtin.modinfo: vmlinux.o FORCE
83-
$(call if_changed,objcopy)
96+
$(call if_changed,modules_builtin_modinfo)
8497

8598
# modules.builtin
8699
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)