Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp694408yba; Mon, 1 Apr 2019 14:59:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZz6j0qDM4nukCtkXW18xFkJ0MWKBeflofxZuki5w+f+WsAVWr0ZL7n/HiUHWUjOWW0qnz X-Received: by 2002:aa7:8a95:: with SMTP id a21mr64681034pfc.14.1554155993410; Mon, 01 Apr 2019 14:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554155993; cv=none; d=google.com; s=arc-20160816; b=0uS6sG6kWYoAonXtsPCqAN5sAraYmY4s5KKTsqBkazE8dmJUhSbUibPbahXGO0m1H5 qmqja+h3C0bRMu2LyfYjc5Em16tJV5Nd6qk2W19IX7C8dQmDPBLirRQXEdGxSYFV6ev2 UJzH6ujCLDTqww4X6wHLdpUuOzs5Y9BtTAiaUVLgd4XWA/mPqpBqXpgsln0z5OrILq7K QEjUpt+PY16jXkRVf5LDxDN4JvNPHnLf7l9OpEjY1Os816z7G58C4RV6WOal+lVq+oLy zQKiQppN+Gh7Xpbg9UcT/XTqQSQffGjqyUYc4ZyaU768GfpFSKiY2nr+kRggPhaJVwrI O+ow== 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=PDePpgwXcePqusDqA5Z1tklxNFAP/0zBUyt3wDwtZo0=; b=I2PojPKXQ3gBRQVV/Pu/sZgQfpkOLT7z6KdXNaZtUUHtkXbJ8BkFJfAiT+/o8qamvO Y3G0Kos+yGv/dmePrkgzAMsDHzlf/bOGvG8XiYHSAKTKpBF5KwAZeQWV8IJ9d8XVzq51 gF+q/8sNAtfgaaesD2ZNLSihvwh1fXFzq7Uu3gJRFvhE3Eid9gmkRLA2ua9fNN3Ffb41 bkEl9Snw6LaxwEshiIw12i8YQ5sEGNMxaA+9mVylqcrwRXw+g7yGNsFnMCE7vjlkvcpi B30uP4Uieqj+fE9Q6lcQrSIj2+S8pgoZ7YTjoRYyHgdVxyG/Lgl45JG0hyFP60acCdr1 3UyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mN9CHwKp; 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 c26si9380530pgw.251.2019.04.01.14.59.35; Mon, 01 Apr 2019 14:59:53 -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=mN9CHwKp; 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 S1726903AbfDAV6I (ORCPT + 99 others); Mon, 1 Apr 2019 17:58:08 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:37010 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbfDAV6I (ORCPT ); Mon, 1 Apr 2019 17:58:08 -0400 Received: by mail-qk1-f196.google.com with SMTP id c1so6696027qkk.4; Mon, 01 Apr 2019 14:58:07 -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=PDePpgwXcePqusDqA5Z1tklxNFAP/0zBUyt3wDwtZo0=; b=mN9CHwKp6/MH1hbten6BgMOla7Hk1ofRaH8Li3AJLbLI8c77gPJyWYYyH3VEc+wWGQ 0Vwlqocvs6SQ6JWav2PDWCJOcqOXgZ5UACChwf5ZA9k9C2RSJSzWenLPbbDyk65lpq/9 HixdNUF8qRP8jtR5KhrW6INBiAIQJ9v10Mz3tj30nmMqflWJ7Ne18EoPdSw8vQ2Oc3vx dmYft0RAidNsKCl0+7tXCgADrBmNt+3/oBFBxinPF6JzaLyGzju6ZbNhF+6uCk7VnUzV qI5TVk4+MMrNm9HB/uy8P93OlKlUHCdobHxd3D2IJlOZaatcMviaOwwdU9o+hz5YY9Qj iGow== 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=PDePpgwXcePqusDqA5Z1tklxNFAP/0zBUyt3wDwtZo0=; b=c5wrYZvVoCFYu+tLdGJukYO4dDaDaCDyfOw1+sw04QvzrN4aU2p7UKJ58poxqnHTno kn8z0spiH1Am6DR+Vws7nrvUxbt9Jy7yHJ84AoetWbfgtl9aAuQTtzsr4CVd1YtlPPg6 kkQY0YW4Tqe1jQjf61xdtjkw/hAgWYNEvOnccWM0AEmf9EebtzmLlYpXxbG7F0LZzU74 It8BGM0EJA6EF9jFaMp6rDP8cysGAApb/P2jmTg94RLzvlwD9ojUxK77s175QYfaSKS7 gkspb5Rg5Dldn4bQ4SSyodkp778lJFnRS1IfbDLSwew6ODDcQn0CUEmaMQ2oA4rcLhWq 2ioA== X-Gm-Message-State: APjAAAXfTjUCCPH8tjg7cuqn2fPX6GeEP0v5ARCD0nA3o+UUqKj88lLG UpTmvCgMGtoHg7/pyUIccy6UfMx9Ns+AwGJCVCQ= X-Received: by 2002:a37:9cc1:: with SMTP id f184mr53423899qke.211.1554155887139; Mon, 01 Apr 2019 14:58:07 -0700 (PDT) MIME-Version: 1.0 References: <132107F4-F56B-4D6E-9E00-A6F7C092E6BD@amacapital.net> <20190331211041.vht7dnqg4e4bilr2@brauner.io> <18C7FCB9-2CBA-4237-94BB-9C4395A2106B@amacapital.net> <20190401114059.7gdsvcqyoz2o5bbz@yavin> <20190401194214.4rbvmwogpke3cjcx@brauner.io> In-Reply-To: From: Jonathan Kowalski Date: Mon, 1 Apr 2019 22:58:04 +0100 Message-ID: Subject: Re: [PATCH v2 0/5] pid: add pidfd_open() To: Linus Torvalds Cc: Christian Brauner , Jann Horn , Daniel Colascione , Aleksa Sarai , Andy Lutomirski , 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 , 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 Mon, Apr 1, 2019 at 10:35 PM Linus Torvalds wrote: > > On Mon, Apr 1, 2019 at 12:42 PM Christian Brauner wrote: > > > > From what I gather from this thread we are still best of with using fds > > to /proc/ as pidfds. Linus, do you agree or have I misunderstood? You mention the race about learning the PID, PID being recycled, and pidfd_open getting the wrong reference. This exists with the /proc model to way. How do you propose to address this? > > That does seem to be the most flexible option. > > > Yes, we can have an internal mount option to restrict access to various > > parts of procfs from such pidfds > > I suspect you'd find that other parties might want such a "restrict > proc" mount option too, so I don't think it needs to be anything > internal. > > But it would be pretty much independent of the pidfd issue, of course. > > > One thing is that we also need something to disable access to the > > "/proc//net". One option could be to give the files in "net/" an > > ->open-handler which checks that our file->f_path.mnt is not one of our > > special clone() mounts and if it is refuse the open. > > I would expect that that would be part of the "restrict proc" mount options, no? I was thinking if some part of /proc could be split in a procpidfs, with possibly shared code, which means with the new mount API, you could configure a superblock with restricted views by virtue of mount options, per task. This only gives you the view as inside /proc/, and you might not be able to lift restrctions depending on privileges in owning userns of the task. Now, this would mean we keep the notion of anon inode fds as pidfds, and on supported systems, you could configure an instance, pass the pidfd descriptor in the fsconfig stage (David Howells demonstrated similar support for passing user and net namespace descriptors during superblock configuration) and also the pidns descriptor. Without mounting the fs, the mount fd can then be used to do metadata access passing it to openat and friends, possibly passed to others. This is more granular than restrcting access over the entire /proc instance, and can be adjusted per process, and since you need the pidfd's pidns descriptor, you cannot easily cross namespace boundaries with just a single pidfd. You can also create many variants of restricted versions of a single task's proc directory. The pidfd API and /proc access can be connected while also keeping them both separate, conceptually. There are some details but this will wound up being much more powerful (restricting /proc as a whole is ofcourse also fine, in addition to this). There are some details on when and how someone should be able to do this, but is something like this up for discussion? > > > Basically, if you have a system without CONFIG_PROC_FS it makes sense > > that clone gives back an anon inode file descriptor as pidfds because > > you can still signal threads in a race-free way. But it doesn't make a > > lot of sense to have pidfd_open() in this scenario because you can't > > really do anything with that pidfd apart from sending signals. > > Well, people might want that. > > But realistically, everybody enables /proc support anyway. Even if you > don't actually fully *mount* it in some restricted area, the support > is pretty much always there in any kernel config. > > But yes, in general I agree that that also most likely means that a > separate system call for "open_pidfd()" isn't worth it. > > Because if the main objection to /proc is that it exposes too much, > then I think a much better option is to see how to sanely restrict the > "too much" parts. > > Because I think there might be a lot of people who want a restricted > /proc, in various container models etc. > > Linus