From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Kowalski Subject: Re: [PATCH v2 0/5] pid: add pidfd_open() Date: Sat, 30 Mar 2019 17:50:20 +0000 Message-ID: References: <20190329155425.26059-1-christian@brauner.io> <20190330171215.3yrfxwodstmgzmxy@brauner.io> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Linus Torvalds Cc: Christian Brauner , Daniel Colascione , Jann Horn , Andrew Lutomirski , David Howells , "Serge E. Hallyn" , Linux API , Linux List Kernel Mailing , Arnd Bergmann , "Eric W. Biederman" , Konstantin Khlebnikov , Kees Cook , Alexey Dobriyan , Thomas Gleixner , Michael Kerrisk-manpages , "Dmitry V. Levin" , Andrew Morton , Oleg Nesterov , Nagarathnam Muthusamy List-Id: linux-api@vger.kernel.org On Sat, Mar 30, 2019 at 5:24 PM Linus Torvalds wrote: > > On Sat, Mar 30, 2019 at 10:12 AM Christian Brauner wrote: > > > > > > To clarify, what the Android guys really wanted to be part of the api is > > a way to get race-free access to metadata associated with a given pidfd. > > And the idea was that *if and only if procfs is mounted* you could do: > > > > int pidfd = pidfd_open(1234, 0); > > > > int procfd = open("/proc", O_RDONLY | O_CLOEXEC); > > int procpidfd = ioctl(pidfd, PIDFD_TO_PROCFD, procfd); > > And my claim is that this is three system calls - one of them very > hacky - to just do > > int pidfd = open("/proc/%d", O_PATH); > > and you're done. It acts as the pidfd _and_ the way to get the > associated status files etc. > > So there is absolutely zero advantage to going through pidfd_open(). > > No. No. No. > > So the *only* reason for "pidfd_open()" is if you don't have /proc in > the first place. In which case the whole PIDFD_TO_PROCFD is bogus. > > Yeah, yeah, if you want to avoid going through the pathname > translation, that's one thing, but if that's your aim, then you again > should also just admit that PIDFD_TO_PROCFD is disgusting and wrong, > and you're basically saying "ok, I'm not going to do /proc at all". > > So I'm ok with the whole "simpler, faster, no-proc pidfd", but then it > really has to be *SIMPLER* and *NO PROCFS*. > (Resending because accidently it wasn't a reply-all) If you go with pidfd_open, that should also mean you remove the ability to be able to use /proc/ dir fds in pidfd_send_signal. Otherwise the semantics are hairy: I can only pidfd_open a task reachable from my active namespace, but somehow also be able to open a pidfd if I happen to see someone's /proc in my mount namespace and have the access to open it? > PIDFD_TO_PROCFD violates *everything*. > > Linus