livepatch: Skip task_call_func() for current task
authorJosh Poimboeuf <jpoimboe@kernel.org>
Fri, 24 Feb 2023 16:49:59 +0000 (08:49 -0800)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 22 Mar 2023 16:09:28 +0000 (17:09 +0100)
The current task doesn't need the scheduler's protection to unwind its
own stack.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Tested-by: Seth Forshee (DigitalOcean) <sforshee@kernel.org>
Link: https://lore.kernel.org/r/4b92e793462d532a05f03767151fa29db3e68e13.1677257135.git.jpoimboe@kernel.org
kernel/livepatch/transition.c

index 135fc73e2e5db06589cbdd462df4e46e31d7c1ba..824e2e3f07ddaf0c19c96c2056266e6370020ab6 100644 (file)
@@ -312,7 +312,11 @@ static bool klp_try_switch_task(struct task_struct *task)
         * functions.  If all goes well, switch the task to the target patch
         * state.
         */
-       ret = task_call_func(task, klp_check_and_switch_task, &old_name);
+       if (task == current)
+               ret = klp_check_and_switch_task(current, &old_name);
+       else
+               ret = task_call_func(task, klp_check_and_switch_task, &old_name);
+
        switch (ret) {
        case 0:         /* success */
                break;