From 10dde2bd66889f82bb37c16fe441f0ebb1c09c24 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 14 Sep 2026 16:30:31 +0200 Subject: module: pull out add_taint_module() to be public Other kernel code might want to call add_taint_module() so pull it out and make it global. If modules are not enabled, this defaults to a call to add_taint(), so all is fine. Reviewed-by: Johan Hovold Tested-by: Johan Hovold Reviewed-by: Bradley Morgan Reviewed-by: Petr Pavlu Acked-by: Danilo Krummrich Link: https://patch.msgid.link/20260914-bind_taint-v4-1-eadf8a090903@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- kernel/module/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'kernel/module') diff --git a/kernel/module/main.c b/kernel/module/main.c index d0e1e0bd2ad0..444d990c9983 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -191,11 +191,21 @@ static inline int strong_try_module_get(struct module *mod) return -ENOENT; } -static inline void add_taint_module(struct module *mod, unsigned flag, - enum lockdep_ok lockdep_ok) +/** + * add_taint_module: add a taint flag if not already set for a specific module + * @mod: pointer to the module that caused the problem + * @flag: one of the TAINT_* constants. + * @lockdep_ok: whether lock debugging is still OK. + * + * If something bad has gone wrong, you'll want @lockdebug_ok = false, but for + * some noteworthy-but-not-corrupting cases, it can be set to true. + */ +void add_taint_module(struct module *mod, unsigned flag, + enum lockdep_ok lockdep_ok) { add_taint(flag, lockdep_ok); - set_bit(flag, &mod->taints); + if (mod) + set_bit(flag, &mod->taints); } /* -- cgit v1.2.3 From de2dbaabbc2f995d97c216ec3ef79fcbde51a7c1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 14 Sep 2026 16:30:32 +0200 Subject: module: fix up documentation for add_taint() and add_taint_module() When add_taint_module() was added, the documentation for it was copied directly from add_taint(). But that documentation was a bit wrong (wrong variable name, and misleading boolean reference.) Fix up both functions to have the correct documentation for how to use the lockdep_ok parameter to these functions. Reported-by: Petr Pavlu Reviewed-by: Bradley Morgan Reviewed-by: Aaron Tomlin Acked-by: Danilo Krummrich Link: https://patch.msgid.link/20260914-bind_taint-v4-2-eadf8a090903@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- kernel/module/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'kernel/module') diff --git a/kernel/module/main.c b/kernel/module/main.c index 444d990c9983..369794876c3e 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -197,8 +197,9 @@ static inline int strong_try_module_get(struct module *mod) * @flag: one of the TAINT_* constants. * @lockdep_ok: whether lock debugging is still OK. * - * If something bad has gone wrong, you'll want @lockdebug_ok = false, but for - * some noteworthy-but-not-corrupting cases, it can be set to true. + * If something bad has gone wrong, you'll want + * @lockdep_ok = LOCKDEP_NOW_UNRELIABLE, but for some + * noteworthy-but-not-corrupting cases, it can be set to LOCKDEP_STILL_OK. */ void add_taint_module(struct module *mod, unsigned flag, enum lockdep_ok lockdep_ok) -- cgit v1.2.3