summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@kernel.org>2023-02-24 08:49:59 -0800
committerPeter Zijlstra <peterz@infradead.org>2023-03-22 17:09:28 +0100
commit383439d3d400d4c5a7ffb4495124adc6be6a05e2 (patch)
treeb72ab5d6a2b8a28cd0d49dd21ebbbdb640d6feac
parente92606fa172f63a26054885b9715be86c643229d (diff)
livepatch: Skip task_call_func() for current task
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
-rw-r--r--kernel/livepatch/transition.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c
index 135fc73e2e5d..824e2e3f07dd 100644
--- a/kernel/livepatch/transition.c
+++ b/kernel/livepatch/transition.c
@@ -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;