On Wed, Feb 12, 2025 at 07:54:21PM +0800, Yafang Shao wrote: > 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