Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2488645ybd; Mon, 24 Jun 2019 07:18:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcr3cqyEFtjuThCCXA0jloCA+sA2K5ECUdfZhOfKloLrUkcE1uDwO8IazyjHiKyDBhimMp X-Received: by 2002:a65:404a:: with SMTP id h10mr33939558pgp.262.1561385896105; Mon, 24 Jun 2019 07:18:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561385896; cv=none; d=google.com; s=arc-20160816; b=EOn+46dSskXnI8WkJIr0NfzqV3gsXgM/2O9Ki4UZejwwGgbKXo3nKU+j+cz9qHkRhC mBCcMEu2Y8/APnbCdpBra5Q1BiB5o8G1wG9z9hvRsq2TrZlxmmHROcHwBrr4Q68Ua8wb RDIKcAh8qEoNaRz+NYQGRVtVQcg3Rt5yeggpueUqRS1MjFuB0TK40FBPBXKNgWOFSNEb ZB92SDKMR8NUwcrpTmyknGxJFXsJhIwsen3UgMKVNDP2F0R8DKeorCar9HVEY8R2pUZ/ LO3/RK5FhuCzyPFWGhl0Z8BMOPw3+dzNien6Lepw727sMJEs+0JLFcV55nT/q2nYq4Uq rJbg== 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=rsdGK2qnX79rTvs0ljNXRm1xbFRSbM8T7vFuJMDh/e4=; b=wXEKT0YIqr6DVFpuaAaEXr95U6AZdMJpycXZLfnmsw9BkQ/r756VmAWf4pjb+WyYsi z/xLtNCz1WuxFruMcVzbu4i0AQ5ycpcJZhbWQWuUGPDW99vNt6Q+T6+QL5/lOfxqBfpg sSgF9bEJ2rsMmeu5DRg7zVkTGQpqo4ZGLIaQtbxDIGya1WavSUIJBnpmQ6G7n9ayVe/M 0ZaNZq/5IYrCkMkvlq4uFiQyAVOwGNyMZrHUTyg+ZMDNjetL+7pCRpoLfgYp5LJE8GAV qzen92E59G7brXb3tmKLWg7ymxEeGFWQdx5IKIZ0cqfmKou7uTVdjTOL69qySaVonwLH 96rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=Y2tiIQZw; 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 e12si6732106pgs.34.2019.06.24.07.18.00; Mon, 24 Jun 2019 07:18:16 -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=Y2tiIQZw; 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 S1731250AbfFXNtZ (ORCPT + 99 others); Mon, 24 Jun 2019 09:49:25 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37402 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730435AbfFXNtY (ORCPT ); Mon, 24 Jun 2019 09:49:24 -0400 Received: by mail-wr1-f67.google.com with SMTP id v14so14009841wrr.4 for ; Mon, 24 Jun 2019 06:49:24 -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=rsdGK2qnX79rTvs0ljNXRm1xbFRSbM8T7vFuJMDh/e4=; b=Y2tiIQZwBrjoPLeq3Rv0KfJCpIb+su9vtzZU4xXl4jeBRjs2aSiX0vpl3DmBFrc3XA AAN3mK5Ju8rd5DhZr3DDBqGcchmQlUXxeGY3ypb5EZKknZkeUUjLWVqcd5Z1RM6FtIcy 8fyFEJlJW2dw+FbWJgoYfPl5XGmJxeXo1eUjRLeQbu5zidjUgCKL2flBaZ3rr26LNBhE nS8jzzI1f5+kwATJP9w96MmBHywPO8qfWk9CZ8RE+xHUctiLnZ/n+KbxQZx1Sl8LRVFN Ou39dJirN1zI71ePA2LcSxCxo6jHY0j++wiDDkOQaunwXkelmFvCY04HdJTNAvcEuJVr 8j/Q== 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=rsdGK2qnX79rTvs0ljNXRm1xbFRSbM8T7vFuJMDh/e4=; b=D8fiMg6Cj6bbTJ1gX/WNpj4bicJUclg40ekjoT3gFYxPVvXAUnrEinoZ/vftDWHNe4 o24/n6hcrRZyeT2Ory7n1xDPcgIxgUH4DaCACg1c14JOkUdfF9g+XrAAV0LwqJpaceNQ QlhLpurd1Zu2QpFUr98X/462mmodg0jl8CSjggqse81tW7PyYVEJfyUKE6khKOnLKlAT ju1VFcRJrAVuYbaBegFhMShFxq9cT+hBd7TJ3vxP9FVHnf7QUfSVUNnsQG2MRsX0mLMH 2Vcm3HlahXlLxBK4VKxG6FPvjw+Ebn9Yhsw92p69OZb3+fe4ZFC9tsIMsfUNfkizo/SY Kyvg== X-Gm-Message-State: APjAAAV5DzC0Tdc4nJ2XyE3gnZdwgSJsC+fISLUl2JUHNc0AMJ0056rV TAsqBftu68XfNC1W0fNaLPQGxw== X-Received: by 2002:a5d:67cd:: with SMTP id n13mr98450455wrw.138.1561384163510; Mon, 24 Jun 2019 06:49:23 -0700 (PDT) Received: from brauner.io ([212.91.227.56]) by smtp.gmail.com with ESMTPSA id s8sm13760952wra.55.2019.06.24.06.49.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 24 Jun 2019 06:49:22 -0700 (PDT) Date: Mon, 24 Jun 2019 15:49:22 +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: <20190624134921.mvgabuz3mgmpuu3n@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> <20190624115942.g6vyis3zy4ptt3fc@brauner.io> <20190624134531.GB6010@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190624134531.GB6010@altlinux.org> 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 04:45:31PM +0300, Dmitry V. Levin wrote: > On Mon, Jun 24, 2019 at 01:59:43PM +0200, Christian Brauner wrote: > > 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. > > s/Old kernel that only support/Old kernels that only support/ Fixed. Thanks! Christian