Skip to content

Commit

Permalink
livepatch: Cancel transition a safe way for immediate patches
Browse files Browse the repository at this point in the history
klp_init_transition() does not set func->transition for immediate patches.
Then klp_ftrace_handler() could use the new code immediately. As a result,
it is not safe to put the livepatch module in klp_cancel_transition().

This patch reverts most of the last minute changes klp_cancel_transition().
It keeps the warning about a misuse because it still makes sense.

Fixes: 3ec2477 ("livepatch: allow removal of a disabled patch")
Signed-off-by: Petr Mladek <pmladek@suse.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Petr Mladek authored and Jiri Kosina committed Apr 11, 2017
1 parent 1051742 commit e679af6
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions kernel/livepatch/transition.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,11 @@ static void klp_complete_transition(void)
*/
void klp_cancel_transition(void)
{
struct klp_patch *patch = klp_transition_patch;
struct klp_object *obj;
struct klp_func *func;
bool immediate_func = false;

if (WARN_ON_ONCE(klp_target_state != KLP_PATCHED))
return;

klp_target_state = KLP_UNPATCHED;
klp_complete_transition();

/*
* In the enable error path, even immediate patches can be safely
* removed because the transition hasn't been started yet.
*
* klp_complete_transition() doesn't have a module_put() for immediate
* patches, so do it here.
*/
klp_for_each_object(patch, obj)
klp_for_each_func(obj, func)
if (func->immediate)
immediate_func = true;

if (patch->immediate || immediate_func)
module_put(patch->mod);
}

/*
Expand Down

0 comments on commit e679af6

Please sign in to comment.