Re: [PATCH v5 0/4] livepatch: Do not lose exiting tasks during a transition
From: Ravindran, Binoy
Date: Sat Dec 05 2026 - 19:39:08 EST
On Sat, Dec 05, 2026 at 01:08:47PM -0500, Binoy Ravindran wrote:
> The SRCU wait covers every task in the exit window, whether or not it
> runs patched code, so a slow exit delays the transition by its length.
> The wait at init holds klp_mutex, and a task stuck in the window could
> make it last indefinitely.
Sashiko pointed out that this is worse than I wrote: a task can pin the
window on purpose. In a new PID namespace, fork PID 1 and PID 2. Let
PID 2 exit, and never reap it from its parent, which is outside the
namespace. Then kill PID 1. PID 1 sleeps in zap_pid_ns_processes(),
after exit_tasks_rcu_start(), until PID 2 is reaped. Where unprivileged
user namespaces are allowed, this needs no privilege.
I reproduced it on v7.4-rc2 under KVM, with a livepatch that does not
touch the exit path. With the window pinned, insmod on v5 blocked in
klp_init_transition() for 60 s, until it was killed, in all 9 runs. In
3 of them, an unprivileged user pinned the window from a user and PID
namespace. In the other 6, root pinned it from a PID namespace. With
the window pinned by root, 6 runs per kernel:
exit-list walk: enabled in 0.10-1.83 s, disabled in 1.01-1.92 s
no fix: enabled in 0.10-1.83 s, disabled in 0.21-1.92 s
The reproducer is a short C program, and I can post it.
This is the same kind of problem that 1612160b9127 ("rcu-tasks:
Eliminate deadlocks involving do_exit() and RCU tasks") removed from
RCU Tasks, by replacing this SRCU read side with the exit lists. The
exit-list walk, as in v4, does not have it: the pinned task's stack
holds no patched function, so it switches like any other sleeping task.
A livepatch that replaces do_exit() itself still waits for that task,
which is correct, and can be forced.
Paul, I know you preferred SRCU for its simpler code. Unless you see a
way around this, I plan to go back to the exit-list walk in v6, which
also visits the exiting tasks at init, and to address the other review
comments on v5. Does that sound right to you?
Thanks,
Binoy