From: Oleg Nesterov <oleg@redhat.com>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Demi Marie Obenour <demiobenour@gmail.com>,
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: Thu, 25 Sep 2025 18:28:00 +0200 [thread overview]
Message-ID: <20250925162759.GA25838@redhat.com> (raw)
In-Reply-To: <CAGudoHED4nx8QT-yw-zdcUApUyvt2HCOR9c3SQ3tAm9J7Q1jEQ@mail.gmail.com>
Sorry for the late reply...
On 09/23, Mateusz Guzik wrote:
>
> On Tue, Sep 23, 2025 at 2:05 PM Oleg Nesterov <oleg@redhat.com> wrote:
> > As you correctly pointed out, forget_original_parent/prctl lack the necessary
> > barries. So lets add the barriers instead of abusing tasklist? As for sys_prctl(),
> > I think that ret-to-user-mode + enter-the-kernel-mode should act as a full
> > barrier, so it only needs WRITE_ONCE()...
> >
>
> So I looked over this and I think I see why you are not eager to fix
> the problem to begin with. ;)
>
> I agree with reluctance to take tasklist lock to handle
> PR_SET_PDEATHSIG, but I wonder if in practice this is used rarely
> enough that the lock trip would not be a problem? It avoids any
> modifications to the exit codepath.
Yes... I mostly dislike the fact that this patch adds another possibility
to easily abuse the global tasklist lock from userspace...
> By barriers I presume you meant smp_mb() between
> RCU_INIT_POINTER(t->real_parent, reaper) and
> READ_ONCE(t->pdeath_signal) in forget_original_parent.
Yes,
> 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.
> > Or perhaps user-space can do something else to sync with the exiting parent
> > instead of using getppid() ?
> >
>
> I never put any thought concerning this mechanism, I do think it
> nicely showcases the prctl at hand is kind of crap. The non-crap
> version would pass the PID you think your parent is, so that you do
> this race-free.
Or PR_SET_PDEATHSIG_FOR_CHILDREN(pdeath_signal), or the new
CLONE_WITH_PDEATHSIG. Or something else, I agree that the current API is,
well, not perfect ;)
> 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.
Thanks!
Oleg.
next prev parent reply other threads:[~2025-09-25 16:29 UTC|newest]
Thread overview: 13+ 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
2025-09-13 22:28 ` 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 [this message]
2025-09-25 18:35 ` Mateusz Guzik
2025-09-25 18:50 ` Oleg Nesterov
2025-09-26 23:58 ` Demi Marie Obenour
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=20250925162759.GA25838@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=demiobenour@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.