From: Oleg Nesterov <oleg@redhat.com>
To: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Aleksa Sarai <cyphar@cyphar.com>,
Tycho Andersen <tandersen@netflix.com>,
Daan De Meyer <daan.j.demeyer@gmail.com>,
Tejun Heo <tj@kernel.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] pidfd: prevent creation of pidfds for kthreads
Date: Thu, 1 Aug 2024 10:01:20 +0200 [thread overview]
Message-ID: <20240801080120.GA4038@redhat.com> (raw)
In-Reply-To: <20240801-report-strukturiert-48470c1ac4e8@brauner>
OK, I won't argue, but ....
On 08/01, Christian Brauner wrote:
>
> On Wed, Jul 31, 2024 at 04:51:33PM GMT, Oleg Nesterov wrote:
> > On 07/31, Christian Brauner wrote:
> > >
> > > It's currently possible to create pidfds for kthreads but it is unclear
> > > what that is supposed to mean. Until we have use-cases for it and we
> > > figured out what behavior we want block the creation of pidfds for
> > > kthreads.
> >
> > Hmm... could you explain your concerns? Why do you think we should disallow
> > pidfd_open(pid-of-kthread) ?
>
> It basically just works now and it's not intentional - at least not on
> my part. You can't send signals to them,
Yes, you can't send signals to kthread. So what?
You can't send signals to the normal processes if check_kill_permission()
fails. And even if you are root, you can't send an unhandled signal via
pidfd = pidfd_open(1).
> you may or may not get notified
> via poll when a kthread exits.
Why? the exiting kthread should not differ in this respect?
> (So imho this causes more confusion then it is actually helpful. If we
> add supports for kthreads I'd also like pidfs to gain a way to identify
> them via statx() or fdinfo.)
/proc/$pid/status has a "Kthread" field...
> > > @@ -2403,6 +2416,12 @@ __latent_entropy struct task_struct *copy_process(
> > > if (clone_flags & CLONE_PIDFD) {
> > > int flags = (clone_flags & CLONE_THREAD) ? PIDFD_THREAD : 0;
> > >
> > > + /* Don't create pidfds for kernel threads for now. */
> > > + if (args->kthread) {
> > > + retval = -EINVAL;
> > > + goto bad_fork_free_pid;
> >
> > Do we really need this check? Userspace can't use args->kthread != NULL,
> > the kernel users should not use CLONE_PIDFD.
>
> Yeah, I know. That's really just proactive so that user of e.g.,
> copy_process() such as vhost or so on don't start handing out pidfds for
> stuff without requring changes to the helper itself.
Then I'd suggest WARN_ON_ONCE(args->kthread).
But as I said I won't argue. I see nothing wrong in this patch.
Oleg.
next prev parent reply other threads:[~2024-08-01 8:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-31 10:01 [PATCH] pidfd: prevent creation of pidfds for kthreads Christian Brauner
2024-07-31 14:51 ` Oleg Nesterov
2024-08-01 6:58 ` Christian Brauner
2024-08-01 8:01 ` Oleg Nesterov [this message]
2024-08-01 13:48 ` Christian Brauner
2024-08-01 13:59 ` Oleg Nesterov
2024-08-18 3:58 ` Eric Biggers
2024-08-19 8:41 ` Christian Brauner
2024-08-20 19:34 ` Eric Biggers
2024-08-21 7:41 ` Christian Brauner
2024-08-21 7:47 ` Daan De Meyer
2024-08-23 5:23 ` Linux regression tracking (Thorsten Leemhuis)
2024-08-23 6:12 ` Greg KH
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=20240801080120.GA4038@redhat.com \
--to=oleg@redhat.com \
--cc=brauner@kernel.org \
--cc=cyphar@cyphar.com \
--cc=daan.j.demeyer@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tandersen@netflix.com \
--cc=tj@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).