Skip to content

Commit 3205c36

Browse files
Libor Pechacekrustyrussell
authored andcommitted
module: Issue warnings when tainting kernel
While most of the locations where a kernel taint bit is set are accompanied with a warning message, there are two which set their bits silently. If the tainting module gets unloaded later on, it is almost impossible to tell what was the reason for setting the flag. Signed-off-by: Libor Pechacek <lpechacek@suse.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent c75b590 commit 3205c36

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎kernel/module.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2919,8 +2919,12 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
29192919
return -ENOEXEC;
29202920
}
29212921

2922-
if (!get_modinfo(info, "intree"))
2922+
if (!get_modinfo(info, "intree")) {
2923+
if (!test_taint(TAINT_OOT_MODULE))
2924+
pr_warn("%s: loading out-of-tree module taints kernel.\n",
2925+
mod->name);
29232926
add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK);
2927+
}
29242928

29252929
if (get_modinfo(info, "staging")) {
29262930
add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK);
@@ -3089,6 +3093,8 @@ static int move_module(struct module *mod, struct load_info *info)
30893093

30903094
static int check_module_license_and_versions(struct module *mod)
30913095
{
3096+
int prev_taint = test_taint(TAINT_PROPRIETARY_MODULE);
3097+
30923098
/*
30933099
* ndiswrapper is under GPL by itself, but loads proprietary modules.
30943100
* Don't use add_taint_module(), as it would prevent ndiswrapper from
@@ -3107,6 +3113,9 @@ static int check_module_license_and_versions(struct module *mod)
31073113
add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
31083114
LOCKDEP_NOW_UNRELIABLE);
31093115

3116+
if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE))
3117+
pr_warn("%s: module license taints kernel.\n", mod->name);
3118+
31103119
#ifdef CONFIG_MODVERSIONS
31113120
if ((mod->num_syms && !mod->crcs)
31123121
|| (mod->num_gpl_syms && !mod->gpl_crcs)

0 commit comments

Comments
 (0)