modpost: distinguish same module paths from different dump files
Subsystems (2)
PATCH 1/1 modpost: distinguish same module paths from different dump files
Since commit 13b25489b6f8 ("kbuild: change working directory to external module directory with M="), module paths are always relative to the top of the external module tree.
The module paths recorded in Module.symvers is no longer globally unique when they are passed via KBUILD_EXTRA_SYMBOLS for building other external modules, which may result in false positive "exported twice" errors. Such errors should not occur because external modules should be able to override in-tree modules.
To address this, record the dump file path in struct module and check it when searching for a module.
---
scripts/mod/modpost.c | 17 +++++++++-------- scripts/mod/modpost.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-)
scripts/mod/modpost.c +9 -8
@@ -155,12 +155,13 @@ char *get_line(char **stringp)/* A list of all modules we processed */ LIST_HEAD (modules); -static struct module *find_module (const char *modname) +static struct module *find_module (const char *filename,const char *modname) {struct module *mod;list_for_each_entry (mod, &modules, list) { -if (strcmp (mod->name, modname) ==0 ) +if (!strcmp (mod->dump_file, filename) && + !strcmp (mod->name, modname))return mod; }return NULL ;
@@ -2030,10 +2031,10 @@ static void read_dump(const char *fname)continue ; } - mod =find_module (modname); + mod =find_module (fname, modname);if (!mod) { mod =new_module (modname,strlen (modname)); - mod->from_dump = true; + mod->dump_file = fname; } s =sym_add_exported (symname, mod, gpl_only, namespace);sym_set_crc (s, crc);
@@ -2052,7 +2053,7 @@ static void write_dump(const char *fname)struct symbol *sym;list_for_each_entry (mod, &modules, list) { -if (mod->from_dump) +if (mod->dump_file)continue ;list_for_each_entry (sym, &mod->exported_symbols, list) {if (trim_unused_exports && !sym->used)
@@ -2076,7 +2077,7 @@ static void write_namespace_deps_files(const char *fname)list_for_each_entry (mod, &modules, list) { -if (mod->from_dump ||list_empty (&mod->missing_namespaces)) +if (mod->dump_file ||list_empty (&mod->missing_namespaces))continue ;buf_printf (&ns_deps_buf,"%s.ko:" , mod->name);
@@ -2194,7 +2195,7 @@ int main(int argc, char **argv)read_symbols_from_files (files_source);list_for_each_entry (mod, &modules, list) { -if (mod->from_dump || mod->is_vmlinux) +if (mod->dump_file || mod->is_vmlinux)continue ;check_modname_len (mod);
@@ -2205,7 +2206,7 @@ int main(int argc, char **argv)handle_white_list_exports (unused_exports_white_list);list_for_each_entry (mod, &modules, list) { -if (mod->from_dump) +if (mod->dump_file)continue ;if (mod->is_vmlinux)
scripts/mod/modpost.h +2 -1
@@ -95,14 +95,15 @@ struct module_alias {/** * struct module - represent a module (vmlinux or *.ko) * +* @dump_file: path to the .symvers file if loaded from a file * @aliases: list head for module_aliases */ struct module {struct list_head list;struct list_head exported_symbols;struct list_head unresolved_symbols; +const char *dump_file;bool is_gpl_compatible; -bool from_dump;/* true if module was loaded from *.symvers */ bool is_vmlinux;bool seen;bool has_init;
Signature · 1 line
2.43.0
Quoted 6 lines · Masahiro Yamada
Since commit
13b25489b6f8("kbuild: change working directory to external module directory with M="), module paths are always relative to the top of the external module tree.The module paths recorded in Module.symvers is no longer globally unique
is -> are
Quoted 13 lines
when they are passed via
KBUILD_EXTRA_SYMBOLSfor building other external modules, which may result in false positive "exported twice" errors. Such errors should not occur because external modules should be able to override in-tree modules.To address this, record the dump file path in struct module and check it when searching for a module.
Fixes 13b25489b6f8 ("kbuild: change working directory to external module directory with M=")Reported-by Jon Hunter <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>---
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 103 lines · Masahiro Yamada
Since commit
13b25489b6f8("kbuild: change working directory to external module directory with M="), module paths are always relative to the top of the external module tree.The module paths recorded in Module.symvers is no longer globally unique when they are passed via
KBUILD_EXTRA_SYMBOLSfor building other external modules, which may result in false positive "exported twice" errors. Such errors should not occur because external modules should be able to override in-tree modules.To address this, record the dump file path in struct module and check it when searching for a module.
Fixes 13b25489b6f8 ("kbuild: change working directory to external module directory with M=")Reported-by Jon Hunter <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>---
scripts/mod/modpost.c | 17 +++++++++-------- scripts/mod/modpost.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-)scripts/mod/modpost.c +9
-8@@ -155,12 +155,13 @@ char *get_line(char **stringp)/* A list of all modules we processed */ LIST_HEAD (modules); -static struct module *find_module (const char *modname) +static struct module *find_module (const char *filename,const char *modname) {struct module *mod;list_for_each_entry (mod, &modules, list) { -if (strcmp (mod->name, modname) ==0 ) +if (!strcmp (mod->dump_file, filename) && + !strcmp (mod->name, modname))return mod; }return NULL ;@@ -2030,10 +2031,10 @@ static void read_dump(const char *fname)continue ; } - mod =find_module (modname); + mod =find_module (fname, modname);if (!mod) { mod =new_module (modname,strlen (modname)); - mod->from_dump = true; + mod->dump_file = fname; } s =sym_add_exported (symname, mod, gpl_only, namespace);sym_set_crc (s, crc);@@ -2052,7 +2053,7 @@ static void write_dump(const char *fname)struct symbol *sym;list_for_each_entry (mod, &modules, list) { -if (mod->from_dump) +if (mod->dump_file)continue ;list_for_each_entry (sym, &mod->exported_symbols, list) {if (trim_unused_exports && !sym->used)@@ -2076,7 +2077,7 @@ static void write_namespace_deps_files(const char *fname)list_for_each_entry (mod, &modules, list) { -if (mod->from_dump ||list_empty (&mod->missing_namespaces)) +if (mod->dump_file ||list_empty (&mod->missing_namespaces))continue ;buf_printf (&ns_deps_buf,"%s.ko:" , mod->name);@@ -2194,7 +2195,7 @@ int main(int argc, char **argv)read_symbols_from_files (files_source);list_for_each_entry (mod, &modules, list) { -if (mod->from_dump || mod->is_vmlinux) +if (mod->dump_file || mod->is_vmlinux)continue ;check_modname_len (mod);@@ -2205,7 +2206,7 @@ int main(int argc, char **argv)handle_white_list_exports (unused_exports_white_list);list_for_each_entry (mod, &modules, list) { -if (mod->from_dump) +if (mod->dump_file)continue ;if (mod->is_vmlinux)scripts/mod/modpost.h +1
-0@@ -95,14 +95,15 @@ struct module_alias {/** * struct module - represent a module (vmlinux or *.ko) * +* @dump_file: path to the .symvers file if loaded from a file * @aliases: list head for module_aliases */
scripts/mod/modpost.h struct module_alias { · line 109
Quoted 10 lines
scripts/mod/modpost.h +1
-1struct module {struct list_head list;struct list_head exported_symbols;struct list_head unresolved_symbols; +const char *dump_file;bool is_gpl_compatible; -bool from_dump;/* true if module was loaded from *.symvers */ bool is_vmlinux;bool seen;bool has_init;
Thanks for fixing!
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerQuoted 111 lines · Jon Hunter
Quoted 104 lines · Masahiro Yamada
Since commit
13b25489b6f8("kbuild: change working directory to external module directory with M="), module paths are always relative to the top of the external module tree.The module paths recorded in Module.symvers is no longer globally unique when they are passed via
KBUILD_EXTRA_SYMBOLSfor building other external modules, which may result in false positive "exported twice" errors. Such errors should not occur because external modules should be able to override in-tree modules.To address this, record the dump file path in struct module and check it when searching for a module.
Fixes 13b25489b6f8 ("kbuild: change working directory to external module directory with M=")Reported-by Jon Hunter <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>---
scripts/mod/modpost.c| 17 +++++++++--------
scripts/mod/modpost.h| 3 ++-2 files changed, 11 insertions(+), 9 deletions(-)scripts/mod/modpost.c +9
-8@@ -155,12 +155,13 @@ char *get_line(char **stringp) /* A list of all modules we processed */ LIST_HEAD(modules); -static struct module *find_module (const char *modname) +static struct module *find_module (const char *filename,const char *modname) { struct module *mod; list_for_each_entry(mod, &modules, list) { - if (strcmp(mod->name, modname) == 0) + if (!strcmp(mod->dump_file, filename) && + !strcmp(mod->name, modname)) return mod; } return NULL;@@ -2030,10 +2031,10 @@ static void read_dump(const char *fname) continue; } - mod = find_module(modname); + mod = find_module(fname, modname); if (!mod) { mod = new_module(modname, strlen(modname)); - mod->from_dump = true; + mod->dump_file = fname; } s = sym_add_exported(symname, mod, gpl_only, namespace); sym_set_crc(s, crc);@@ -2052,7 +2053,7 @@ static void write_dump(const char *fname) struct symbol *sym; list_for_each_entry(mod, &modules, list) { - if (mod->from_dump) + if (mod->dump_file) continue; list_for_each_entry(sym, &mod->exported_symbols, list) { if (trim_unused_exports && !sym->used)@@ -2076,7 +2077,7 @@ static void write_namespace_deps_files(const char *fname) list_for_each_entry(mod, &modules, list) { - if (mod->from_dump || list_empty(&mod->missing_namespaces)) + if (mod->dump_file || list_empty(&mod->missing_namespaces)) continue; buf_printf(&ns_deps_buf, "%s.ko:", mod->name);@@ -2194,7 +2195,7 @@ int main(int argc, char **argv) read_symbols_from_files(files_source); list_for_each_entry(mod, &modules, list) { - if (mod->from_dump || mod->is_vmlinux) + if (mod->dump_file || mod->is_vmlinux) continue; check_modname_len(mod);@@ -2205,7 +2206,7 @@ int main(int argc, char **argv) handle_white_list_exports(unused_exports_white_list); list_for_each_entry(mod, &modules, list) { - if (mod->from_dump) + if (mod->dump_file) continue; if (mod->is_vmlinux)scripts/mod/modpost.h +2
-1@@ -95,14 +95,15 @@ struct module_alias {/** * struct module - represent a module (vmlinux or *.ko) * +* @dump_file: path to the .symvers file if loaded from a file * @aliases: list head for module_aliases */ struct module { struct list_head list; struct list_head exported_symbols; struct list_head unresolved_symbols; + const char *dump_file; bool is_gpl_compatible; - bool from_dump; /* true if module was loaded from *.symvers */ bool is_vmlinux; bool seen;Quoted 1 line
bool
has_init;Thanks for fixing!
Quoted 1 line
Tested-by Jon Hunter <[email protected]>
I have not seen this land in -next yet. Would be great to get this applied.
Thanks!
Jon
Signature · 1 line
nvpublic
Quoted 116 lines · Jon Hunter
Quoted 113 lines · Jon Hunter
Quoted 106 lines · Masahiro Yamada
Since commit
13b25489b6f8("kbuild: change working directory to external module directory with M="), module paths are always relative to the top of the external module tree.The module paths recorded in Module.symvers is no longer globally unique when they are passed via
KBUILD_EXTRA_SYMBOLSfor building other external modules, which may result in false positive "exported twice" errors. Such errors should not occur because external modules should be able to override in-tree modules.To address this, record the dump file path in struct module and check it when searching for a module.
Fixes 13b25489b6f8 ("kbuild: change working directory to externalmodule directory with M=")
Reported-by Jon Hunter <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>---
scripts/mod/modpost.c | 17 +++++++++-------- scripts/mod/modpost.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-)scripts/mod/modpost.c +9
-8@@ -155,12 +155,13 @@ char *get_line(char **stringp)/* A list of all modules we processed */ LIST_HEAD (modules); -static struct module *find_module (const char *modname) +static struct module *find_module (const char *filename,const char *modname) {struct module *mod;list_for_each_entry (mod, &modules, list) { -if (strcmp (mod->name, modname) ==0 ) +if (!strcmp (mod->dump_file, filename) && + !strcmp (mod->name, modname))return mod; }return NULL ;@@ -2030,10 +2031,10 @@ static void read_dump(const char *fname)continue ; } - mod =find_module (modname); + mod =find_module (fname, modname);if (!mod) { mod =new_module (modname,strlen (modname)); - mod->from_dump = true; + mod->dump_file = fname; } s =sym_add_exported (symname, mod, gpl_only, namespace);sym_set_crc (s, crc);@@ -2052,7 +2053,7 @@ static void write_dump(const char *fname)struct symbol *sym;list_for_each_entry (mod, &modules, list) { -if (mod->from_dump) +if (mod->dump_file)continue ;list_for_each_entry (sym, &mod->exported_symbols, list) {if (trim_unused_exports && !sym->used)@@ -2076,7 +2077,7 @@ static void write_namespace_deps_files(const char *fname)list_for_each_entry (mod, &modules, list) { -if (mod->from_dump ||list_empty (&mod->missing_namespaces)) +if (mod->dump_file ||list_empty (&mod->missing_namespaces))continue ;buf_printf (&ns_deps_buf,"%s.ko:" , mod->name);@@ -2194,7 +2195,7 @@ int main(int argc, char **argv)read_symbols_from_files (files_source);list_for_each_entry (mod, &modules, list) { -if (mod->from_dump || mod->is_vmlinux) +if (mod->dump_file || mod->is_vmlinux)continue ;check_modname_len (mod);@@ -2205,7 +2206,7 @@ int main(int argc, char **argv)handle_white_list_exports (unused_exports_white_list);list_for_each_entry (mod, &modules, list) { -if (mod->from_dump) +if (mod->dump_file)continue ;if (mod->is_vmlinux)scripts/mod/modpost.h +2
-1@@ -95,14 +95,15 @@ struct module_alias {/** * struct module - represent a module (vmlinux or *.ko) * +* @dump_file: path to the .symvers file if loaded from a file * @aliases: list head for module_aliases */ struct module {struct list_head list;struct list_head exported_symbols;struct list_head unresolved_symbols; +const char *dump_file;bool is_gpl_compatible; -bool from_dump;/* true if module was loaded from *.symvers */bool is_vmlinux;bool seen;Quoted 1 line
bool has_init;Thanks for fixing!
Quoted 5 lines
Quoted 1 line
Tested-by Jon Hunter <[email protected]>I have not seen this land in -next yet. Would be great to get this applied.
Now applied to linux-kbuild/fixes.
Signature · 2 lines
Best Regards Masahiro Yamada