Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2686089ybb; Sat, 30 Mar 2019 11:04:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvAMDGeRDE42FIuHy+Sw+IbrDM4JCEKT57P3ngI+5QSEtEcn+gu8QwH/Kllw+AeOYCNhLM X-Received: by 2002:a63:e554:: with SMTP id z20mr48884280pgj.234.1553969071624; Sat, 30 Mar 2019 11:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553969071; cv=none; d=google.com; s=arc-20160816; b=HPgd1etnxjyJRsbrHzcArsmvhG0WESBGRVxT3baKOINK/L3DNKcQ0m7hpSnfgpUBHP h1YMS/DqOg6TJnRA1Ltac8Z23577bj6wGbGVOJSaKxVwqx3Bdq7fY5HTYrk511vUPyEM orBosK8ydcl+jnQKD7VnvZkInsPW9DIGz7f02Lp+K+sFGqLRxQtXEJ0jGQjhdhddzXU7 DsNKrosKGdzGromy45xMbvxr0+7E5UZ6R+B+nQRejjr5dhPZrT80JZnqny+5dZbAitkW O7i+cwtDnM4a4anXLQf1AK4ewF9upBmGeTK+Tb9s8WF4mlYV04pvIW5HxpKlg7BgzRq6 W4gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Boy6Z5pZ7bEVfjbfzz39eWJ+Ke042SqdNUU3pLWpsxU=; b=NOPx1MdSIwbTe94rfeNepLWhpB6gTQ2AFrcRYPCvpu9Lxa2aVq8kVr6Af3/ibJlHaD II7hq9wBioQSQMCUh2ke3GemW1bMl0d5k8K6IcR0Kj6XEh6fAM6/2KmnRTVrPdl8z9g0 dQbC13yRJkWofELI/alELEqFltScfcTNNFaRmz+Kyvd/PHPmVY6z/4VYBi5lUS4cXq1t CxkG97OhwMOy981ol4g1w7yUsGo0YUxC0bUjZWGoTl0PIMUjRG7Z+o2I8XY0sDqZc/+c QeECFzcs/C202lfL0sFgIUoIhHBRM4gSAkoaX9XkXCBd087hNy7v2pNAKqglr845cAYu 2x2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=GhYmw0p0; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cn16si5201996plb.174.2019.03.30.11.04.16; Sat, 30 Mar 2019 11:04:31 -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=@brauner.io header.s=google header.b=GhYmw0p0; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730983AbfC3SCX (ORCPT + 99 others); Sat, 30 Mar 2019 14:02:23 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:34415 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730675AbfC3SCW (ORCPT ); Sat, 30 Mar 2019 14:02:22 -0400 Received: by mail-ed1-f68.google.com with SMTP id x14so4719129eds.1 for ; Sat, 30 Mar 2019 11:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Boy6Z5pZ7bEVfjbfzz39eWJ+Ke042SqdNUU3pLWpsxU=; b=GhYmw0p09ijNCE8ZXjhU3bqMRhwAuj6v04HuXFLi7pUQy8CjZRQZRhVy0BnMDhThT7 mTLIddx5fU1C8K5/dXRIMeLVZWydZiXPgD4+I6L99/pPs3Wx0+9wwHNK3grIdeqVSMld nFY6yL0UoBXgilfpRSJGL3xOXeKnG0M40d/1yPufPAAsnwBmJQjgg37M+ipsN/knoKFh 0bSnUuAOVZAvWE5p6o5gfyRDHI3+aB4ZxYVt8fg25nXeWKLAaxA+Z5R1/8Hd2bLzcZOV GPsq84iru6hW15s8ycXwZzt0p5ZNPqfWcQSh6k1R5ymWRVvVbXk3XkZiJPbBGfRBneNR ytCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Boy6Z5pZ7bEVfjbfzz39eWJ+Ke042SqdNUU3pLWpsxU=; b=qHIbE7qARWT6b9fiKhDSAvRTkQXLx8Qc3ZpysHJscTF6KOdJD8IMvO91n14GPKYJDT edTz2eOb20rRD22HzzDqUU7ajRVeTUW+8ursxxTxTsAAiHFOHLxOWXe19EsKmujd7gqK t4DUoXDaJSfRmijjdBaL7YxNsGcJ9+YUOLUovNQR05HWrEa8Ilck5fvrCjrG1ttuIwM+ 97JbtnD2ptrVBADGvSzFx6oiF9FwN8UyfpV7Z8e6gu4Z19U+VKDVE2iWaEHBKlEo7ZOO iUdb84nnId8klC61yycRWVD6s8dcpEHTOsSCYKfEv1743FpdYQ/BNVkzTURjYLxT2jNx Xj8g== X-Gm-Message-State: APjAAAV2Qli+38/C0C5hiWSOje7exmqeNRXeL3daAG1h7VuDD64RvdNi 0Wt4i/lvfrqcMsjQu5shiohskg== X-Received: by 2002:a50:ac14:: with SMTP id v20mr35463089edc.63.1553968940206; Sat, 30 Mar 2019 11:02:20 -0700 (PDT) Received: from brauner.io ([2a02:8109:b6bf:d24a:b136:35b0:7c8c:280a]) by smtp.gmail.com with ESMTPSA id m47sm1682396edm.7.2019.03.30.11.02.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 30 Mar 2019 11:02:19 -0700 (PDT) Date: Sat, 30 Mar 2019 19:02:18 +0100 From: Christian Brauner To: Jonathan Kowalski 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 Subject: Re: [PATCH v2 0/5] pid: add pidfd_open() Message-ID: <20190330180217.emenfwjsc2ejf5ws@brauner.io> References: <20190330171215.3yrfxwodstmgzmxy@brauner.io> <20190330175241.4itdnx3tl5upzjxd@brauner.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 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 05:59:34PM +0000, Jonathan Kowalski wrote: > 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 That's not on the plate for now and pidfd_send_signal() is checking for that to not allow it.