Re: [PATCH] signal: Prevent exec() race
From: Oleg Nesterov
Date: Mon Aug 31 2026 - 08:49:48 EST
On 08/31, Thomas Gleixner wrote:
>
> +static inline void flush_pending_unlocked(struct task_struct *tsk)
> +{
> + flush_sigqueue(&tsk->pending);
> +}
> +
> void exit_signals(struct task_struct *tsk)
> {
> int group_stop = 0;
> @@ -3130,8 +3147,10 @@ void exit_signals(struct task_struct *ts
> cgroup_threadgroup_change_begin(tsk);
>
> if (thread_group_empty(tsk) || (tsk->signal->flags & SIGNAL_GROUP_EXIT)) {
> - tsk->flags |= PF_EXITING;
> + scoped_guard(spinlock_irq, &tsk->sighand->siglock)
> + tsk->flags |= PF_EXITING;
> cgroup_threadgroup_change_end(tsk);
> + flush_pending_unlocked(tsk);
Hmm... the exiting thread is still visible to for_each_thread().
Can't this flush_pending_unlocked() race with (say) do_sigaction() ?
Oleg.