livepatch/module: make TAINT_LIVEPATCH module-specific
authorJosh Poimboeuf <jpoimboe@redhat.com>
Thu, 25 Aug 2016 15:04:45 +0000 (10:04 -0500)
committerJiri Kosina <jkosina@suse.cz>
Fri, 26 Aug 2016 12:42:08 +0000 (14:42 +0200)
There's no reliable way to determine which module tainted the kernel
with TAINT_LIVEPATCH.  For example, /sys/module/<klp module>/taint
doesn't report it.  Neither does the "mod -t" command in the crash tool.

Make it crystal clear who the guilty party is by associating
TAINT_LIVEPATCH with any module which sets the "livepatch" modinfo
attribute.  The flag will still get set in the kernel like before, but
now it also sets the same flag in mod->taint.

Note that now the taint flag gets set when the module is loaded rather
than when it's enabled.

I also renamed find_livepatch_modinfo() to check_modinfo_livepatch() to
better reflect its purpose: it's basically a livepatch-specific
sub-function of check_modinfo().

Reported-by: Chunyu Hu <chuhu@redhat.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Jessica Yu <jeyu@redhat.com>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
kernel/livepatch/core.c
kernel/module.c

index 5fbabe022286634c244fde4ad825e59ab054614a..af4643873e7179c0e750d3d69a665844d06f4725 100644 (file)
@@ -545,9 +545,6 @@ static int __klp_enable_patch(struct klp_patch *patch)
            list_prev_entry(patch, list)->state == KLP_DISABLED)
                return -EBUSY;
 
-       pr_notice_once("tainting kernel with TAINT_LIVEPATCH\n");
-       add_taint(TAINT_LIVEPATCH, LOCKDEP_STILL_OK);
-
        pr_notice("enabling patch '%s'\n", patch->mod->name);
 
        klp_for_each_object(patch, obj) {
index 529efae9f481e6e071d084735bd54ad5e024b153..f57dd63186e63c647e4566c828b1258fbcdb8724 100644 (file)
@@ -1149,6 +1149,8 @@ static size_t module_flags_taint(struct module *mod, char *buf)
                buf[l++] = 'C';
        if (mod->taints & (1 << TAINT_UNSIGNED_MODULE))
                buf[l++] = 'E';
+       if (mod->taints & (1 << TAINT_LIVEPATCH))
+               buf[l++] = 'K';
        /*
         * TAINT_FORCED_RMMOD: could be added.
         * TAINT_CPU_OUT_OF_SPEC, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't
@@ -2792,14 +2794,17 @@ static int copy_chunked_from_user(void *dst, const void __user *usrc, unsigned l
 }
 
 #ifdef CONFIG_LIVEPATCH
-static int find_livepatch_modinfo(struct module *mod, struct load_info *info)
+static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
 {
-       mod->klp = get_modinfo(info, "livepatch") ? true : false;
+       if (get_modinfo(info, "livepatch")) {
+               mod->klp = true;
+               add_taint_module(mod, TAINT_LIVEPATCH, LOCKDEP_STILL_OK);
+       }
 
        return 0;
 }
 #else /* !CONFIG_LIVEPATCH */
-static int find_livepatch_modinfo(struct module *mod, struct load_info *info)
+static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
 {
        if (get_modinfo(info, "livepatch")) {
                pr_err("%s: module is marked as livepatch module, but livepatch support is disabled",
@@ -2969,7 +2974,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
                        "is unknown, you have been warned.\n", mod->name);
        }
 
-       err = find_livepatch_modinfo(mod, info);
+       err = check_modinfo_livepatch(mod, info);
        if (err)
                return err;
 
This page took 0.032863 seconds and 5 git commands to generate.