Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp812517yba; Sun, 31 Mar 2019 13:43:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwr1096xffbAssnwvhfog/OJThttjhap2m4ybJdQ5pNBrq19LpSIdCPXwttc4GuFm1otUmX X-Received: by 2002:a17:902:e90b:: with SMTP id cs11mr1984279plb.243.1554064985946; Sun, 31 Mar 2019 13:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554064985; cv=none; d=google.com; s=arc-20160816; b=SfKY3vZzA3BbCxFn9UGwZLk/YADv6YGPX/25wpPG9sMauIL+Qs9bVNpWGH0jy1obkl 7NUOaU1CWiWGBbyqFnNEI+SATSWa+nxdx54ktUOyhkAakYte9gAKgqtXfIFpUq4UcPyb W+BjPw+PMv9aTv9KhvysVeeGDMhbHV+RCymavMCor/X6kgV4EWu1rF2otNP+AaIbbp60 VrrdBH3NcLG900GbnIaE6ibJUTvZJq3z/65SlqHs5bv84pwoReJhQLip0S514EEkA29e ZklxHqRLo53cFOqAkcp9C1zwDhhJdgK8voPDrrn+iJIN6hhbdeGb58zTO9Tt5S/p0NVB yv8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding :dkim-signature; bh=GYOZQm4vYbyUdQFi8rHe4bvj6vFGTwbbXOBuIqEShGI=; b=b0xy89HMhEWAZD/QyBSu8z1sS6ieS/NDXxlK9uhwNqG6LEu0Xb9I2NswhwfoOA3siv iwrun0mscbGHxujr8+xUZC4e7FIf3h7LZGJpRF4Iv9GzJsa4ir5Y7wfNCXP1nLjuepg+ 9Oucyw6fp3XflVyLP1ZVTBLh2+vSA1GmVb0Cx3aTC8+Rm7aOjEQN3w2N1VHg3ZnDE5me MgSt5JZLTE6u52MF0xAP5X/N04oyK6fkD0tOLGFDQoZwuoku1SmZh1HHRcaFuX/rW0Hc rC7pJGzGuyjHY6V7/0rISeRiEl2jrLDpuB/owIuVlN/GtlSC69xdwhiI4ALT/ImjKkkA lAGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=AGnN356U; 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 64si7253972ply.239.2019.03.31.13.42.50; Sun, 31 Mar 2019 13:43:05 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=AGnN356U; 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 S1731432AbfCaUib (ORCPT + 99 others); Sun, 31 Mar 2019 16:38:31 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45483 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726931AbfCaUib (ORCPT ); Sun, 31 Mar 2019 16:38:31 -0400 Received: by mail-pf1-f195.google.com with SMTP id e24so3466026pfi.12 for ; Sun, 31 Mar 2019 13:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=GYOZQm4vYbyUdQFi8rHe4bvj6vFGTwbbXOBuIqEShGI=; b=AGnN356UX2DjQrmYSKwgx9TPPQS0bvawlmliOoIfJ9L27/IL8K/jPrRpTiOTJRxZ/v jgcXHVUoVwODzclaD/vEPfn2ToceLDNoioESQt1q9+ieoBNvM31E+mmut7/PKNO/DRq4 WjxNNB5GiEJgOHUGrvL2Q4FhU9NUOAV2ZH5hTnqRGG8X+9Ve/7P17f3kvYsxKTMj7viG Lam8aJ1GtgnMuf3mQq2eaaOh++tfEvNocMoGFemMBSali/vvUGd+nZo6J77q1WKdej0I aiJum73DsBIcszEekomHceFcwDXiXFGmbeV5712qwLVpZzrat+eDbBApCBouBUJ+lwQN fBPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=GYOZQm4vYbyUdQFi8rHe4bvj6vFGTwbbXOBuIqEShGI=; b=lCKFnSeQF8lMYXgnNsE6DJbDw/WcjuenJskjkmbfYNpV5Ok0gZHxYXFmYXR24x8FBw zY0GeQfi9AXXzzyWWd6IpnaQvMJBPcIxRmjKen1Jt70mX+OL2J8qUAqsLRcGnaTl39qM RbwJn+vdTIAmENUPr7O/RpLhHMia4fUhxDO9MSi2fBp4ta6mtvUrerh2RiP0CEtbP65k TrF1VlEjNXC5EFoR7Tuk4NsoJMgCfUZm3gn5jK1gRZOJNIg1nbtq5Ug2ONwHFNTbhJZW ImTbIQ6RSfgGrxmSftpuqcISo2F4vG5t587o0+YHT2CRzUyxFT6zS3ejO/RDNfO6EtFV 6gOA== X-Gm-Message-State: APjAAAWFb8P0x1OY1PYRczZCmKdJlmH78xfWPeHZ3lrb5wk/NstLRYTG S9tdk9YQ3yP4880K59QbSbS5Vg== X-Received: by 2002:a63:145f:: with SMTP id 31mr7981828pgu.16.1554064710590; Sun, 31 Mar 2019 13:38:30 -0700 (PDT) Received: from ?IPv6:2600:100e:b13e:a3af:389b:29a:6d03:f8bf? ([2600:100e:b13e:a3af:389b:29a:6d03:f8bf]) by smtp.gmail.com with ESMTPSA id g73sm15291060pfd.185.2019.03.31.13.38.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Mar 2019 13:38:28 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v2 0/5] pid: add pidfd_open() Date: Sun, 31 Mar 2019 14:09:03 -0600 Message-Id: <132107F4-F56B-4D6E-9E00-A6F7C092E6BD@amacapital.net> References: <20190329155425.26059-1-christian@brauner.io> <20190330171215.3yrfxwodstmgzmxy@brauner.io> 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 , Jonathan Kowalski , "Dmitry V. Levin" , Andrew Morton , Oleg Nesterov , Nagarathnam Muthusamy , Aleksa Sarai , Al Viro , Joel Fernandes In-Reply-To: To: Linus Torvalds X-Mailer: iPhone Mail (16D57) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Mar 30, 2019, at 11:24 AM, Linus Torvalds wrote: >=20 >> On Sat, Mar 30, 2019 at 10:12 AM Christian Brauner = wrote: >>=20 >>=20 >> 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: >>=20 >> int pidfd =3D pidfd_open(1234, 0); >>=20 >> int procfd =3D open("/proc", O_RDONLY | O_CLOEXEC); >> int procpidfd =3D ioctl(pidfd, PIDFD_TO_PROCFD, procfd); >=20 > And my claim is that this is three system calls - one of them very > hacky - to just do >=20 > int pidfd =3D open("/proc/%d", O_PATH); Hi Linus- I want to re-check this because I think Christian=E2=80=99s example was bad.= I proposed these ioctls, but that wasn=E2=80=99t the intended use. The re= al point is: int pidfd =3D new_improved_clone(...); To be useful, this type of API *must* work without proc mounted. And, later: openat(fd to pidfd=E2=80=99s proc directory, =E2=80=9Cstatus=E2=80=9D, ...);= And we want a non-utterly-crappy way to do this. The ioctl is certainly ugl= y, but it *works*. Another approach is: pid_t pid =3D pidfd_get_pid(pidfd); sprintf(buf, =E2=80=9C/proc/%d=E2=80=9D, pid); int procfd =3D open(buf, O_PATH); if (pidfd_get_pid(pidfd) !=3D pid) { we lose; } But this is clunky. Do you think the clunky version is okay, or do you have a suggestion for mak= ing it better? =E2=80=94Andy