lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0d8d7420-8a39-457f-a5a5-980a40809527@gmail.com>
Date: Mon, 20 Oct 2025 19:37:27 +0300
From: Cosmin Tanislav <demonsingur@...il.com>
To: Josh Poimboeuf <jpoimboe@...nel.org>, x86@...nel.org
Cc: linux-kernel@...r.kernel.org, Petr Mladek <pmladek@...e.com>,
 Miroslav Benes <mbenes@...e.cz>, Joe Lawrence <joe.lawrence@...hat.com>,
 live-patching@...r.kernel.org, Song Liu <song@...nel.org>,
 laokz <laokz@...mail.com>, Jiri Kosina <jikos@...nel.org>,
 Marcos Paulo de Souza <mpdesouza@...e.com>, Weinan Liu <wnliu@...gle.com>,
 Fazla Mehrab <a.mehrab@...edance.com>,
 Chen Zhongjin <chenzhongjin@...wei.com>, Puranjay Mohan
 <puranjay@...nel.org>, Dylan Hatch <dylanbhatch@...gle.com>,
 Peter Zijlstra <peterz@...radead.org>, Masahiro Yamada <masahiroy@...nel.org>
Subject: Re: [PATCH v4 08/63] kbuild: Remove 'kmod_' prefix from
 __KBUILD_MODNAME



On 9/17/25 7:03 PM, Josh Poimboeuf wrote:
> In preparation for the objtool klp diff subcommand, remove the arbitrary
> 'kmod_' prefix from __KBUILD_MODNAME and instead add it explicitly in
> the __initcall_id() macro.
> 
> This change supports the standardization of "unique" symbol naming by
> ensuring the non-unique portion of the name comes before the unique
> part.  That will enable objtool to properly correlate symbols across
> builds.
> 
> Cc: Masahiro Yamada <masahiroy@...nel.org>
> Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>
> ---
>   include/linux/init.h | 3 ++-
>   scripts/Makefile.lib | 2 +-
>   2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/init.h b/include/linux/init.h
> index 17c1bc712e234..40331923b9f4a 100644
> --- a/include/linux/init.h
> +++ b/include/linux/init.h
> @@ -200,12 +200,13 @@ extern struct module __this_module;
>   
>   /* Format: <modname>__<counter>_<line>_<fn> */
>   #define __initcall_id(fn)					\
> +	__PASTE(kmod_,						\
>   	__PASTE(__KBUILD_MODNAME,				\
>   	__PASTE(__,						\
>   	__PASTE(__COUNTER__,					\
>   	__PASTE(_,						\
>   	__PASTE(__LINE__,					\
> -	__PASTE(_, fn))))))
> +	__PASTE(_, fn)))))))
>   
>   /* Format: __<prefix>__<iid><id> */
>   #define __initcall_name(prefix, __iid, id)			\
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 1d581ba5df66f..b955602661240 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -20,7 +20,7 @@ name-fix-token = $(subst $(comma),_,$(subst -,_,$1))
>   name-fix = $(call stringify,$(call name-fix-token,$1))
>   basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
>   modname_flags  = -DKBUILD_MODNAME=$(call name-fix,$(modname)) \
> -		 -D__KBUILD_MODNAME=kmod_$(call name-fix-token,$(modname))
> +		 -D__KBUILD_MODNAME=$(call name-fix-token,$(modname))

As others have mentioned, this breaks modules.alias generation.

The following diff seems to fix it, although in introduces a slight
functional change if symbols do not actually follow the naming scheme.

diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index b3333560b95e..c3c06b944c69 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1489,14 +1489,11 @@ void handle_moddevtable(struct module *mod, 
struct elf_info *info,
  	if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT)
  		return;

-	/* All our symbols are of form 
__mod_device_table__kmod_<modname>__<type>__<name>. */
+	/* All our symbols are of form 
__mod_device_table__<modname>__<type>__<name>. */
  	if (!strstarts(symname, prefix))
  		return;

-	modname = strstr(symname, "__kmod_");
-	if (!modname)
-		return;
-	modname += strlen("__kmod_");
+	modname = symname + strlen(prefix);

  	type = strstr(modname, "__");
  	if (!type)

It would seem like rust generated symbols don't follow it exactly?

See module_device_table macro in rust/kernel/device_id.rs.

>   modfile_flags  = -DKBUILD_MODFILE=$(call stringify,$(modfile))
>   
>   _c_flags       = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), \


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ