On 8/26/25 17:33, Petr Pavlu wrote:
On 8/25/25 11:15 AM, Jinchao Wang wrote:
Include reason in error message when force loading is disabled.
Signed-off-by: Jinchao Wang <wangjinchao...@gmail.com>
---
kernel/module/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/module/main.c b/kernel/module/main.c
index c66b26184936..a426bd8a18b5 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -1083,6 +1083,7 @@ int try_to_force_load(struct module *mod, const char
*reason)
add_taint_module(mod, TAINT_FORCED_MODULE, LOCKDEP_NOW_UNRELIABLE);
return 0;
#else
+ pr_err("%s force load is not supported\n", reason);
return -ENOEXEC;
#endif
}
The module name is already available at all points where
try_to_force_load() is called, so the new error message should include
it.
Additionally, we should be careful about the message. In the case of the
init_module syscall, the missing modversions and vermagic could mean
that the data was deliberately stripped by kmod because the module was
inserted with --force, or it could mean that the module lacks this data
in the first place. In other words, it is not always the case that that
we're reaching this logic because of a force load.
My suggestion would be to use the following:
pr_err("%s: %s, force load is not supported\n", mod->name, reason);
Good suggestion. Thanks.
--
Best regards,
Jinchao