Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2678677ybb; Sat, 30 Mar 2019 10:53:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhQspntpwbxCQ4IBtGFk2y7ZfNhJOATgwQMfcVNB1Cghl8oQgQUz7kxpL4G2CFxUNL3aZs X-Received: by 2002:a17:902:2947:: with SMTP id g65mr55293063plb.258.1553968395159; Sat, 30 Mar 2019 10:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553968395; cv=none; d=google.com; s=arc-20160816; b=YRXGWeH8tXb9SsLWYvXseM2pZJti7ubWZKB/DDU1SfJaMMVfVSmDJSUO7gKq5qKxZl ZEYkCLHvFvpb/o+Svuk+eUZJGJhr7JHBQLOpxfT6l4mnD/rjkZZyqvLc24VeoT1f6Vrw vmH/pSL1UrxQ7wDRD1ik2utpUx3aG3+1AMFjtVyDK0BqtjPr7o+DtcYCS++rbqTsaXaN QrzEmjcNfK/BSeMfPkxRiXklRVy3LJS0B7XW3iSlX+riv72+lLQFIyA7yF6NAhtnMpYd 3BHo3r+UeDSK8eLm5gIZYpebXvBMlv/YvYRfU6zQX22CI9QP0Q+TrlWjWG5uaK1hGUlG C8EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mjmT9JSBixV9ZplO7X4LpJ4/7aBZYStDxsJ3dPUlulQ=; b=0v5G/78PGjTpRcx1zXA6vms6h4s3s2h0n/ilzkbVjBYdJD7JMt+dYsSzCy2lKBfqQe 2I1PjtXH+3YhSjPLtBlAM16ewbD5jsRZDkScaKWu/FiD40kcouWX6hKaLBlgL1pa2jA3 HQE8y9gpXtqAvlEvTN8mVm0O+AxHzdczMu1z9oBvNjmceKs74rRGnbyIkC75n1/kqjW9 7ScvXRjcD4q3lJ3btmesnqFRqfwgyXKRefHklju1cN6MXnKDxWLeweFSRvFzVyeWUnjE 0v0n6pangj5Qj0Pud8pfbDzIm7St11Vxhb9so3i7CpSHE028/JjQKRbrk49WY9LwsVVa rjaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XWSxm5LC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f66si4846828pgc.400.2019.03.30.10.52.59; Sat, 30 Mar 2019 10:53:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XWSxm5LC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730922AbfC3Ru2 (ORCPT + 99 others); Sat, 30 Mar 2019 13:50:28 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:41431 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730721AbfC3Ru1 (ORCPT ); Sat, 30 Mar 2019 13:50:27 -0400 Received: by mail-qk1-f195.google.com with SMTP id o129so3278358qke.8; Sat, 30 Mar 2019 10:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mjmT9JSBixV9ZplO7X4LpJ4/7aBZYStDxsJ3dPUlulQ=; b=XWSxm5LCEVkKOTQwP4VKFPqin2om/iwP0pyUnVcVUXWrARdqF8m73+n/9iSINDumFb zN+qRrdTgaHZPh92qaU3MybkmFLkY/0GAQkRr+xZb8n/BxdNS/58ixvhDvuv55GmxZWS i9/OP8kSZ+gimqiYN+/6qgm6R7O/XFGDD8Z9T7mfTwgIyCGIU22Am1fCeRvnfyapGnF5 rLZh50im1do+smK7eGgb+8GK/MZC9eL1kn5X3L1+tMWsioHVLG14pEj5QtSNGSkHBkYA BP7UCOkJZ2rWoB4LK3JsMHrGdsBScoRYvpcPKNCysz6+oinfx3VGBKpwyBD0m+WewrhZ lS4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mjmT9JSBixV9ZplO7X4LpJ4/7aBZYStDxsJ3dPUlulQ=; b=CvZT+nNc2Qlco3WOYhuCOwovDkdSoYoNunvfaClK7ds2rw8usxSFIL9QQ/aI14dBJ3 fwqgKKafN57zyC5YrkX6IgafMOJMQnFA1qAkyXeVCzR11vcYUIKQBIU6lgU7CbEFF7BU p2UEml9QkniuJzpZa1dk88lulmsHj1o9GWRa9NVFYQj67w6EKF7V5IGeSYzCLeXgOQxw y/mVlp/zxFRDBipo/1bV7Rr3fuqpFKZs0qDlXJBNJimsHhA3TOdZ/dm8JYpQcSLeOUNE Adm83uVOXfjlQL5Zagavp3xaoriBhU8t/IULgxtdZdj+MOI5pNZze5YwR4GG32krZ3fR nqjw== X-Gm-Message-State: APjAAAU8WXPYrqnoJJmRqcdwrp+edCOCvBLobvaH/CYFqcXXjrvj4Ras 4OuQX3ukoHHAuh0FDGe9sKq8Y/zMSe0tHRBxkuI= X-Received: by 2002:a05:620a:1438:: with SMTP id k24mr41627983qkj.165.1553968226775; Sat, 30 Mar 2019 10:50:26 -0700 (PDT) MIME-Version: 1.0 References: <20190329155425.26059-1-christian@brauner.io> <20190330171215.3yrfxwodstmgzmxy@brauner.io> In-Reply-To: From: Jonathan Kowalski Date: Sat, 30 Mar 2019 17:50:20 +0000 Message-ID: Subject: Re: [PATCH v2 0/5] pid: add pidfd_open() 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 , Aleksa Sarai , Al Viro , Joel Fernandes Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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