Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4459642img; Tue, 26 Mar 2019 09:47:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3HBY7zDFDCFk0qFOZZTtog46LPBRauUBX/IY1C5NWIWofvcO4lV7SNw2biTP3xNbWNB5N X-Received: by 2002:a65:64cf:: with SMTP id t15mr15330135pgv.322.1553618863192; Tue, 26 Mar 2019 09:47:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553618863; cv=none; d=google.com; s=arc-20160816; b=fEsVnq+O3mzA28dzrNScpYYRuQWCI3aqPPRMPsYIVWVScYcQS0CZVzu7CtPBX5mQLN uI7MQb6TNpsyD2ym22CY3BpWvAWJDq/BGPPm2fMfYM8bFaj8IisS/ki9Q+E1h7ixHVpu Z7rL9PRY+ti73/gaQtlJtDNfI93iM1TPg6/nLdBR9ca4awGJWWw2YJyoYZF4ulVRtAGN daLM0htWtRC1SyRpQltt7jeW+PAS/dtp0I9WYjzG4CgfrKvxHViHddDGMgtZhuUKp/nH O6MNG9Ty+j11c1r1xMbDrU6zUSSGctbphfNEuB6Nma4JhipoWNpjBYe7cje+h0sWVWSv 70GQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=CUnsG4nZFUqlK9xMVi9XxULBtSGFwWhB5AMNqq5lCZ8=; b=lEKJPrq58smlXQO823hchbQ/+1oKzkg4pLC3o+qQN4iHAYFRrxmGt+YZAwsxiTb0iD MH1+s2o1GdwknornVn+LvEolGVLq6jWONph2EIcOUl+O8Ux0c23RCDX5NzkBLwTlxNDO NucNl1gbyMH6l1dHlmorsQz7dl7yKkqr2SItgyGNh7zwZxeuFCSb6FcAnuuPsLommxJ9 X+zRFwbL/oYH9cHAA0P9UC74wE3xJf/sHfP4BSwmi3h/+IXQJduaC8pgVbVTgk3OZr3t luDsGvoQ07us0oJLOyKl6v/D6EnZ5dJEWNn7jS0DWuhXdUnTi9BGPZFFyaUwEaVI6POP z0Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=CUo8nHTi; 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 e11si18320645plb.140.2019.03.26.09.47.27; Tue, 26 Mar 2019 09:47:43 -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=CUo8nHTi; 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 S1731679AbfCZQqk (ORCPT + 99 others); Tue, 26 Mar 2019 12:46:40 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:42704 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726258AbfCZQqk (ORCPT ); Tue, 26 Mar 2019 12:46:40 -0400 Received: by mail-ed1-f68.google.com with SMTP id x61so5716680edc.9 for ; Tue, 26 Mar 2019 09:46:38 -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:in-reply-to:user-agent; bh=CUnsG4nZFUqlK9xMVi9XxULBtSGFwWhB5AMNqq5lCZ8=; b=CUo8nHTi1akTKAjwBghAYXcl0jRTdTclaEgYc3ltfrOnEzpTnmoh45F82+lfSt2ebH JWud442HMi86C3kPXWbG5yJbGD6OFUXNXbnD1tnic4gvge0CSQY137gKReHZgkSKUsA4 CSnagauy1blVftDXr6F7PY+hFBqUZFwsAipR0ZDQ+DwV5hRdIMgftBu05hhPNwjrwzIX fjDU3XO69bkOi6m+LCJ9FM2FJWKGtCen7yb9f4UcSMTAM/USGhpFdPon2Sj7UBqhEDQQ bcuBb8Hd8cgt/FtbWqrJD3PbicXn7qnDEjIuu6FDHV9cQWe0oWi5Z1+ZrbIDkkm9NoP1 Y8Nw== 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:in-reply-to:user-agent; bh=CUnsG4nZFUqlK9xMVi9XxULBtSGFwWhB5AMNqq5lCZ8=; b=S3FPU7uDoBi/Dsux70sBkZ9UJ3D66b7gqdZBKuS0xknKa97EQ7iEd9FydRdhYuITS3 OSUrripfhbYJi9NV9WTXGySKaj/SqY2kSw9v4LTLtWmbcvkdodwjGmk7ABpIgoOw1y0k QruQ/zpC2q7awajv9EOKKRLcV6bcEZuZq+5MbMxM3iyPIbPWBIXKPz2zprZzFEjti35u ILUKAkxYl18+ultOLEtdTl8cJ1W6hTmy15Zfg78HGJ8UzOiEyEeEBCk3Qd6+9p29IcPQ KMCp7d2UQvowHKCa3R3FoiBeoSFNx7SnpKEQEP/g4FE8YUllJazV17JlPmZttLEqgQlZ moNw== X-Gm-Message-State: APjAAAWrGY7oUgdIyqAqM59LYTRFnmWmJXwBmSFLK7wCxp6LeAci3GeH bwbEd/gYUn4uV7sx7zCuH4P4Xw== X-Received: by 2002:a50:cccc:: with SMTP id b12mr21233010edj.94.1553618798235; Tue, 26 Mar 2019 09:46:38 -0700 (PDT) Received: from brauner.io (x59cc895e.dyn.telefonica.de. [89.204.137.94]) by smtp.gmail.com with ESMTPSA id l44sm6297030edb.37.2019.03.26.09.46.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 26 Mar 2019 09:46:37 -0700 (PDT) Date: Tue, 26 Mar 2019 17:46:35 +0100 From: Christian Brauner To: Andy Lutomirski Cc: Daniel Colascione , Jann Horn , Konstantin Khlebnikov , David Howells , "Serge E. Hallyn" , "Eric W. Biederman" , Linux API , linux-kernel , Arnd Bergmann , 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 v1 2/4] pid: add pidctl() Message-ID: <20190326164634.ba5dko6weazp3zyd@brauner.io> References: <20190326155513.26964-1-christian@brauner.io> <20190326155513.26964-3-christian@brauner.io> <20190326162337.o256x7hiodu2qfyg@brauner.io> <20190326163142.4eh5qpgiqvygf26w@brauner.io> <20190326163452.uku4bgkessxzxvai@brauner.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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 Tue, Mar 26, 2019 at 09:42:59AM -0700, Andy Lutomirski wrote: > On Tue, Mar 26, 2019 at 9:34 AM Christian Brauner wrote: > > > > On Tue, Mar 26, 2019 at 05:31:42PM +0100, Christian Brauner wrote: > > > On Tue, Mar 26, 2019 at 05:23:37PM +0100, Christian Brauner wrote: > > > > On Tue, Mar 26, 2019 at 09:17:07AM -0700, Daniel Colascione wrote: > > > > > Thanks for the patch. > > > > > > > > > > On Tue, Mar 26, 2019 at 8:55 AM Christian Brauner wrote: > > > > > > > > > > > > The pidctl() syscalls builds on, extends, and improves translate_pid() [4]. > > > > > > I quote Konstantins original patchset first that has already been acked and > > > > > > picked up by Eric before and whose functionality is preserved in this > > > > > > syscall: > > > > > > > > > > We still haven't had a much-needed conversation about splitting this > > > > > system call into smaller logical operations. It's important that we > > > > > address this point before this patch is merged and becomes permanent > > > > > kernel ABI. > > > > > > > > I don't particularly mind splitting this into an additional syscall like > > > > e.g. pidfd_open() but then we have - and yes, I know you'll say > > > > syscalls are cheap - translate_pid(), and pidfd_open(). What I like > > > > about this rn is that it connects both apis in a single syscall > > > > and allows pidfd retrieval across pid namespaces. So I guess we'll see > > > > what other people think. > > > > > > There's something to be said for > > > > > > pidfd_open(pid_t pid, int pidfd, unsigned int flags); > > > > > > /* get pidfd */ > > > int pidfd = pidfd_open(1234, -1, 0); > > > > > > /* convert to procfd */ > > > int procfd = pidfd_open(-1, 4, 0); > > > > > > /* convert to pidfd */ > > > int pidfd = pidfd_open(4, -1, 0); > > > > probably rather: > > > > int pidfd = pidfd_open(-1, 4, PIDFD_TO_PROCFD); > > Do you mean: > > int procrootfd = open("/proc", O_DIRECTORY | O_RDONLY); > int procfd = pidfd_open(procrootfd, pidfd, PIDFD_TO_PROCFD); > > or do you have some other solution in mind to avoid the security problem? Yes, we need the proc root obviously. I just jotted this down. We probably would need where one of the fds can refer to the proc root. pidfd_open(pid_t, int fd, int fd, 0)