Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2368675rdg; Sun, 13 Aug 2023 23:19:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFH1fzUIkDBoHOw+reS0gy53uqXkld8d0F4MOtyP9b0TGnB88YsmTrdk2lB26gDnRh+BDnl X-Received: by 2002:a17:906:738f:b0:99b:dd38:864d with SMTP id f15-20020a170906738f00b0099bdd38864dmr6705146ejl.23.1691993961362; Sun, 13 Aug 2023 23:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691993961; cv=none; d=google.com; s=arc-20160816; b=QxYrCsiBENizEelt5QY9Y12OVh9bNXFvzd/npZfPvC2gdt6x7fm0WpuXo4Yxfoj2WO 0w2YTtmPkbg2wZJFZPKUd5o3smzCjxYMUl0ZSNYc3/5Tb/WwHwNXtWctRYQhJldTyO9i rY6x8WurHdko/p1YtIG5ub2VI0z4YEUDNYSbFo/XSGf7qjtjUV+tn8O9gAKW5cHpD3YB H0MtN4sxMEG98ySkJyVioddQRHInuu06cKpsbKjAC5pol5Y1HJXl9Ln73cQzmNAACBsF qL0mXjKuW8Zp1ww5dJHGH/IBot+F59QcC46QpJzW8E21eqK6Ke4FR35bBcovfoaFDSxJ fmWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=zkizbUTAIxQH29l5UUOkg2ZePPgXb8Du8bWmk2iGUB0=; fh=jkPsxaMT1fqwx5N5M4SdsrPHn3VIdgBbXhbasVKic38=; b=EgL7Q269kn6PTIDJ7FoG5tDefR1j9KsILbeanW6d910AEQy9vvmiipfpNa0I20coM8 tksBdNYEIn1Y4kJQ2CxDE6dfmQ1V5+0VADGCiUe/4qPJduKdETUGVcblM7i9xFgWXZoT zvDBXd1xssdix5iRGtDvXV/NG419v2dAUnRs99y4FTFtKw2jSLfM2/T70xOnKr9UPMWO BWHpf8gEOn6d4hyNiGswmPXex+/u2s0u2pu6Y6+dEWypfpGRCgaVHT6sfT2lF/qGs5Q5 9/d93z+CILZek9ZZKAjUP8HJpY67se1ZrnAfne41xlebzMBArIjiOqCjt5KYVkWPaJJL KMaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@readahead.eu header.s=fm3 header.b=rj2Fkwix; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=0Y2xraBV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id le1-20020a170907170100b0098d5b116e6fsi7196485ejc.856.2023.08.13.23.18.56; Sun, 13 Aug 2023 23:19:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@readahead.eu header.s=fm3 header.b=rj2Fkwix; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=0Y2xraBV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232607AbjHNFN4 (ORCPT + 99 others); Mon, 14 Aug 2023 01:13:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231716AbjHNFNy (ORCPT ); Mon, 14 Aug 2023 01:13:54 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B880E5F for ; Sun, 13 Aug 2023 22:13:47 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 896765C00B3; Mon, 14 Aug 2023 01:13:43 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute6.internal (MEProxy); Mon, 14 Aug 2023 01:13:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=readahead.eu; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1691990023; x=1692076423; bh=zk izbUTAIxQH29l5UUOkg2ZePPgXb8Du8bWmk2iGUB0=; b=rj2FkwixNHD4bwFkP7 lSvb2txdrt6j1Fr8s5CPtkPZ641AC/I9j9F8dUikG7Rnp1xymF+f9EkoZBuscVPO 39TWi2t7k7HF+9kyciBm2PY77ibC1umhAqWI45zUTLtNoWML9l0rMxNr6UtT8MG1 OOhrE3CRXvpzp4AlvYKW+1QXU156dceQgKZW9p2VjGbXmiK88BblDHTsOEvwOQTo u/MLAQKFXEWWxUplYhTYm6DQ6s2PKFVf4wb4KZvgBtD7PpyO4E6+/2VptYoC1Ede TZNwyr0SrV663crgpkfzO4rjPYtcoMxfHL2LOMtFN9vQ7RTGcHnzGfES6Jvj5dg6 fALA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1691990023; x=1692076423; bh=zkizbUTAIxQH2 9l5UUOkg2ZePPgXb8Du8bWmk2iGUB0=; b=0Y2xraBVEdqJJj4IMWcEtgP5a8Z7S /tIVflGH+eubGkJ7dpu/Ko2uEv6oaGIiRA6+IMR0bzgh3jmS5d3rQXKgjLfraM9J 97RQIZJfz5lHF48pVUzDuW0rN+iA3/+R+5iFTNmV6GkcMxOhDAdJew6in6ehfPC2 n7VdsqXg2g0TzIHyCmmIn1zjmzlfxcOATTTIHi1R9bgm7DHEo1h44fAGOCRf0SHg 8E7sYKk4HD9Goti4xQPNnMuos3IHNVIrq6NABtbUnI4R0IZWxWhSxE2LfEQZoKzW NE4a9Uu0slPjKDynVFpvIu2QUFa1N+DP/1XAJ7taCI2uw2XQ071S5FrGw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedruddtfedgleefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedfffgr vhhiugcutfhhvghinhhssggvrhhgfdcuoegurghvihgusehrvggruggrhhgvrggurdgvuh eqnecuggftrfgrthhtvghrnhepfeelgeeuheeihfeuleefleehtdektdeihffguddvheef iefhveelhedvvdfhueeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepuggrvhhiugesrhgvrggurghhvggrugdrvghu X-ME-Proxy: Feedback-ID: id2994666:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id EB5241700089; Mon, 14 Aug 2023 01:13:42 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-624-g7714e4406d-fm-20230801.001-g7714e440 Mime-Version: 1.0 Message-Id: <6feef7e0-ea72-412d-837e-34b6fdd3b869@app.fastmail.com> In-Reply-To: <20230811115710.GA21779@redhat.com> References: <20230807085203.819772-1-david@readahead.eu> <20230807-porzellan-rehkitz-9fde1b94dd6b@brauner> <20230811112911.GA22566@redhat.com> <20230811-perplex-installieren-899f5925534d@brauner> <20230811115710.GA21779@redhat.com> Date: Mon, 14 Aug 2023 07:13:09 +0200 From: "David Rheinsberg" To: "Oleg Nesterov" , "Christian Brauner" Cc: linux-kernel@vger.kernel.org, "Jan Kara" , "Kees Cook" , "Alexander Mikhalitsyn" , "Luca Boccassi" Subject: Re: [PATCH] pid: allow pidfds for reaped tasks Content-Type: text/plain X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,T_SPF_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Oleg, On Fri, Aug 11, 2023, at 1:57 PM, Oleg Nesterov wrote: >> What code do we need to allow userspace to open a pidfd to a leader pid >> even if it has already been exited and reaped (without also accidently >> allowing to open non-lead pid pidfds)? > > I'll try to think more, but can you also explain why do we need this? > > See my another email. Can't we simply shift the pid_has_task(PIDTYPE_TGID) > check from pidfd_prepare() to pidfd_create() ? (and then we can kill > pidfd_prepare and rename __pidfd_prepare to pidfd_prepare). Yes, the easiest solution would be to use `__pidfd_prepare()` and ensure that the caller only ever calls this on tg-leaders. This would work just fine, imo. And this was my initial approach. I think Christian preferred an explicit assertion that ensures we do not accidentally hand out pidfds for non-tg-leaders. The question is thus whether there is an easy way to assert this even for reaped tasks? Or whether there is a simple way to flag a pid that was used as tg-leader? Or, ultimately, whether this has limited use and we should just use `__pidfd_prepare()`? Thanks a lot! David