From: Christian Brauner <christian@brauner.io>
To: "Dmitry V. Levin" <ldv@altlinux.org>
Cc: Jann Horn <jannh@google.com>, Oleg Nesterov <oleg@redhat.com>,
Arnd Bergmann <arnd@arndb.de>,
linux-api@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] CLONE_PIDFD: do not use the value pointed by parent_tidptr
Date: Mon, 24 Jun 2019 15:49:22 +0200 [thread overview]
Message-ID: <20190624134921.mvgabuz3mgmpuu3n@brauner.io> (raw)
In-Reply-To: <20190624134531.GB6010@altlinux.org>
On Mon, Jun 24, 2019 at 04:45:31PM +0300, Dmitry V. Levin wrote:
> On Mon, Jun 24, 2019 at 01:59:43PM +0200, Christian Brauner wrote:
> > On Mon, Jun 24, 2019 at 11:49:40AM +0200, Christian Brauner wrote:
> > > On Sun, Jun 23, 2019 at 02:27:17PM +0300, Dmitry V. Levin wrote:
> > > > Userspace needs a cheap and reliable way to tell whether CLONE_PIDFD
> > > > is supported by the kernel or not.
> > > >
> > > > While older kernels without CLONE_PIDFD support just leave unchanged
> > > > the value pointed by parent_tidptr, current implementation fails with
> > > > EINVAL if that value is non-zero.
> > > >
> > > > If CLONE_PIDFD is supported and fd 0 is closed, then mandatory pidfd == 0
> > > > pointed by parent_tidptr also remains unchanged, which effectively
> > > > means that userspace must either check CLONE_PIDFD support beforehand
> > > > or ensure that fd 0 is not closed when invoking CLONE_PIDFD.
> > > >
> > > > The check for pidfd == 0 was introduced during v5.2 release cycle
> > > > by commit b3e583825266 ("clone: add CLONE_PIDFD") to ensure that
> > > > CLONE_PIDFD could be potentially extended by passing in flags through
> > > > the return argument.
> > > >
> > > > However, that extension would look horrendous, and with introduction of
> > > > clone3 syscall in v5.3 there is no need to extend legacy clone syscall
> > > > this way.
> > > >
> > > > So remove the pidfd == 0 check. Userspace that needs to be portable
> > > > to kernels without CLONE_PIDFD support is advised to initialize pidfd
> > > > with -1 and check the pidfd value returned by CLONE_PIDFD.
> > > >
> > > > Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> > >
> > > Reviewed-by: Christian Brauner <christian@brauner.io>
> > >
> > > Thank you Dmitry, queueing this up for rc7.
> >
> > This is now sitting in
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/commit/?h=fixes&id=43754d05f235dd1b6c7f8ab9f42007770d721f10
> >
> > I reformulated the commit message a bit and gave it a Fixes tag. Dmitry,
> > if you want you can take a look and tell me if that's acceptable to you.
>
> s/Old kernel that only support/Old kernels that only support/
Fixed.
Thanks!
Christian
next prev parent reply other threads:[~2019-06-24 13:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190620103105.cdxgqfelzlnkmblv@brauner.io>
2019-06-20 11:00 ` [PATCH] samples: make pidfd-metadata fail gracefully on older kernels Dmitry V. Levin
2019-06-20 11:10 ` Christian Brauner
2019-06-21 17:06 ` Dmitry V. Levin
2019-06-21 22:13 ` Christian Brauner
2019-06-23 11:27 ` [PATCH 1/2] CLONE_PIDFD: do not use the value pointed by parent_tidptr Dmitry V. Levin
2019-06-23 11:28 ` [PATCH 2/2] samples: make pidfd-metadata fail gracefully on older kernels Dmitry V. Levin
2019-06-24 9:50 ` Christian Brauner
2019-06-24 9:49 ` [PATCH 1/2] CLONE_PIDFD: do not use the value pointed by parent_tidptr Christian Brauner
2019-06-24 11:59 ` Christian Brauner
2019-06-24 13:45 ` Dmitry V. Levin
2019-06-24 13:49 ` Christian Brauner [this message]
2019-06-23 11:32 ` [PATCH] samples: make pidfd-metadata fail gracefully on older kernels Dmitry V. Levin
2019-06-24 9:52 ` Christian Brauner
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=20190624134921.mvgabuz3mgmpuu3n@brauner.io \
--to=christian@brauner.io \
--cc=arnd@arndb.de \
--cc=jannh@google.com \
--cc=ldv@altlinux.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).