Skip to contentSkip to conversation

kbuild: fix modules.builtin.modinfo being executable

PATCH In review Fabian Pfitzner 3 participants 3 messages Dec 9, 2025 – Dec 10, 2025 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: fix modules.builtin.modinfo being executable

Since commit a26a6c93edfe ("kbuild: Strip trailing padding bytes from modules.builtin.modinfo") the resulting modules.builtin.modinfo file gets copied by objcopy resulting in an executable file.

It seems, that objcopy detects this file as executable even though the file is not executable at all.

This problem arises on x86_64 and arm-v7a, but for some reason does not happen on aarch64.

Fix this problem by removing the execution bit afterwards.

---
 scripts/Makefile.vmlinux | 1 +
 1 file changed, 1 insertion(+)
scripts/Makefile.vmlinux +1 -0
index cd788cac9d91dadcf4e83a39142f9d7bc61ffed0..7ee6aad760495ac5357132954c32ff879d24f72e 100644
@@ -113,6 +113,7 @@ vmlinux: vmlinux.unstripped FORCE
 # what kmod expects to parse.
 quiet_cmd_modules_builtin_modinfo = GEN     $@
       cmd_modules_builtin_modinfo = $(cmd_objcopy); \
+                                    chmod -x $@; \
                                     sed -i 's/\x00\+$$/\x00/g' $@
 
 OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary

---
base-commit: cb015814f8b6eebcbb8e46e111d108892c5e6821
change-id: 20251209-modinfo-executable-2d2af74150c0

Best regards,

Signature · 1 line
Fabian Pfitzner <[email protected]>
Acked-by Tested-by on v1 1/1
#1 lore raw
Quoted 7 lines · Fabian Pfitzner

Since commit a26a6c93edfe ("kbuild: Strip trailing padding bytes from modules.builtin.modinfo") the resulting modules.builtin.modinfo file gets copied by objcopy resulting in an executable file.

It seems, that objcopy detects this file as executable even though the file is not executable at all.

Quoted 6 lines

This problem arises on x86_64 and arm-v7a, but for some reason does not happen on aarch64.

Fix this problem by removing the execution bit afterwards.

WFM. Thanks.

Quoted 22 lines
---
 scripts/Makefile.vmlinux | 1 +
 1 file changed, 1 insertion(+)
scripts/Makefile.vmlinux +1 -1
index cd788cac9d91dadcf4e83a39142f9d7bc61ffed0..7ee6aad760495ac5357132954c32ff879d24f72e 100644
@@ -113,6 +113,7 @@ vmlinux: vmlinux.unstripped FORCE
 # what kmod expects to parse.
 quiet_cmd_modules_builtin_modinfo = GEN     $@
       cmd_modules_builtin_modinfo = $(cmd_objcopy); \
+                                    chmod -x $@; \
                                     sed -i 's/\x00\+$$/\x00/g' $@
 
 OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
 
---

base-commit: cb015814f8b6eebcbb8e46e111d108892c5e6821
change-id: 20251209-modinfo-executable-2d2af74150c0

Best regards,

Signature · 1 line
~Randy
#2 lore raw
In reply to Fabian Pfitzner
Quoted 3 lines · Fabian Pfitzner

Since commit a26a6c93edfe ("kbuild: Strip trailing padding bytes from modules.builtin.modinfo") the resulting modules.builtin.modinfo file gets copied by objcopy resulting in an executable file.

objcopy has been used to generate modules.builtin.modinfo since its introduction in commit 898490c010b5 ("moduleparam: Save information about built-in modules in separate file"). This would seem to indicate some issue with the sed command in that change if it is indeed the culprit of introducing this behavior? Or is there something else going on here?

Quoted 2 lines

It seems, that objcopy detects this file as executable even though the file is not executable at all.

This section comes from vmlinux.unstripped, which is executable, perhaps that is related?

Quoted 2 lines

This problem arises on x86_64 and arm-v7a, but for some reason does not happen on aarch64.

This file is executable for me on an aarch64 machine:

  $ uname -m
  aarch64
  $ ls -al /usr/lib/modules/6.18.0-next-20251205-00002-g8e6af29eba24/modules.builtin.modinfo
  .rwxr-xr-x@ 197k root  5 Dec 09:39 /usr/lib/modules/6.18.0-next-20251205-00002-g8e6af29eba24/modules.builtin.modinfo
Quoted 1 line

Fix this problem by removing the execution bit afterwards.

This seems obviously correct since there is no reason for this file to be executable but does this result in any other problems?

Quoted 26 lines
---
 scripts/Makefile.vmlinux | 1 +
 1 file changed, 1 insertion(+)
scripts/Makefile.vmlinux +1 -1
index cd788cac9d91dadcf4e83a39142f9d7bc61ffed0..7ee6aad760495ac5357132954c32ff879d24f72e 100644
@@ -113,6 +113,7 @@ vmlinux: vmlinux.unstripped FORCE
 # what kmod expects to parse.
 quiet_cmd_modules_builtin_modinfo = GEN     $@
       cmd_modules_builtin_modinfo = $(cmd_objcopy); \
+                                    chmod -x $@; \
                                     sed -i 's/\x00\+$$/\x00/g' $@
 
 OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
 
---

base-commit: cb015814f8b6eebcbb8e46e111d108892c5e6821
change-id: 20251209-modinfo-executable-2d2af74150c0

Best regards,

Signature · 1 line
Fabian Pfitzner <[email protected]>