Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1442563ybi; Sat, 27 Jul 2019 09:45:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRjJPjYPqcrjkF1fxe28u23QeyZBV40HK2lMarmDXvz2dk94M1BMsRgqFT3XCwhUyQgQav X-Received: by 2002:a63:188:: with SMTP id 130mr95340675pgb.231.1564245945726; Sat, 27 Jul 2019 09:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564245945; cv=none; d=google.com; s=arc-20160816; b=uJ4+sLouUYehLLIYndVsViMIuQpcoHQ15AKU+GQbywAKIMH/g92d+6H+g7MeKOloUq vTpWTldKuDg6sID+TzZXUDqhtz5oSpD77TMFH+fgy8UN0ouA7dXaBBiPK9o1ARVnNwNh qSgQw5FxB+Xdj1qfWA47Ln+xKIHRZInzoL18rP1A15kUpGqr2Rrsj/ZER7LIPWcjB8q3 0mBiH0bMutz22HdrznB4POCESjte85hH29r6lfpRyFb9Q1BJgAMnOH3ldO8uyMQBVmW9 1rwxeLKuH6nOJQmLkC9/keg2Gi8xYOYea5QnSbgAi4G2ER6LkRi91AxnHEwTcer3if9U 6Rhw== 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=URzo6r2h2/jBzyZ/IbgB9BNeTix2jmweMWplmeW7miE=; b=E8mmwZVs4wT4ZpDnVzt5YKtUGtAq5NX2opiiI86rVXKX56Dp5UhzC076mOfXZzVPpI 3a39tSFfycy445/Yz+Fzx/eM5JZhDb0+qbbki9hZaAzTmFAeiXa7r1rzPn5ObBkHX1mW sEtZzeixuykn7F51LYixFL6rDPGbyf7HCdtxe3bHuX3BFMtFDtBDDowCW8nZqvRvEoXC W1CPbdWq9+F+AELINwjw32pp19Rqc7eaJmt2YnQWm0mFW8EsQbsFrqWrrkPHgKPmg/X6 8g1Mq4Du1/1s8WgQQoK/2pMeNoKI0Vi7WjTjsTihdaNJo3/uE+NQ6MwKVZYn9JiSmahg S5Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=fUv1YrBB; 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 d19si21218884pgl.53.2019.07.27.09.45.28; Sat, 27 Jul 2019 09:45:45 -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=@linux-foundation.org header.s=google header.b=fUv1YrBB; 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 S1728981AbfG0Qlr (ORCPT + 99 others); Sat, 27 Jul 2019 12:41:47 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:41269 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728856AbfG0Qlr (ORCPT ); Sat, 27 Jul 2019 12:41:47 -0400 Received: by mail-lj1-f195.google.com with SMTP id d24so54380357ljg.8 for ; Sat, 27 Jul 2019 09:41:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=URzo6r2h2/jBzyZ/IbgB9BNeTix2jmweMWplmeW7miE=; b=fUv1YrBBaXDgQir2L0b+1MYDz2FMOyGCVVhV3BqLC7Ynrf0k01/vDoIA/nLEk9UeCn ycwRuXTvxvUZ1/CLFddwJCNil6D/+omHdt2hn979QSKWvEKEbHFsr+k6yfvf6glxKqoC rWRXDRFy+5wsQTx9spjJ3c8Bvxfb+4qXzE1Ao= 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=URzo6r2h2/jBzyZ/IbgB9BNeTix2jmweMWplmeW7miE=; b=IJRx0wZ4+fZvx864dvW531r7A4okHDjvdzmshmsRM+iE15KA3tiQoZ6gvzGVyA6jE/ em6CKjPzC6H/ZR2U80f9sNNT/uC3lC5vgnBukGbssfza2uXS1y8auKLOWTBhLWKsHXA0 D04F6HD8GZXJ9AYpInOSz5wUhPiyJGalmJKLj4JUl1jfA5q/s5jaa/ir/uwGZbR510wF 1RrwvC1scx05aNHgE5PPm4ahjh2ltgSv04RqDm5rAdTKYuKAEGbHurMyOjwmxDuLBeDK BCGvSeNZS40kHLD61jNcRO6afctX6iju+WWZhGWf18s+IbgGU/pyx5GCB2uqGwAbsXYW nGEw== X-Gm-Message-State: APjAAAUv1lsXTbyuXl2DPSROTdWj/DjCtS6o6zcExFVQw/RnwWsJrFSs QgjZDmutgUQg1d89UHBEi8zIXVzVxgY= X-Received: by 2002:a2e:9950:: with SMTP id r16mr35766982ljj.173.1564245704372; Sat, 27 Jul 2019 09:41:44 -0700 (PDT) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com. [209.85.167.54]) by smtp.gmail.com with ESMTPSA id m4sm11202697ljc.56.2019.07.27.09.41.41 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jul 2019 09:41:42 -0700 (PDT) Received: by mail-lf1-f54.google.com with SMTP id c9so39109500lfh.4 for ; Sat, 27 Jul 2019 09:41:41 -0700 (PDT) X-Received: by 2002:ac2:44c5:: with SMTP id d5mr48540131lfm.134.1564245701693; Sat, 27 Jul 2019 09:41:41 -0700 (PDT) MIME-Version: 1.0 References: <20190727085201.11743-1-christian@brauner.io> <20190727085201.11743-2-christian@brauner.io> In-Reply-To: From: Linus Torvalds Date: Sat, 27 Jul 2019 09:41:25 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] pidfd: add P_PIDFD to waitid() To: Christian Brauner Cc: Linux List Kernel Mailing , Oleg Nesterov , Arnd Bergmann , "Eric W. Biederman" , Kees Cook , Joel Fernandes , Thomas Gleixner , Tejun Heo , David Howells , Jann Horn , Andrew Lutomirski , Andrew Morton , Aleksa Sarai , Al Viro , Android Kernel Team 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, Jul 27, 2019 at 9:28 AM Linus Torvalds wrote: > > Something like > > struct pid *fd_to_pid(unsigned int fd) > { > struct fd f; > struct pid *pid; ... I forgot to put my usual disclaimer about TOTALLY UNTESTED GARBAGE in that email. I want to make that part clear: that code snippet was meant as a rough guide of direction, not as a "this works". Hopefully that was clear. Also note again that one of the reasons I would prefer that "fd_to_pid()" interface is that you _can_ do it cleverly with RCU lookup, but that requires a lot of care. In particular, I think all of our _existing_ "proc_pid(file_inode(file))" users are done while you actually hold a reference to "struct file *", so they don't have to worry about races with another thread doing the final ->release(). So the "clever" thing is possible, but might need a _lot_ of care to make sure the 'struct pid *' associated with the file still exists. The example code sequence was not doing the clever thing, obviously. So it was untested _and_ simple-stupid. But it has the interface that I'd prefer. Linus