Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique

From: Alexey Gladkov
Date: Mon Jun 02 2025 - 14:44:54 EST


On Tue, Jun 03, 2025 at 03:00:07AM +0900, Masahiro Yamada wrote:
> On Mon, Jun 2, 2025 at 5:24 PM Alexey Gladkov <legion@xxxxxxxxxx> wrote:
> >
> > On Mon, Jun 02, 2025 at 04:52:36PM +0900, Masahiro Yamada wrote:
> > > On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@xxxxxxxxxx> wrote:
> > > >
> > > > In order to avoid symbol conflicts if they appear in the same binary, a
> > > > more unique alias identifier can be generated.
> > > >
> > > > Signed-off-by: Alexey Gladkov <legion@xxxxxxxxxx>
> > > > Reviewed-by: Petr Pavlu <petr.pavlu@xxxxxxxx>
> > > > ---
> > > > include/linux/module.h | 14 ++++++++++++--
> > > > scripts/mod/file2alias.c | 18 ++++++++++++++----
> > > > 2 files changed, 26 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/include/linux/module.h b/include/linux/module.h
> > > > index 88048561360f..e7506684069d 100644
> > > > --- a/include/linux/module.h
> > > > +++ b/include/linux/module.h
> > > > @@ -249,10 +249,20 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
> > > > /* What your module does. */
> > > > #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
> > > >
> > > > +/* Format: __mod_device_table__<counter>__kmod_<modname>__<type>__<name> */
> > >
> > > This format relies on module-name mangling, but
> > > I hope we will be able to stop doing it some day.
> >
> > I didn't like this approach either when I found out how it was
> > implemented.
>
> Yeah, I dislike it.
>
> I hope we can stop this historical mistake:
> https://lore.kernel.org/lkml/20250602130609.402581-1-masahiroy@xxxxxxxxxx/
>
> Once we stop doing that, __KBUILD_MODNAME will not match to KBUILD_MODNAME.

Do I understand you correctly that I cannot use __KBUILD_MODNAME now ?

> Also, you need to be careful about the rust side, as
> you did not take care of it.
>
> https://github.com/torvalds/linux/blob/v6.15/rust/kernel/device_id.rs#L157

Oh. This will make it much more complicated because I don't know rust
well. :(

I found a few more issues with modules when they compile as part of the
kernel, but was hoping to fix them after these patches.

--
Rgrds, legion