aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/livepatch/core.c
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2015-01-20 10:26:18 -0500
committerJiri Kosina <jkosina@suse.cz>2015-01-20 14:09:41 -0500
commit83a90bb1345767f0cb96d242fd8b9db44b2b0e17 (patch)
tree68a4466302071ededbed9c50f4d80e431e656f32 /kernel/livepatch/core.c
parent32b7eb877165fdb29f1722071c6c64ced1789014 (diff)
livepatch: enforce patch stacking semantics
Only allow the topmost patch on the stack to be enabled or disabled, so that patches can't be removed or added in an arbitrary order. Suggested-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Reviewed-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'kernel/livepatch/core.c')
-rw-r--r--kernel/livepatch/core.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 3d9c00b5223a..2401e7f955d3 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -379,6 +379,11 @@ static int __klp_disable_patch(struct klp_patch *patch)
379 struct klp_object *obj; 379 struct klp_object *obj;
380 int ret; 380 int ret;
381 381
382 /* enforce stacking: only the last enabled patch can be disabled */
383 if (!list_is_last(&patch->list, &klp_patches) &&
384 list_next_entry(patch, list)->state == KLP_ENABLED)
385 return -EBUSY;
386
382 pr_notice("disabling patch '%s'\n", patch->mod->name); 387 pr_notice("disabling patch '%s'\n", patch->mod->name);
383 388
384 for (obj = patch->objs; obj->funcs; obj++) { 389 for (obj = patch->objs; obj->funcs; obj++) {
@@ -435,6 +440,11 @@ static int __klp_enable_patch(struct klp_patch *patch)
435 if (WARN_ON(patch->state != KLP_DISABLED)) 440 if (WARN_ON(patch->state != KLP_DISABLED))
436 return -EINVAL; 441 return -EINVAL;
437 442
443 /* enforce stacking: only the first disabled patch can be enabled */
444 if (patch->list.prev != &klp_patches &&
445 list_prev_entry(patch, list)->state == KLP_DISABLED)
446 return -EBUSY;
447
438 pr_notice_once("tainting kernel with TAINT_LIVEPATCH\n"); 448 pr_notice_once("tainting kernel with TAINT_LIVEPATCH\n");
439 add_taint(TAINT_LIVEPATCH, LOCKDEP_STILL_OK); 449 add_taint(TAINT_LIVEPATCH, LOCKDEP_STILL_OK);
440 450