Re: [PATCH 0/2] livepatch: Do not lose exiting tasks during a transition
From: Yafang Shao
Date: Mon Nov 23 2026 - 23:01:01 EST
On Tue, Nov 24, 2026 at 6:40 AM Ravindran, Binoy <binoy@xxxxxx> wrote:
>
Hello Ravindran,
Thanks for driving this fix.
>
> The two issues Sashiko reported on patch 2 are valid:
>
> 1. An exiting task that has not been unhashed is on both the task list
> and an exit list, so klp_start_transition() can visit it twice and
> set TIF_PATCH_PENDING again after it has switched.
>
> 2. Between exit_tasks_rcu_finish() and its final switch, an exiting
> task is on neither list and can still enter patched code with a
> stale patch_state.
We also discussed this issue at the thread:
https://lore.kernel.org/live-patching/CALOAHbA9WHPjeZKUcUkwULagQjTMfqAdAg+akqPzbZ7Byc=qrw@xxxxxxxxxxxxxx/
and Josh suggested something along the lines of what you are proposing,
https://lore.kernel.org/live-patching/20250124010848.pdcxokfsk2ngrowl@jpoimboe/
I did not take it for the same reason Sashiko raised in issue 2: the
RCU exit list narrows the race window but does not close it.
I could not see how klp_synchronize_transition(), as you describe
below, completely resolves it. Could you please explain that in
detail?
>
> v2 will walk the exit lists under tasklist_lock and skip tasks that are
> still hashed, so each task is visited exactly once. It will also call
> klp_synchronize_transition() before func->transition is set and before
> completion, to wait out tasks in that last stretch. It will document
> rtp_exit_cursor as well.
>
> I'll post v2 after testing it on mainline. Please hold off on
> reviewing v1.
--
Regards
Yafang