On 8/25/25 11:15 AM, Jinchao Wang wrote: > Move try_to_force_load() call from check_version() to > check_modstruct_version() to handle "no versions" case only once before > other version checks. > > This prevents duplicate force load attempts and makes the error message > show the proper reason. > > Signed-off-by: Jinchao Wang <wangjinchao...@gmail.com> > --- > kernel/module/version.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/kernel/module/version.c b/kernel/module/version.c > index 2beefeba82d9..3f07fd03cb30 100644 > --- a/kernel/module/version.c > +++ b/kernel/module/version.c > @@ -41,10 +41,6 @@ int check_version(const struct load_info *info, > return 1; > } > > - /* No versions at all? modprobe --force does this. */ > - if (versindex == 0) > - return try_to_force_load(mod, symname) == 0; > - > versions = (void *)sechdrs[versindex].sh_addr; > num_versions = sechdrs[versindex].sh_size > / sizeof(struct modversion_info);
Removing this return completely means that when versindex == 0, the function incorrectly looks at the dummy section #0 and eventually calls pr_warn_once("%s: no symbol version for %s\n", ...). As I outlined in my prototype patch previously [1], I think this should be changed to: /* No versions? Ok, already tainted in check_modstruct_version(). */ if (versindex == 0) return 1; > @@ -81,6 +77,11 @@ int check_modstruct_version(const struct load_info *info, > }; > bool have_symbol; > > + /* No versions at all? modprobe --force does this. */ > + if (info->index.vers == 0 && > + try_to_force_load(mod, "no versions module")) > + return 1; > + > /* > * Since this should be found in kernel (which can't be removed), no > * locking is necessary. Regardless use a RCU read section to keep I suggest that the reason message should say "no versions for imported symbols" to indicate which version data is missing and to be consistent with check_export_symbol_versions(), which uses "no versions for exported symbols". [1] https://lore.kernel.org/linux-modules/3992b57d-3d8b-4d60-bc4a-f227f712d...@suse.com/ -- Thanks, Petr