linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yann Droneaud <ydroneaud@opteya.com>
To: Christian Brauner <christian@brauner.io>,
	jannh@google.com, khlebnikov@yandex-team.ru, luto@kernel.org,
	dhowells@redhat.com, serge@hallyn.com, ebiederm@xmission.com,
	linux-api@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: arnd@arndb.de, keescook@chromium.org, adobriyan@gmail.com,
	tglx@linutronix.de, mtk.manpages@gmail.com, bl0pbl33p@gmail.com,
	ldv@altlinux.org, akpm@linux-foundation.org, oleg@redhat.com,
	nagarathnam.muthusamy@oracle.com, cyphar@cyphar.com,
	viro@zeniv.linux.org.uk, joel@joelfernandes.org,
	dancol@google.com
Subject: Re: [PATCH 2/4] pid: add pidfd_open()
Date: Wed, 27 Mar 2019 18:21:24 +0100	[thread overview]
Message-ID: <9254286c02dbe883c14e38ed2af0022d36b17355.camel@opteya.com> (raw)
In-Reply-To: <20190327162147.23198-3-christian@brauner.io>

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



  parent reply	other threads:[~2019-03-27 17:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-27 16:21 [PATCH 0/4] pidfd_open() Christian Brauner
2019-03-27 16:21 ` [PATCH 1/4] Make anon_inodes unconditional Christian Brauner
2019-03-27 16:21 ` [PATCH 2/4] pid: add pidfd_open() Christian Brauner
2019-03-27 17:07   ` Jann Horn
2019-03-27 21:02     ` Christian Brauner
2019-03-27 17:21   ` Yann Droneaud [this message]
2019-03-27 20:59     ` Christian Brauner
2019-03-27 19:38   ` Jonathan Kowalski
2019-03-27 20:17     ` Jonathan Kowalski
2019-03-27 21:34     ` Christian Brauner
2019-03-27 22:12       ` Jonathan Kowalski
2019-03-27 22:25         ` Christian Brauner
2019-03-28  0:42           ` Jonathan Kowalski
2019-03-28 10:38             ` Christian Brauner
2019-03-28 16:59               ` Joel Fernandes
2019-03-28 17:07                 ` Christian Brauner
2019-03-30  5:35               ` Daniel Colascione
2019-03-30  6:25                 ` Jonathan Kowalski
2019-03-30  7:39                   ` Daniel Colascione
2019-03-30 14:30                     ` Jonathan Kowalski
2019-03-30 16:08                       ` Daniel Colascione
2019-03-27 16:21 ` [PATCH 3/4] signal: support pidfd_open() with pidfd_send_signal() Christian Brauner
2019-03-27 16:21 ` [PATCH 4/4] tests: add pidfd_open() tests Christian Brauner
2019-03-27 19:36   ` Kees Cook
2019-03-27 20:55     ` 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=9254286c02dbe883c14e38ed2af0022d36b17355.camel@opteya.com \
    --to=ydroneaud@opteya.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=bl0pbl33p@gmail.com \
    --cc=christian@brauner.io \
    --cc=cyphar@cyphar.com \
    --cc=dancol@google.com \
    --cc=dhowells@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=jannh@google.com \
    --cc=joel@joelfernandes.org \
    --cc=keescook@chromium.org \
    --cc=khlebnikov@yandex-team.ru \
    --cc=ldv@altlinux.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=nagarathnam.muthusamy@oracle.com \
    --cc=oleg@redhat.com \
    --cc=serge@hallyn.com \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    /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).