livepatch: Trigger WARNING if livepatch function fails due to recursion
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 6 Nov 2020 02:32:42 +0000 (21:32 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 6 Nov 2020 13:41:47 +0000 (08:41 -0500)
If for some reason a function is called that triggers the recursion
detection of live patching, trigger a warning. By not executing the live
patch code, it is possible that the old unpatched function will be called
placing the system into an unknown state.

Link: https://lore.kernel.org/r/20201029145709.GD16774@alley
Link: https://lkml.kernel.org/r/20201106023547.312639435@goodmis.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Joe Lawrence <joe.lawrence@redhat.com>
Cc: live-patching@vger.kernel.org
Suggested-by: Miroslav Benes <mbenes@suse.cz>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/livepatch/patch.c

index 6c0164d..15480bf 100644 (file)
@@ -50,7 +50,7 @@ static void notrace klp_ftrace_handler(unsigned long ip,
        ops = container_of(fops, struct klp_ops, fops);
 
        bit = ftrace_test_recursion_trylock();
-       if (bit < 0)
+       if (WARN_ON_ONCE(bit < 0))
                return;
        /*
         * A variant of synchronize_rcu() is used to allow patching functions