[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190327205922.ajkkylqft6tp5cf7@brauner.io>
Date: Wed, 27 Mar 2019 21:59:23 +0100
From: Christian Brauner <christian@...uner.io>
To: Yann Droneaud <ydroneaud@...eya.com>
Cc: jannh@...gle.com, khlebnikov@...dex-team.ru, luto@...nel.org,
dhowells@...hat.com, serge@...lyn.com, ebiederm@...ssion.com,
linux-api@...r.kernel.org, linux-kernel@...r.kernel.org,
arnd@...db.de, keescook@...omium.org, adobriyan@...il.com,
tglx@...utronix.de, mtk.manpages@...il.com, bl0pbl33p@...il.com,
ldv@...linux.org, akpm@...ux-foundation.org, oleg@...hat.com,
nagarathnam.muthusamy@...cle.com, cyphar@...har.com,
viro@...iv.linux.org.uk, joel@...lfernandes.org, dancol@...gle.com
Subject: Re: [PATCH 2/4] pid: add pidfd_open()
On Wed, Mar 27, 2019 at 06:21:24PM +0100, Yann Droneaud wrote:
> Le mercredi 27 mars 2019 à 17:21 +0100, Christian Brauner a écrit :
>
> > diff --git a/kernel/pid.c b/kernel/pid.c
> > index 20881598bdfa..c9e24e726aba 100644
> > --- a/kernel/pid.c
> > +++ b/kernel/pid.c
> > @@ -26,8 +26,10 @@
> > +SYSCALL_DEFINE4(pidfd_open, pid_t, pid, int, procfd, int, pidfd,
> > unsigned int,
> > + flags)
> > +{
> > + long fd = -EINVAL;
> > +
> > + if (flags & ~(PIDFD_TO_PROCFD | PROCFD_TO_PIDFD))
> > + return -EINVAL;
> > +
> > + if (!flags) {
> > + struct pid *pidfd_pid;
> > +
> > + if (pid <= 0)
> > + return -EINVAL;
> > +
> > + if (procfd != -1 || pidfd != -1)
> > + return -EINVAL;
> > +
> > + rcu_read_lock();
> > + pidfd_pid = get_pid(find_pid_ns(pid, task_active_pid_ns(current)));
> > + rcu_read_unlock();
> > +
> > + fd = pidfd_create_fd(pidfd_pid, O_CLOEXEC);
> > + put_pid(pidfd_pid);
> > + } else if (flags & PIDFD_TO_PROCFD) {
>
> [...]
>
> > + } else if (flags & PROCFD_TO_PIDFD) {
> > + if (flags & ~PROCFD_TO_PIDFD)
> > + return -EINVAL;
> > +
> > + if (pid != -1)
> > + return -EINVAL;
> > +
> > + if (pidfd >= 0)
> >
>
> I think it can be stricter with:
>
> if (pidfd != -1)
Yes.
>
> (and match the check done for flag == 0).
>
> Regards.
>
> --
> Yann Droneaud
> OPTEYA
>
>
Powered by blists - more mailing lists