[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9254286c02dbe883c14e38ed2af0022d36b17355.camel@opteya.com>
Date: Wed, 27 Mar 2019 18:21:24 +0100
From: Yann Droneaud <ydroneaud@...eya.com>
To: Christian Brauner <christian@...uner.io>, 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
Cc: 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()
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)
(and match the check done for flag == 0).
Regards.
--
Yann Droneaud
OPTEYA
Powered by blists - more mailing lists