From: Demi Marie Obenour <demiobenour@gmail.com>
To: Mateusz Guzik <mjguzik@gmail.com>, Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Christian Brauner <brauner@kernel.org>,
Linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kernel: Prevent prctl(PR_SET_PDEATHSIG) from racing with parent process exit
Date: Fri, 26 Sep 2025 19:58:05 -0400 [thread overview]
Message-ID: <2a3b72a8-6604-4c7e-a9b1-0c770efb29c6@gmail.com> (raw)
In-Reply-To: <CAGudoHGiO8vfyzuRmVHePR_TCeMSXjOv1TFpQ3i8Jk9+RMmTtQ@mail.gmail.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 2733 bytes --]
On 9/25/25 14:35, Mateusz Guzik wrote:
> It struck me that this mail thread is perhaps a little rude towards
> Demi, so I would like to state the reported race is legitimate and if
> it was reported against come core functionality it would count as
> "good spotting". It just so happens this is a corner case to something
> not-that-imporant and the proposed fix is rather heavy-weight (despite
> being perfectly sensible), so there is quite a bit of reluctance.
That makes sense. Thank you!
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.
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?
> With that out of the way...
>
> On Thu, Sep 25, 2025 at 6:29 PM Oleg Nesterov <oleg@redhat.com> wrote:
>>> That's very
>>> nasty as the full fence is quite expensive.
>>
>> Well, the exit_notify() path is already heavy, not sure smp_mb() or
>> smp_store_mb(real_parent, reaper) can add a noticeable difference.
>>
>
> Well the tasklist consumers already suffer a lot of avoidable
> overhead, but I'm going to save the spiel about it. Maybe instead I
> will post a patch to remove some. ;)
>
> I realized I never checked how often processes are exiting while still
> having children -- for legitimate workloads this is probably not that
> common either, so the fence would not even show up in typical usage?
>
> This could be answered with bpftrace over a bunch of workloads if
> someone cares to investigate.
Starvation on PREEMPT_RT is my only concern. See above.
>>> I don't know if makes any sense to add this.
>>
>> Neither me.
>>
>> OK. I won't argue with this patch. At least the usage of tasklist_lock is well
>> documented.
>>
>
> ye.. avoiding smp_mb may be a case of "premature optimization", except
> it is also simpler, so that's a really tough call. good news is that
> it's not mine to make ;-)
>
> I guess if the lock acquire goes in the sky is not going to fall,
> worst case this can get revisited later. So fwiw I would be leaning
> towards accepting the patch as well for the time being.
Thank you!
--
Sincerely,
Demi Marie Obenour (she/her/hers)
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 7253 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-09-26 23:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-13 22:28 [PATCH] kernel: Prevent prctl(PR_SET_PDEATHSIG) from racing with parent process exit Demi Marie Obenour via B4 Relay
2025-09-20 4:10 ` Demi Marie Obenour
2025-09-22 22:48 ` Andrew Morton
2025-09-23 12:03 ` Oleg Nesterov
2025-09-23 13:39 ` Mateusz Guzik
2025-09-25 16:28 ` Oleg Nesterov
2025-09-25 18:35 ` Mateusz Guzik
2025-09-25 18:50 ` Oleg Nesterov
2025-09-26 23:58 ` Demi Marie Obenour [this message]
2025-09-27 1:51 ` Mateusz Guzik
2025-10-07 12:53 ` Christian Brauner
2025-09-20 4:10 ` Demi Marie Obenour
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2a3b72a8-6604-4c7e-a9b1-0c770efb29c6@gmail.com \
--to=demiobenour@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=oleg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox