Move try_to_force_load() call from check_version() to check_modstruct_version() to handle "no versions" case only once before other version checks.
Suggested-by: Petr Pavlu <petr.pa...@suse.com> Signed-off-by: Jinchao Wang <wangjinchao...@gmail.com> --- kernel/module/version.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/module/version.c b/kernel/module/version.c index 2beefeba82d9..7a458c681049 100644 --- a/kernel/module/version.c +++ b/kernel/module/version.c @@ -41,9 +41,9 @@ int check_version(const struct load_info *info, return 1; } - /* No versions at all? modprobe --force does this. */ + /* No versions? Ok, already tainted in check_modstruct_version(). */ if (versindex == 0) - return try_to_force_load(mod, symname) == 0; + return 1; versions = (void *)sechdrs[versindex].sh_addr; num_versions = sechdrs[versindex].sh_size @@ -80,6 +80,7 @@ int check_modstruct_version(const struct load_info *info, .gplok = true, }; bool have_symbol; + char *reason; /* * Since this should be found in kernel (which can't be removed), no @@ -90,6 +91,11 @@ int check_modstruct_version(const struct load_info *info, have_symbol = find_symbol(&fsa); BUG_ON(!have_symbol); + /* No versions at all? modprobe --force does this. */ + if (!info->index.vers && !info->index.vers_ext_crc) { + reason = "no versions for imported symbols"; + return try_to_force_load(mod, reason) == 0; + } return check_version(info, "module_layout", mod, fsa.crc); } -- 2.43.0