Re: [PATCH] kernel: Prevent prctl(PR_SET_PDEATHSIG) from racing with parent process exit

From: Mateusz Guzik

Date: Fri Sep 26 2025 - 21:51:40 EST


On Sat, Sep 27, 2025 at 1:58 AM Demi Marie Obenour
<demiobenour@xxxxxxxxx> wrote:
> My personal thought is that prctl(PR_SET_DEATHSIG) is rather rare,
> and also the lock is not held very long. In particular, exit
> already takes tasklist_lock for writing, and that is much more
> common. Therefore, I would be shocked if this added any significant
> contention outside of contrived benchmarks.
>

This is my suspicion as well, yes.

> What I _am_ concerned about is potential starvation,
> especially on PREEMPT_RT. Per the documentation:
>
> > - Because an rwlock_t writer cannot grant its priority to multiple
> > readers, a preempted low-priority reader will continue holding its lock,
> > thus starving even high-priority writers.
>
> This allows any user to hammer tasklist_lock
> at will. Is that going to be a problem?
>

I can't speak for Oleg, but he also expressed concern over free access
to readlock tasklist, presumably including in this context.

My take is that any thread can already freely abuse the lock in this
manner by spamming waitid or kill (and probably in some other ways).

The existing spots are not trivial to fix. Should someone do it, your
patch is comparatively a minor addition effort-wise.