Re: [patch V2 1/8] signal: Prevent exec() race

From: Oleg Nesterov

Date: Sun Sep 06 2026 - 09:22:20 EST


On 09/05, Thomas Gleixner wrote:
>
> +/*
> + * Find the target task for the POSIX timer signal and prevent that a
> + * PIDTYPE_PID signal is queued on a task which has PF_EXITING set.
> + */
> +static inline struct task_struct *posixtimer_get_unignore_target(struct k_itimer *tmr)
> +{
> + struct task_struct *t = posixtimer_get_target(tmr);
> +
> + if (t && task_can_queue_signal(t, tmr->it_pid_type))
> + return t;
> +
> + return NULL;
> +}
...
> @@ -2136,7 +2183,7 @@ static void posixtimer_sig_unignore(stru
> * has exited by now, drop the reference count.
> */
> guard(rcu)();
> - target = posixtimer_get_target(tmr);
> + target = posixtimer_get_unignore_target(tmr);
> if (target)
> posixtimer_queue_sigqueue(&tmr->sigq, target, tmr->it_pid_type);

Not sure posixtimer_get_unignore_target() makes a lot of sence...
It has a single caller, and posixtimer_sig_unignore() can do

target = posixtimer_get_target(tmr);
if (target && task_can_queue_signal(target, tmr->it_pid_type))
posixtimer_queue_sigqueue(&tmr->sigq, target, tmr->it_pid_type);

But this is cosmetic and subjective. I believe the patch is correct.

Reviewed-by: Oleg Nesterov <oleg@xxxxxxxxxx>