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.
Showing the changes to scripts/Makefile.vmlinux (1 of 1 file). Show all
Unified · Split
| @@ -102,11 +102,24 @@ vmlinux: vmlinux.unstripped FORCE · 101 unmodified lines | ||
| 102 | 102 | # modules.builtin.modinfo |
| 103 | 103 | # --------------------------------------------------------------------------- |
| 104 | 104 | |
| 105 | +# .modinfo in vmlinux.unstripped is aligned to 8 bytes for compatibility with | |
| 106 | +# tools that expect vmlinux to have sufficiently aligned sections but the | |
| 107 | +# additional bytes used for padding .modinfo to satisfy this requirement break | |
| 108 | +# certain versions of kmod with | |
| 109 | +# | |
| 110 | +# depmod: ERROR: kmod_builtin_iter_next: unexpected string without modname prefix | |
| 111 | +# | |
| 112 | +# Strip the trailing padding bytes after extracting .modinfo to comply with | |
| 113 | +# what kmod expects to parse. | |
| 114 | +quiet_cmd_modules_builtin_modinfo = GEN $@ | |
| 115 | + cmd_modules_builtin_modinfo = $(cmd_objcopy); \ | |
| 116 | + sed -i 's/\x00\+$$/\x00/g' $@ | |
| 117 | + | |
| 105 | 118 | OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary |
| 106 | 119 | |
| 107 | 120 | targets += modules.builtin.modinfo |
| 108 | 121 | modules.builtin.modinfo: vmlinux.unstripped FORCE |
| 109 | − $(call if_changed,objcopy) | |
| 122 | + $(call if_changed,modules_builtin_modinfo) | |
| 110 | 123 | |
| 111 | 124 | # modules.builtin |
| 112 | 125 | # --------------------------------------------------------------------------- |