Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp827390yba; Sun, 31 Mar 2019 14:11:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzPcFR4rSRWbG//aLoYVT2lcA6/8LPemerkfgsgCcy0Dq4LzRhDezbAihGMX/MCy1zr0o1 X-Received: by 2002:a62:cfc4:: with SMTP id b187mr31067166pfg.130.1554066696768; Sun, 31 Mar 2019 14:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554066696; cv=none; d=google.com; s=arc-20160816; b=ltiyv3bDzajsenmdP23Mdb+ugo94LJ0YUrb+VRI9IFPpfHCcmb3bf70S1z6Yrl41C+ z1dlJua60T0VThaqq/u0Wcw9bI39o44mm3XwZkzWxs+6hXyRVP1A2uJDWb6EIxiKxWSy vWsC44yU2HkdTJ1zN1FDJ6k5M9UMk1cwysQVfGgtRSM8jevQG6YSHF418yGHMACJaV3N V9fUuRvEe7mmj0vw3iTTe9rjWmJ3qM+S2e9Eht8j49GNgTRGHz6hdwLkTSDHIFbuXhD9 gKE9ktG7lhrfd3seJV7GEo1OXN5jdGHk//xevg86BD1jECES8n3TZJ2T7fGf9ceGqaMP KNgg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QMYZKV8w3K7zsSovYcs2Yb7Li2RouumghnMebcv29RA=; b=B8TaRVtqE2pTuP6IMsQdcSCaYCdmdafqYlScWvM7PfIl+NSrNWDp3uVxEpB+Xdflpw OyL4uwmp/WCubFuIBWObygcXCMXkiw3MsTgEQLNoAA0iCyJb7kuwkiurP+Rl3Kt8DGE5 XpU8Z6BQOBT82mV0PxR+PPEvtlCaQ2VwZdDkE4C7TJZN+aaB24dxOxl4luhfnw03uM/o EKS55MPiPsxKyv6Neaw0V0N8hxE/2I4hsF5qdV1JxjCdgqC9RYyq3dIBv1Y4Hjrt06/V NyiOFD9HJSR/kH0fsI9iGjiTHo0hgUUbdazYTrDIpcMiEkfAWSS3kmcn+5Q13CYBe4Lk 00yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=Mhv39Tba; 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 g20si7107400pfi.266.2019.03.31.14.11.21; Sun, 31 Mar 2019 14:11:36 -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=Mhv39Tba; 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 S1731470AbfCaVKr (ORCPT + 99 others); Sun, 31 Mar 2019 17:10:47 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:36500 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731241AbfCaVKr (ORCPT ); Sun, 31 Mar 2019 17:10:47 -0400 Received: by mail-ed1-f67.google.com with SMTP id s16so6429501edr.3 for ; Sun, 31 Mar 2019 14:10:45 -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:content-transfer-encoding:in-reply-to :user-agent; bh=QMYZKV8w3K7zsSovYcs2Yb7Li2RouumghnMebcv29RA=; b=Mhv39TbazztYpO6XJAM4TS6LjIF6VNJXMBKIa/KxcCLqcHhNjTL//pcBpIzf5Lm9XQ TIL5TZrQ7Nw1DrdWn9xi9irPwrMRCdJ2COgORrrySxq9aW3L+ZoLoLkytIodVPa+y/XB lSbozEy37uGgpqt3QYZEmyET4kli3kAN02eEgOWHD/j+UU//tWOhUXkizzrzEF7/UK4/ RxDlrz+lPgjSRqnDnXNpb5bMEN+FUuDOQJN+n6VuFap0NRTbD01nuAjB7Rqr5Ryq6PN0 7vW35lb+vHmfeAHZVo+TSMjezSZMp4ZxjT/dV+++GQqEauy/jFdtSUtidWIDMt6U2fcP conQ== 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:content-transfer-encoding :in-reply-to:user-agent; bh=QMYZKV8w3K7zsSovYcs2Yb7Li2RouumghnMebcv29RA=; b=N14Wzl6n2HpaGWx4q9Ce7JhHA3zYpPH+83VdgrihEm4L8rKHsEuYqzT/3b12z3jWxK 8+8xpL/DBpkx8t18Mq7hzR9FmuAy8WoDxAb1A4Fj9QmpyKUBdDcuxQu4tmVyRYlh1IUk mwf5I7j0jb2ukv38sNbJSQwJzF8iuQKYSnr4Yl9xFeYibXQQ+LBYbupNlfrvOdFbLqfT xm7MUPdPiVAqH8KXd+cZq+5eWbcqmegnV/Nx7MVJf7J/66+A2qN39IjCMD15WX/Mgb6Q vqb2r8fLJzHw/BVIpNtKHhMTaiyWltUcvVVXzxoqNlTOkyGQSHsl3UjYMOXy8EeuCPwH 4I5Q== X-Gm-Message-State: APjAAAXXf76/gBI2+eRnDZwY1AXIjHbmDjDnY4IdYhNP52czeVHeH9Cy CSPmAErVFoNMrcZABPTKbjTMvg== X-Received: by 2002:a17:906:a291:: with SMTP id i17mr34303036ejz.180.1554066644871; Sun, 31 Mar 2019 14:10:44 -0700 (PDT) Received: from brauner.io ([2a02:8109:b6bf:d24a:b136:35b0:7c8c:280a]) by smtp.gmail.com with ESMTPSA id ay12sm1557523ejb.15.2019.03.31.14.10.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 31 Mar 2019 14:10:44 -0700 (PDT) Date: Sun, 31 Mar 2019 23:10:42 +0200 From: Christian Brauner To: Linus Torvalds Cc: Andy Lutomirski , 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 Subject: Re: [PATCH v2 0/5] pid: add pidfd_open() Message-ID: <20190331211041.vht7dnqg4e4bilr2@brauner.io> References: <20190329155425.26059-1-christian@brauner.io> <20190330171215.3yrfxwodstmgzmxy@brauner.io> <132107F4-F56B-4D6E-9E00-A6F7C092E6BD@amacapital.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 Sun, Mar 31, 2019 at 02:03:25PM -0700, Linus Torvalds wrote: > On Sun, Mar 31, 2019 at 1:38 PM Andy Lutomirski wrote: > > > > openat(fd to pidfd’s proc directory, “status”, ...); > > > > And we want a non-utterly-crappy way to do this. The ioctl is certainly ugly, but it *works*. > > It's beyond clunky. It's a disgrace. > > If people really want equivalency between open("/proc/%d") and some > new pidfd_open(), then just *make* the two equivalent. I don't think that we want or can make them equivalent since that would mean we depend on procfs. If userspace really wants to turn a pidfd into an fd for /proc/ then they can be burdened to do so by parsing out the pid relative to their procfs pid namespace from the pidfds fdinfo: int pidfd = pidfd_open(pid, 0); int pid = parse_fdinfo("/proc/self/fdinfo/"); int procpidfd = open("/proc/", ...); /* Test if process still exists by sending signal 0 through our pidfd. */ int ret = pidfd_send_signal(pid, 0, NULL, PIDFD_SIGNAL_THREAD); if (ret < 0 && errno == ESRCH) { /* pid has been recycled and procpidfd refers to another process */ } it's race free and no ioctl() is needed. > > No effing crappy ioctl idiocy to create one from the other. Just make > the damn things be the exact same thing (and then if we extend clone() > to return one, make that return the same exact thing too). > > Btw, we have several clone bits left: > > - if we don't have CLONE_PARENT set, the low 8 bits are still available > > - ignoring that, wehave bit #12 free: It used to be CLONE_IDLETASK > long long ago, but it was always kernel-only so it's never been > exposed as a user space bit. That's good to know.