Re: [PATCH] kprobes: Use synchronize_rcu_tasks_rude in kprobe_optimizer

From: Andrew Morton
Date: Wed Jan 17 2024 - 15:32:04 EST


On Wed, 17 Jan 2024 06:16:36 +0000 Chen Zhongjin <chenzhongjin@xxxxxxxxxx> wrote:

> There is a deadlock scenario in kprobe_optimizer():
>
> pid A pid B pid C
> kprobe_optimizer() do_exit() perf_kprobe_init()
> mutex_lock(&kprobe_mutex) exit_tasks_rcu_start() mutex_lock(&kprobe_mutex)
> synchronize_rcu_tasks() zap_pid_ns_processes() // waiting kprobe_mutex
> // waiting tasks_rcu_exit_srcu kernel_wait4()
> // waiting pid C exit
>
> To avoid this deadlock loop, use synchronize_rcu_tasks_rude() in kprobe_optimizer()
> rather than synchronize_rcu_tasks(). synchronize_rcu_tasks_rude() can also promise
> that all preempted tasks have scheduled, but it will not wait tasks_rcu_exit_srcu.
>
> Signed-off-by: Chen Zhongjin <chenzhongjin@xxxxxxxxxx>

Thanks. Should we backport this fix into earlier kernels? If so, are
we able to identify a suitable Fixes: target?