Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2469777ybd; Mon, 24 Jun 2019 07:01:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVeN3tMNZXFKcFORUGHtXm1nJcC+B4fokNk/tjdsJgsq51VOg+3q4Ar3eVWhsFMxKOrn6i X-Received: by 2002:a17:902:6b07:: with SMTP id o7mr124820102plk.180.1561384889866; Mon, 24 Jun 2019 07:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561384889; cv=none; d=google.com; s=arc-20160816; b=j0KK0vnm0CHwEOV8A7rOh5iZcPpYxg/euzZiGeNxVFxd0a4d7eTIquRwsr2PoQL7// o9JcHz1+4ONBY259GpW/yLgYm2KMIG1P4+WTqfnReq2mIvlfrjSncFCUI4sjIpgoQDtf heTy0SGtDvlRJB6F3oLbQivN5rJiI5SSaT0XLqa+KySS3izfa9Fjlrq81rV0o5/JNNl0 Qq6ptVDO6kBsJzcwzN+1Cpu3rP5reOqhlvVcqTtN0riyuD/NjbfTjKq094XtEVO0nhNW 9cX38VK6ey5gBi4LFFbSos8EAJaxF9zFYiJkzjZzFtEVz8qaibSD/IhkFBVDSPpenjKI J2MQ== 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=NISf2AF+teimA9xsNpoKX9LvLTU//qt9iSbtSvGhumw=; b=zDWCQkZHG0zITBTOjgYzL+LgmFwUE4Vrty8Kqgrpn6gB/4ML2+KDCXwbN+t8lT3Y9s EXaFGD5qpKCdiH0vGe/QpL/mSsFcIDaNzJs1krK7+fkjfMRCO2GzumZKgjZ7Kwkjx07V rjdIiU1mHl6FbTifqX5fbQVNenITX0qekkUh40/Ii5XRyCa3JreCynum9DH8NB8WnAk+ nscmE3feH2s+GkD2uv9Lm8KlgvgvjUe5460rpnq7rGoYIWEmPW095d82Z/n6u/Oe5Sfy Qri6GZt1Z14gy/XBeX+kIgrvxOwAhSTHX2Y/Cvh3D3GvCotvkMQRqmvUr3wKmxTOh1Eq ZAzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=O33JM0SQ; 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 k134si529960pgc.363.2019.06.24.07.01.13; Mon, 24 Jun 2019 07:01:29 -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=O33JM0SQ; 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 S1727982AbfFXL7r (ORCPT + 99 others); Mon, 24 Jun 2019 07:59:47 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35545 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726679AbfFXL7r (ORCPT ); Mon, 24 Jun 2019 07:59:47 -0400 Received: by mail-wm1-f65.google.com with SMTP id c6so13125480wml.0 for ; Mon, 24 Jun 2019 04:59: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:in-reply-to:user-agent; bh=NISf2AF+teimA9xsNpoKX9LvLTU//qt9iSbtSvGhumw=; b=O33JM0SQsoxgxG2UxDCzjJt5FATg92mACnzbJMOJ77sZn/u3/ZkeQMZe+44zyPFGFy azEIg/a/j6bQ62w12aW1UhqEjbzphb6ucFWHtE/9KOXYAA/QBPc92y9/CFLB2p7VYxyE KN/Lig39fYFeU5wlSB7JhOX/1StAcz9efFdJ1B/fOz0uU6k/ViJIuhFhgqYO9aDDDu1o SWdMhVNBoh0scdsdFhZeX6GY31qP6jfT3DuVZeCd7OWql8DZJ4wBi8zTcHRjEhIATAWy PxNsFyyX06R3vxUWF1CMot/Wi3UsysFBxit5k/umwYwAs8spQsp1WxgIZBkw3MD4Ybt7 iUqw== 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=NISf2AF+teimA9xsNpoKX9LvLTU//qt9iSbtSvGhumw=; b=Rn8w/UPWC4sMRW0mJd3W8PtDzKuLKzRtMUXgfWJ0c0l+SPMGJLCOEgE3bsuYLvjDBQ sDOG6EIKWf3rUvPaiyS0ZLA5l7Hby+cu3znE1Ihuo9NhUWADBJv7XM6I6yRvaYnt36LE la14wqgJ01MVLAcMwOWe9LQJnos9V9yaMEF7tXG9XJtYKIMH2zDRBP2DA3EfJ1ylPMjx YSY2C9GYzgiX8G5e7z9QYFB6HZFxRJucwx9Y4cKpXDVwWvXhIfWV9RgjT/zPrjHms5i3 5XGrIYFjSwoyLE1j8f/U+1NlzT2A6GzqyDSHm/TVI0x8BwdZyb0v0pZ3qlyymaQHTSNb iUvQ== X-Gm-Message-State: APjAAAV2ITE5BhIph8wJqE09CUV6WcHOZt+da3sbq8TX38Y4KkEzVQBK XaSH33HKtJYmHimB4YaB5nLnHw== X-Received: by 2002:a1c:a6d3:: with SMTP id p202mr16445912wme.26.1561377584822; Mon, 24 Jun 2019 04:59:44 -0700 (PDT) Received: from brauner.io ([212.91.227.56]) by smtp.gmail.com with ESMTPSA id l1sm32113168wrf.46.2019.06.24.04.59.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 24 Jun 2019 04:59:44 -0700 (PDT) Date: Mon, 24 Jun 2019 13:59:43 +0200 From: Christian Brauner To: "Dmitry V. Levin" Cc: Jann Horn , Oleg Nesterov , Arnd Bergmann , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] CLONE_PIDFD: do not use the value pointed by parent_tidptr Message-ID: <20190624115942.g6vyis3zy4ptt3fc@brauner.io> References: <20190620103105.cdxgqfelzlnkmblv@brauner.io> <20190620110037.GA4998@altlinux.org> <20190620111036.asi3mbcv4ax5ekrw@brauner.io> <20190621170613.GA26182@altlinux.org> <20190621221339.6yj4vg4zexv4y2j7@brauner.io> <20190623112717.GA20697@altlinux.org> <20190624094940.24qrteybbcp25wq7@brauner.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190624094940.24qrteybbcp25wq7@brauner.io> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 24, 2019 at 11:49:40AM +0200, Christian Brauner wrote: > On Sun, Jun 23, 2019 at 02:27:17PM +0300, Dmitry V. Levin wrote: > > Userspace needs a cheap and reliable way to tell whether CLONE_PIDFD > > is supported by the kernel or not. > > > > While older kernels without CLONE_PIDFD support just leave unchanged > > the value pointed by parent_tidptr, current implementation fails with > > EINVAL if that value is non-zero. > > > > If CLONE_PIDFD is supported and fd 0 is closed, then mandatory pidfd == 0 > > pointed by parent_tidptr also remains unchanged, which effectively > > means that userspace must either check CLONE_PIDFD support beforehand > > or ensure that fd 0 is not closed when invoking CLONE_PIDFD. > > > > The check for pidfd == 0 was introduced during v5.2 release cycle > > by commit b3e583825266 ("clone: add CLONE_PIDFD") to ensure that > > CLONE_PIDFD could be potentially extended by passing in flags through > > the return argument. > > > > However, that extension would look horrendous, and with introduction of > > clone3 syscall in v5.3 there is no need to extend legacy clone syscall > > this way. > > > > So remove the pidfd == 0 check. Userspace that needs to be portable > > to kernels without CLONE_PIDFD support is advised to initialize pidfd > > with -1 and check the pidfd value returned by CLONE_PIDFD. > > > > Signed-off-by: Dmitry V. Levin > > Reviewed-by: Christian Brauner > > Thank you Dmitry, queueing this up for rc7. This is now sitting in https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/commit/?h=fixes&id=43754d05f235dd1b6c7f8ab9f42007770d721f10 I reformulated the commit message a bit and gave it a Fixes tag. Dmitry, if you want you can take a look and tell me if that's acceptable to you. Thanks! Christian