]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
module: Issue warnings when tainting kernel
authorLibor Pechacek <lpechacek@suse.com>
Wed, 13 Apr 2016 01:36:12 +0000 (11:06 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 27 Jul 2016 03:08:00 +0000 (12:38 +0930)
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>
kernel/module.c

index 9e04a4210a4a05b74654a6169f96c93f26bc62f6..0b4f3a85d4fc7cf90ec71d01b8b6544d11ce7691 100644 (file)
@@ -2919,8 +2919,12 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
                return -ENOEXEC;
        }
 
-       if (!get_modinfo(info, "intree"))
+       if (!get_modinfo(info, "intree")) {
+               if (!test_taint(TAINT_OOT_MODULE))
+                       pr_warn("%s: loading out-of-tree module taints kernel.\n",
+                               mod->name);
                add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK);
+       }
 
        if (get_modinfo(info, "staging")) {
                add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK);
@@ -3089,6 +3093,8 @@ static int move_module(struct module *mod, struct load_info *info)
 
 static int check_module_license_and_versions(struct module *mod)
 {
+       int prev_taint = test_taint(TAINT_PROPRIETARY_MODULE);
+
        /*
         * ndiswrapper is under GPL by itself, but loads proprietary modules.
         * 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)
                add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
                                 LOCKDEP_NOW_UNRELIABLE);
 
+       if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE))
+               pr_warn("%s: module license taints kernel.\n", mod->name);
+
 #ifdef CONFIG_MODVERSIONS
        if ((mod->num_syms && !mod->crcs)
            || (mod->num_gpl_syms && !mod->gpl_crcs)