Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp853293yba; Sun, 31 Mar 2019 15:04:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEUAGVcUHvsjoUp74aTpcGVXPhCUK91HGRSsU6wKZtV7/IWEWKupYo68gX46KdTCr+6W0j X-Received: by 2002:a62:6985:: with SMTP id e127mr24913211pfc.188.1554069876525; Sun, 31 Mar 2019 15:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554069876; cv=none; d=google.com; s=arc-20160816; b=XqqNKK6lZc1+7/qq2rQ1BJ7Baw+wN3xrMgg4nlO8oikRrG23yBoOACEIJVhE696l+Z 6gxsVLl27k2BF8nIAC/k85bSIpZ10wWTALcC4QHxk4CNiuooObxxb27DMMyFxuELGnna ItkxOd3P0CTHmhXYieFjJWsr0HH7E9ZWyTOMMwBz2Vzlb6+ZsRIK0Km9hBODtMlJI0Zl t7naJWik/C2Z96dEavNdFC8DcHqYMMtf4X+a0jH/+FTIjYOQplnH+R6V69UFbPFItFqs YNRBzZHR5mfgB5LhwMoSAVXNWhuoiQ054hWqzu2fbV54dyUIEUqE70Wyl1/zx6ycE/Wn Gx7Q== 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=LolVlPosekdj/WNDRbmPadZoTDQ+a9gOcVU/g3QUrBA=; b=jPS2E6IV5FA4wK6arJTgTZpFFyjwvV0yso4jmC1GTRrIMcMveCteYofVMFtDl6FWt3 fgqrmegqeECsT80ofwo/ldv2kZVYIaZ928smXqGDcCAKdyBqmHXqYoSOvI4M5goeHh8j 4YDtKMYBT0UGtayPr2YKaG0+aiPK2cqElXi85oVU/yf1B+f24AS4xlkNpmoNCjRcB9fn jQ9BIKrBLNXJONaDeui0G5TTerpXuQ1IZzJ7C2zqXHAH0pI4I3tOnhNUeLxayL7w9Bgy SSGxW26rvqTjxKRohJ2Ko7hHu1NhtS+d7Zm0FgPm/Cy1rrxquxFCbODsZje9Bp2zhaI8 7yhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=C6O14p3Y; 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 l93si7541704plb.331.2019.03.31.15.04.21; Sun, 31 Mar 2019 15:04: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=@gmail.com header.s=20161025 header.b=C6O14p3Y; 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 S1731559AbfCaWDO (ORCPT + 99 others); Sun, 31 Mar 2019 18:03:14 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:32930 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731172AbfCaWDN (ORCPT ); Sun, 31 Mar 2019 18:03:13 -0400 Received: by mail-qt1-f195.google.com with SMTP id k14so8696306qtb.0; Sun, 31 Mar 2019 15:03:12 -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=LolVlPosekdj/WNDRbmPadZoTDQ+a9gOcVU/g3QUrBA=; b=C6O14p3YTUm+KqoJVbXo6t1Ff7FoWKaE+QtppXniFV5LqVCrodLmwn9ERzt/CkPhBb esPwub4EKXdyMJkHaJrmOLUlTOMhlrJ9xtc7EK2qMScjS/jatpkWqfla1/2uhGDJV1AE ViMHALyIm2txXCLgU/tvP/QOH80uciMrq5Wo37/0RrlLsMcwW3ttYwihBmGrtqCVfZkk OKpExfU4ajlrqK3Sw6nA0LZBTNY0SxFuXpwbciqu3ZsOLXxeTINyJ0UGPngfXV3QcrSA 2qFfTQFia7InqBGbmngGYVJiwyVkt79uzC5gqaSqo6OJMs+K2tf8VgFHGhh8oXQlzc42 Hpfw== 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=LolVlPosekdj/WNDRbmPadZoTDQ+a9gOcVU/g3QUrBA=; b=lw7Qk+5UqzpHTfD+DHf+L31kJxs3TvR1mb/S/HC/ziEFVJJtjUe9+o2+LXx47zg3ON LcCJ5Am3nSeAO7piWZ6paqbzitPCMH7FEthtA4wZaVyCusK6XRJz2AWN16QzExiDhPOZ Kam4Zi4jAQNUUep1LP+TQc+02LlDQz21gyCahK3qAHfP/i6OWwf8x4dQIqnGoakSrt3E +jwKf8XZSrj1txAKzRAbkBPRzKaWLXmwks9HAegDNUNC06tZ6pwGdwihK3eMb6Pap+4t Y98bfM/J79eN9UxY/KyFegZCjEGugD1TexpTCp7E9BoCFgAN4KkOZXGxKCC8tzPlgedh bJgA== X-Gm-Message-State: APjAAAVmaNn+71R4GAHqRfB3adiuy6j8AQzEi7LwiaO/geVnmzQwEQ7w 0B+B0tDQPZ1L3yWskYxP1xDbX9DJaroXzeDVkjg= X-Received: by 2002:a0c:958d:: with SMTP id s13mr49088306qvs.205.1554069792561; Sun, 31 Mar 2019 15:03:12 -0700 (PDT) MIME-Version: 1.0 References: <20190329155425.26059-1-christian@brauner.io> <20190330171215.3yrfxwodstmgzmxy@brauner.io> <132107F4-F56B-4D6E-9E00-A6F7C092E6BD@amacapital.net> <20190331211041.vht7dnqg4e4bilr2@brauner.io> In-Reply-To: From: Jonathan Kowalski Date: Sun, 31 Mar 2019 23:03:07 +0100 Message-ID: Subject: Re: [PATCH v2 0/5] pid: add pidfd_open() To: Linus Torvalds Cc: Christian Brauner , 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 , "Dmitry V. Levin" , Andrew Morton , Oleg Nesterov , Nagarathnam Muthusamy , Aleksa Sarai , 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 Sun, Mar 31, 2019 at 10:18 PM Linus Torvalds wrote: > > On Sun, Mar 31, 2019 at 2:10 PM Christian Brauner wrote: > > > > I don't think that we want or can make them equivalent since that would > > mean we depend on procfs. > > Sure we can. > > If /proc is enabled, then you always do that dance YOU ALREADY WROTE > THE CODE FOR to do the stupid ioctl. > > And if /procfs isn't enabled, then you don't do that. > > Ta-daa. Done. No stupid ioctl, and now /proc and pidfd_open() return > the same damn thing. So this is already inherently broken with the /proc filesystem mounted with hidepid=2. What type of object will it return when CONFIG_PROC_FS is enabled, but I cannot see anyone's /proc entry except the processe's running as my own user. > > And guess what? If /proc isn't enabled, then obviously pidfd_open() > gives you the /proc-less thing, but at least there is no crazy "two > different file descriptors for the same thing" situation, because then > the /proc one doesn't exist. There will be when you have no procfs mount for the PID namespace. What do you return in that case? You run into the problem of two types of descriptors on the same system. If you choose to error out, the whole API is useless. Yes, you can now argue that if I use hidepid=2 and cannot see other process's /proc entry other than my own user, I wouldn't be able to kill them anyway, so erroring out is fine, but let's not forget CAP_KILL. > > Notice? No incompatibility. No crazy stupid new "convert one to the > other", because "the other model" NEVER EXISTS. There is only one > pidfd - it might be proc-less if CONFIG_PROC isn't there, but let's > face it, nobody even cares, because nobody ever disabled /proc anyway. I agree that the ioctl really sucks, but using /proc sucks even further. Processes have their own namespace, and that is not the filesystem, it is the PID namespace. As such, pidfd_open should be my open() for an addressable task I can see in my PID namespace, unrelated to /proc. Then, processes could pass a pidfd for something in their namespace *elsewhere*, crossing namespace boundaries, as file descriptors remain unaffected by that, and subject to kernel permissions, you could implement some neat communication primitive just through such process descriptors (which are stable). It's like the filesystem in some sense, the processes form some hierarchy, so I should be only be able to open something I can address in this namespace. It is otherwise a gross layering violation if the /proc filesystem works like some sort of backdoor to open some different kind of descriptors pidfd calls accept (and it ends up working for those I cannot even see). > > And no need for some new "convert" interface (ioctl or other). > > Problem solved. > > Linus