public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: Fix permissions of modules.builtin.modinfo
@ 2026-01-27 19:23 Ethan Zuo
  2026-01-27 20:59 ` Nathan Chancellor
  0 siblings, 1 reply; 7+ messages in thread
From: Ethan Zuo @ 2026-01-27 19:23 UTC (permalink / raw)
  To: nathan, nsc; +Cc: masahiroy, linux-kbuild, linux-kernel, Ethan Zuo

Currently, modules.builtin.modinfo is created with executable permissions
(0755). This is because after commit 39cfd5b12160 ("kbuild: extract
modules.builtin.modinfo from vmlinux.unstripped"), modules.builtin.modinfo
is extracted from vmlinux.unstripped using objcopy. When extracting
sections, objcopy inherits attributes from the source ELF file.

Since modules.builtin.modinfo is a data file and not an executable,
it should have 0644 permissions. The executable bit can trigger
warnings in Debian's Lintian tool.

Explicitly set the permissions to 0644 after generation.

Fixes: 39cfd5b12160 ("kbuild: extract modules.builtin.modinfo from vmlinux.unstripped")
Signed-off-by: Ethan Zuo <yuxuan.zuo@outlook.com>
---
 scripts/Makefile.vmlinux | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index cd788cac9d91..c5305619b1d3 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -113,7 +113,8 @@ vmlinux: vmlinux.unstripped FORCE
 # what kmod expects to parse.
 quiet_cmd_modules_builtin_modinfo = GEN     $@
       cmd_modules_builtin_modinfo = $(cmd_objcopy); \
-                                    sed -i 's/\x00\+$$/\x00/g' $@
+                                    sed -i 's/\x00\+$$/\x00/g' $@; \
+                                    chmod 644 $@
 
 OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] kbuild: Fix permissions of modules.builtin.modinfo
  2026-01-27 19:23 [PATCH] kbuild: Fix permissions of modules.builtin.modinfo Ethan Zuo
@ 2026-01-27 20:59 ` Nathan Chancellor
  2026-01-28  6:15   ` Ethan Zuo
                     ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Nathan Chancellor @ 2026-01-27 20:59 UTC (permalink / raw)
  To: Ethan Zuo; +Cc: nsc, masahiroy, linux-kbuild, linux-kernel

Hi Ethan,

On Wed, Jan 28, 2026 at 03:23:23AM +0800, Ethan Zuo wrote:
> Currently, modules.builtin.modinfo is created with executable permissions
> (0755). This is because after commit 39cfd5b12160 ("kbuild: extract
> modules.builtin.modinfo from vmlinux.unstripped"), modules.builtin.modinfo
> is extracted from vmlinux.unstripped using objcopy. When extracting
> sections, objcopy inherits attributes from the source ELF file.

Ah, that explains why this is only visble after 39cfd5b12160, as
vmlinux.o was just a regular object file, whereas vmlinux.unstripped is
an executable. There was another patch submitted to address this issue
that did not explain that bit well:

https://lore.kernel.org/20251209-modinfo-executable-v1-1-ed0c553a4390@pengutronix.de/

> Since modules.builtin.modinfo is a data file and not an executable,
> it should have 0644 permissions. The executable bit can trigger
> warnings in Debian's Lintian tool.

I had asked on that previous submission what sort of issues could be
expected from being executable and warnings from tools is a reasonable
answer to that. Thanks for including that.

> Explicitly set the permissions to 0644 after generation.

Would it be better to do what the previous submission did and just
remove the execute bit via 'chmod -x'? That seems to be slightly more
common in the kernel (even though there are very few uses of 'chmod'
throughout Makefile instances) and seems to get at the issue a little
bit more. Not sure if the creation of these files respects umask, in
case someone had a more restrictive one, but that might be contrived.

> Fixes: 39cfd5b12160 ("kbuild: extract modules.builtin.modinfo from vmlinux.unstripped")
> Signed-off-by: Ethan Zuo <yuxuan.zuo@outlook.com>

Nicolas, do you want to take this as a fix for 6.19 or should I take it
via kbuild-next for 6.20/7.0?

> ---
>  scripts/Makefile.vmlinux | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
> index cd788cac9d91..c5305619b1d3 100644
> --- a/scripts/Makefile.vmlinux
> +++ b/scripts/Makefile.vmlinux
> @@ -113,7 +113,8 @@ vmlinux: vmlinux.unstripped FORCE
>  # what kmod expects to parse.
>  quiet_cmd_modules_builtin_modinfo = GEN     $@
>        cmd_modules_builtin_modinfo = $(cmd_objcopy); \
> -                                    sed -i 's/\x00\+$$/\x00/g' $@
> +                                    sed -i 's/\x00\+$$/\x00/g' $@; \
> +                                    chmod 644 $@
>  
>  OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
>  
> -- 
> 2.51.0
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] kbuild: Fix permissions of modules.builtin.modinfo
  2026-01-27 20:59 ` Nathan Chancellor
@ 2026-01-28  6:15   ` Ethan Zuo
  2026-01-28  6:35   ` Ethan Zuo
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Ethan Zuo @ 2026-01-28  6:15 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: nsc, masahiroy, linux-kbuild, linux-kernel

Thank you for your reply, sir.

My apologies for the double mail; I realized I missed the CC list.

On 1/28/26 4:59 AM, Nathan Chancellor wrote:
> Would it be better to do what the previous submission did and just
> remove the execute bit via 'chmod -x'? That seems to be slightly more
> common in the kernel (even though there are very few uses of 'chmod'
> throughout Makefile instances) and seems to get at the issue a little
> bit more. Not sure if the creation of these files respects umask, in
> case someone had a more restrictive one, but that might be contrived.
That looks more reasonable. I'll send out the v2 patch shortly.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] kbuild: Fix permissions of modules.builtin.modinfo
  2026-01-27 20:59 ` Nathan Chancellor
  2026-01-28  6:15   ` Ethan Zuo
@ 2026-01-28  6:35   ` Ethan Zuo
  2026-01-28  6:37   ` [PATCH v2] " Ethan Zuo
  2026-01-28  8:16   ` [PATCH] " Nicolas Schier
  3 siblings, 0 replies; 7+ messages in thread
From: Ethan Zuo @ 2026-01-28  6:35 UTC (permalink / raw)
  To: nathan; +Cc: nsc, masahiroy, linux-kbuild, linux-kernel, Ethan Zuo

Currently, modules.builtin.modinfo is created with executable permissions
(0755). This is because after commit 39cfd5b12160 ("kbuild: extract
modules.builtin.modinfo from vmlinux.unstripped"), modules.builtin.modinfo
is extracted from vmlinux.unstripped using objcopy. When extracting
sections, objcopy inherits attributes from the source ELF file.

Since modules.builtin.modinfo is a data file and not an executable,
it should have 0644 permissions. The executable bit can trigger
warnings in Debian's Lintian tool.

Explicitly set the permissions to 0644 after generation.

Fixes: 39cfd5b12160 ("kbuild: extract modules.builtin.modinfo from vmlinux.unstripped")
Signed-off-by: Ethan Zuo <yuxuan.zuo@outlook.com>
---
 scripts/Makefile.vmlinux | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index cd788cac9d91..c5305619b1d3 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -113,7 +113,8 @@ vmlinux: vmlinux.unstripped FORCE
 # what kmod expects to parse.
 quiet_cmd_modules_builtin_modinfo = GEN     $@
       cmd_modules_builtin_modinfo = $(cmd_objcopy); \
-                                    sed -i 's/\x00\+$$/\x00/g' $@
+                                    sed -i 's/\x00\+$$/\x00/g' $@; \
+                                    chmod 644 $@
 
 OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2] kbuild: Fix permissions of modules.builtin.modinfo
  2026-01-27 20:59 ` Nathan Chancellor
  2026-01-28  6:15   ` Ethan Zuo
  2026-01-28  6:35   ` Ethan Zuo
@ 2026-01-28  6:37   ` Ethan Zuo
  2026-01-28 11:27     ` Nicolas Schier
  2026-01-28  8:16   ` [PATCH] " Nicolas Schier
  3 siblings, 1 reply; 7+ messages in thread
From: Ethan Zuo @ 2026-01-28  6:37 UTC (permalink / raw)
  To: nathan; +Cc: nsc, masahiroy, linux-kbuild, linux-kernel, Ethan Zuo

Currently, modules.builtin.modinfo is created with executable permissions
(0755). This is because after commit 39cfd5b12160 ("kbuild: extract
modules.builtin.modinfo from vmlinux.unstripped"), modules.builtin.modinfo
is extracted from vmlinux.unstripped using objcopy. When extracting
sections, objcopy inherits attributes from the source ELF file.

Since modules.builtin.modinfo is a data file and not an executable,
it should have regular file permissions (0644). The executable bit
can trigger warnings in Debian's Lintian tool.

Explicitly remove the executable bit after generation.

Fixes: 39cfd5b12160 ("kbuild: extract modules.builtin.modinfo from vmlinux.unstripped")
Signed-off-by: Ethan Zuo <yuxuan.zuo@outlook.com>
---
 scripts/Makefile.vmlinux | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index cd788cac9d91..276c3134a563 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -113,7 +113,8 @@ vmlinux: vmlinux.unstripped FORCE
 # what kmod expects to parse.
 quiet_cmd_modules_builtin_modinfo = GEN     $@
       cmd_modules_builtin_modinfo = $(cmd_objcopy); \
-                                    sed -i 's/\x00\+$$/\x00/g' $@
+                                    sed -i 's/\x00\+$$/\x00/g' $@; \
+                                    chmod -x $@
 
 OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] kbuild: Fix permissions of modules.builtin.modinfo
  2026-01-27 20:59 ` Nathan Chancellor
                     ` (2 preceding siblings ...)
  2026-01-28  6:37   ` [PATCH v2] " Ethan Zuo
@ 2026-01-28  8:16   ` Nicolas Schier
  3 siblings, 0 replies; 7+ messages in thread
From: Nicolas Schier @ 2026-01-28  8:16 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: Ethan Zuo, masahiroy, linux-kbuild, linux-kernel

On Tue, Jan 27, 2026 at 01:59:15PM -0700, Nathan Chancellor wrote:
> Hi Ethan,
> 
> On Wed, Jan 28, 2026 at 03:23:23AM +0800, Ethan Zuo wrote:
> > Currently, modules.builtin.modinfo is created with executable permissions
> > (0755). This is because after commit 39cfd5b12160 ("kbuild: extract
> > modules.builtin.modinfo from vmlinux.unstripped"), modules.builtin.modinfo
> > is extracted from vmlinux.unstripped using objcopy. When extracting
> > sections, objcopy inherits attributes from the source ELF file.
> 
> Ah, that explains why this is only visble after 39cfd5b12160, as
> vmlinux.o was just a regular object file, whereas vmlinux.unstripped is
> an executable. There was another patch submitted to address this issue
> that did not explain that bit well:
> 
> https://lore.kernel.org/20251209-modinfo-executable-v1-1-ed0c553a4390@pengutronix.de/
> 
> > Since modules.builtin.modinfo is a data file and not an executable,
> > it should have 0644 permissions. The executable bit can trigger
> > warnings in Debian's Lintian tool.
> 
> I had asked on that previous submission what sort of issues could be
> expected from being executable and warnings from tools is a reasonable
> answer to that. Thanks for including that.
> 
> > Explicitly set the permissions to 0644 after generation.
> 
> Would it be better to do what the previous submission did and just
> remove the execute bit via 'chmod -x'? That seems to be slightly more
> common in the kernel (even though there are very few uses of 'chmod'
> throughout Makefile instances) and seems to get at the issue a little
> bit more. Not sure if the creation of these files respects umask, in
> case someone had a more restrictive one, but that might be contrived.
> 
> > Fixes: 39cfd5b12160 ("kbuild: extract modules.builtin.modinfo from vmlinux.unstripped")
> > Signed-off-by: Ethan Zuo <yuxuan.zuo@outlook.com>
> 
> Nicolas, do you want to take this as a fix for 6.19 or should I take it
> via kbuild-next for 6.20/7.0?
> 

I'm happy to take it (v2) for kbuild-fixes this week.
Thanks!

-- 
Nicolas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] kbuild: Fix permissions of modules.builtin.modinfo
  2026-01-28  6:37   ` [PATCH v2] " Ethan Zuo
@ 2026-01-28 11:27     ` Nicolas Schier
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Schier @ 2026-01-28 11:27 UTC (permalink / raw)
  To: nathan, Ethan Zuo; +Cc: masahiroy, linux-kbuild, linux-kernel

On Wed, 28 Jan 2026 14:37:51 +0800, Ethan Zuo wrote:
> Currently, modules.builtin.modinfo is created with executable permissions
> (0755). This is because after commit 39cfd5b12160 ("kbuild: extract
> modules.builtin.modinfo from vmlinux.unstripped"), modules.builtin.modinfo
> is extracted from vmlinux.unstripped using objcopy. When extracting
> sections, objcopy inherits attributes from the source ELF file.
> 
> Since modules.builtin.modinfo is a data file and not an executable,
> it should have regular file permissions (0644). The executable bit
> can trigger warnings in Debian's Lintian tool.
> 
> [...]

Applied to kbuild/linux.git (kbuild-fixes-unstable), thanks!

[1/1] kbuild: Fix permissions of modules.builtin.modinfo
      https://git.kernel.org/kbuild/c/6d60354e

Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped,
reverted or modified (e.g. trailers). Patches applied to the
kbuild-fixes-unstable branch are accepted pending wider testing in
linux-next and any post-commit review; they will generally be moved
to the kbuild-fixes branch in a week if no issues are found.

Best regards,
-- 
Nicolas



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-01-28 11:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 19:23 [PATCH] kbuild: Fix permissions of modules.builtin.modinfo Ethan Zuo
2026-01-27 20:59 ` Nathan Chancellor
2026-01-28  6:15   ` Ethan Zuo
2026-01-28  6:35   ` Ethan Zuo
2026-01-28  6:37   ` [PATCH v2] " Ethan Zuo
2026-01-28 11:27     ` Nicolas Schier
2026-01-28  8:16   ` [PATCH] " Nicolas Schier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox