Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2682998ybb; Sat, 30 Mar 2019 11:00:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvb5MiVhNh0myZhCmJVTFVY2NHzSpFUvzNApZKBoEFhhZg7AcaQtQMdSfsbr/8f2j1C3M+ X-Received: by 2002:a65:5003:: with SMTP id f3mr40038000pgo.29.1553968834754; Sat, 30 Mar 2019 11:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553968834; cv=none; d=google.com; s=arc-20160816; b=jcrwYXnCbBcRh1hXCtDa2u4Krrml4yFfpRT6CQp4NGq4cOmphYxjLVDHlYdBGUKlr7 6odksANGITaMTXynnBco0z3gwrw3wP5vRSo5yTSFszL8+RH4bWHdOftYJxTpq3EfjhO+ m1l6im7kn39WiDHmIsLhz0ZCkgNpR1ppwfkXrETFNTT/2T3iArDFp27V/Y517fpmTfO7 Jn9T44rcHj8PW/2dsx4hsWx/tEuFTMI2KfbxsCoknIVnQ9rfIQFef32MtkTcrNPbhjS/ xt1DfmHrqeW3ybK8iU+HD5FDcC0lHLWYCKejlQ7G51S2zt4WBJTAtZk3PyfrYIdtPlAT cbFA== 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=1NBa54fTgslAZ+4TBm7qu5vEcTvq37GddI32idRhStE=; b=LGegm8hWUuRpOqhBMb96L41AGbLoVu5oodTp7xPDi6XbSPv6uLv0fhkJmhT8MlER+n tShxw7CmGzCRZUwNWkNbpH865WqsDXMYTjVBNgEC+2T98lwH7GYpfuXTwArq+bTqW407 7ja2Cw+LA+c4jPoe90YCYuOA/x/YTekdixH3sXH/DKOjh9G758hN1ve5LqlkEnrjEaTY NdO34DYCgVWSEkp3cUg8v+ZdpyfcsOeTGHpRZ2cyyaGT/C/+XsnUsMnyKE5XKhPmYDW2 ufaeTR7K6yng7dYaYEwwgRIrJXbIv/+HVK6t9CkQ2WDvYFpYdqwXtfaCUIKdy6X+jWhh pEOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=prdfcf46; 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.11.00.18; Sat, 30 Mar 2019 11:00:34 -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=prdfcf46; 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 S1730769AbfC3R7n (ORCPT + 99 others); Sat, 30 Mar 2019 13:59:43 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:42253 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730396AbfC3R7m (ORCPT ); Sat, 30 Mar 2019 13:59:42 -0400 Received: by mail-qk1-f195.google.com with SMTP id b74so3282384qkg.9; Sat, 30 Mar 2019 10:59:41 -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=1NBa54fTgslAZ+4TBm7qu5vEcTvq37GddI32idRhStE=; b=prdfcf46TC6nTtTbMc2Tih0xrAESd/0wkwgW8SLV+sq2s5IiyeqoWTpmZaSMYVRi7w ncC5AKRojkn4I6u9dRxaJVQdD+I8MoxLkJJvbxyEN1onhG2TQ5SUC9OBXVmdylBlKGKg HtWg1EgJQkHYwLz2ssVsMIIjnU07WiLfWgAQBahsV5MrKKyXF/9B2Si5/H+rJtH/aWxc 0UF0mqNwxhPKQbFAZvrcM+ba28rDyoQlHyUYgjvi7tVGBwVTizcrtq2oQKUt7qs/853D SeBE8S8PbuGcjZ60Qf2PEl/EXcMMck+P2JWhItV4lfxdn8xerGcQiYNGXOQ/ticLMQGL qSJw== 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=1NBa54fTgslAZ+4TBm7qu5vEcTvq37GddI32idRhStE=; b=QwI4LKydh9YL4YAym2tB6d4frFj0RcvQm/SC/CMsYcBwqIGl4BXLhRJ9pGPzr+Umbq t7HWvx+52a+iMLG8vQ6l+c0MMqIwc5/cIl0ULNcLQYAB3xDvRNSherQkFzyumePPPHD5 3cb7+Cen9WZVsNwZ3BVQ6/koLM6u61T2smHn+AAX6YMrwSCC4wnaewzSF0bRNwc3uzGf XaqYvHs5m4gsY+gfoeRNNuQXE3rLgA9aYcxQJNWzkXFUaA551eec5eYeuYb6qiDvJOfz MKc9RHlx4pgR4315mZ9HoJC7mlsQajFBao9svvXKEemDZ8In1Nq3COGETDiz9vkxUrTP ea7A== X-Gm-Message-State: APjAAAXorK+x3gaINXQ+ErVkAL6HLRLNmgh8aEFLheRizS1EpPlhZRSl hOcHr75HGkGNE1+vOGN9CDTgcowwSVwV2100CRk= X-Received: by 2002:a05:620a:1529:: with SMTP id n9mr34724685qkk.190.1553968781411; Sat, 30 Mar 2019 10:59:41 -0700 (PDT) MIME-Version: 1.0 References: <20190329155425.26059-1-christian@brauner.io> <20190330171215.3yrfxwodstmgzmxy@brauner.io> <20190330175241.4itdnx3tl5upzjxd@brauner.io> In-Reply-To: <20190330175241.4itdnx3tl5upzjxd@brauner.io> From: Jonathan Kowalski Date: Sat, 30 Mar 2019 17:59:34 +0000 Message-ID: Subject: Re: [PATCH v2 0/5] pid: add pidfd_open() To: Christian Brauner Cc: Linus Torvalds , 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:52 PM Christian Brauner wrote: > > On Sat, Mar 30, 2019 at 05:50:20PM +0000, Jonathan Kowalski wrote: > > 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 > > You can easily setns() to another pid namespace and get a pidfd there. > That's how most namespace interactions work right now. We already had > that discussion. Only if it is a child namespace, or you have the relevant capabilities to setns. Currently, if I just put a task in PID namespace, it can see /proc of an ancestor PID namespace, and opendir /proc/, this is accepted by pidfd_send_signal. If you ever allow signalling across PID namespaces (because file descriptors should be able to do that, they are not namespaced, see files, sockets, etc), it will become a problem. Getting pidfds from outside my active namespace should require userspace cooperation. So, opening a pidfd should be limited to what *I* can see in my namespace, like every other namespace. That is what a namespace is, and PIDs have their own namespace, they're not exposed in the filesystem namespace.