Re: [PATCH v2] posix-cpu-timers: Dequeue per-thread timers before exchange_tids()

From: Thomas Gleixner

Date: Mon Aug 31 2026 - 08:00:56 EST


On Wed, Aug 26 2026 at 20:41, Hyunwoo Kim wrote:
> diff --git a/fs/exec.c b/fs/exec.c
> index 745f6eb5279e6..9b2d140bd9f2a 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -1003,6 +1003,18 @@ static int de_thread(struct task_struct *tsk)
> * the former thread group leader:
> */
>
> +#ifdef CONFIG_POSIX_TIMERS
> + /*
> + * exchange_tids() hands this thread's PID to the old leader,
> + * which is reaped right after. The PID lookup in
> + * timer_lock_sighand() then fails while the per thread CPU
> + * timers are still queued here, so dequeue them first.
> + */
> + spin_lock(lock);
> + posix_cpu_timers_exit(tsk);
> + spin_unlock(lock);
> +#endif
> +
> /* Become a process group leader with the old leader's pid.
> * The old leader becomes a thread of the this thread group.
> */

Similar to the other issue vs. POSIX timer signals this really wants to
be solved in exit() independent of non-leader exec(). Let me have a
look.