Re: [PATCH 2/3] livepatch: Avoid blocking tasklist_lock too long

From
Josh Poimboeuf <jpoimboe@kernel.org>
Date
2025-02-13 02:47:50
Reply to
Yafang Shao, 2025-02-12
On Wed, Feb 12, 2025 at 07:54:21PM +0800, Yafang Shao wrote:
quoted hunk ↗ jump to hunk
Before the newly forked task is added to the task list, it doesn’t
execute any code and can always be considered safe during the KLP
transition. Therefore, we could replace klp_copy_process() with
klp_init_process(), where we simply set patch_state to
KLP_TRANSITION_IDLE, as shown below:
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2544,7 +2544,9 @@ __latent_entropy struct task_struct *copy_process(
                p->exit_signal = args->exit_signal;
        }

-       klp_copy_process(p);
+       // klp_init_process(p);
+       clear_tsk_thread_flag(child, TIF_PATCH_PENDING);
+       child->patch_state = KLP_TRANSITION_IDLE;

        sched_core_fork(p);
Some additional changes may be needed, such as removing
WARN_ON_ONCE(patch_state == KLP_TRANSITION_IDLE) in
klp_ftrace_handler().
Oops, I managed to miss this email before my reply.  Looks like we had a
similar idea :-)

-- 
Josh
Thread (30 messages) 30 messages, 3 authors, last reply 2025-02-18
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help