Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1801784rdb; Wed, 31 Jan 2024 09:24:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlrKF9xCrUhfKRqC6x6A8it90KsFvXdR1Zto96I3cNhMvI9QC97NSwmQD6AjXvvm6Ps5wF X-Received: by 2002:ac8:7fd4:0:b0:42b:e6d4:e488 with SMTP id b20-20020ac87fd4000000b0042be6d4e488mr2066360qtk.12.1706721859787; Wed, 31 Jan 2024 09:24:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706721859; cv=pass; d=google.com; s=arc-20160816; b=ZMgvxzYEW7P10J7I16A0quwets6atoEkxwmymAcqrHVVlVzyMqIq+Urd2FViaAg6zu 84sOA/7syi7H6lvAs9aYE2KtSFlWAXsvNkhaIi3Yd+Nq7mBqslXmjav2esgttfIYfZlH i0BQLgcA+QEFsyDGS5lqL5LiQWvRo3GhO3ehQ2ja8fiJjKgN1SOt+THPCSPAHIMwqDb5 pIdxn721sSmT2bEyqEtJnX17Gl72nDUpim8DZUuwAktZQsa9f1Qp/4Wvy3a/mmhVFJwd I8nmXJqCB6Tf7tG0mnVSbI2ooPLHV3+ozt5n+JRkeEy+f9z9JKfiXVpxycP7nWt2yXd/ YCNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature:dkim-signature; bh=zMKGJxHDLhy9XiJ/65aFtBKWBCwquZ0HqRnigxHPmzQ=; fh=UkbqrehOEjobFM501VCcocGckuTURP/gXD2RvNv9cb8=; b=VrSu3gfcg/GxLNbCDVeLEE5Yph8iVo/lnOJ8VuFX6+3BEfv5mkfpIpz7cuElAO2CG/ fJs+VcD3jTN8iHSV9MXhvPqQAinNHIifx8YSy+gNh4idF5W+uJg2v413CbGl5o0KH4jh DfL7jyfTjjACTpHYD4Jj0Nvn7FpLr9OZW/gSdCWa35jcaEtyTtTRMyIL1wkjUrAe16ZE BDn0FK0nKg3gN2/qzTmna4opWVQ8TwvFPqcUhtUBQS4zkyLj0dK5acGyPQcvTusLkoBx X3K5+4GDdxZ9NZ32oNFAWDLJDctI5gd8fpR3807Tbs+Br958FtHf6/5s9OGAVXmXjUQv kVZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm2 header.b=FdgYdwWY; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=vwNnU0A9; arc=pass (i=1 spf=pass spfdomain=tycho.pizza dkim=pass dkdomain=tycho.pizza dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-46902-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46902-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVXrdpavr9kSlPG6O0p1WGJwgY7EuCqrWAzdoT7ztiyi+vaxqJ+EgZ+7xBx9u5JnedLzb7GuKDG+hjWH4Ndz5wBt4ij5fI4IL4P01cBcg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r13-20020a05622a034d00b0042beebb9dc1si692391qtw.391.2024.01.31.09.24.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 09:24:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46902-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm2 header.b=FdgYdwWY; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=vwNnU0A9; arc=pass (i=1 spf=pass spfdomain=tycho.pizza dkim=pass dkdomain=tycho.pizza dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-46902-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46902-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 85C9E1C25177 for ; Wed, 31 Jan 2024 17:24:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE8B512DD80; Wed, 31 Jan 2024 17:24:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tycho.pizza header.i=@tycho.pizza header.b="FdgYdwWY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="vwNnU0A9" Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45C4412C52E for ; Wed, 31 Jan 2024 17:23:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706721841; cv=none; b=IgBJEV+tnU+uMZC7Pe+0EqEIDYGHK9wtERHwvdR2WD55XFSOnBtwhQY2UjKmmL+4t/aWEUjKc7qwWSCGbS0XyjeVbc4Dw0iG6CdaFCOGp+o5Bm5zeu3CC6kumw2B2YPHT6rKr0vSCCWDSK0C9niBz0amqf47LpP+Yw0rihJUvr8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706721841; c=relaxed/simple; bh=j+Bbez0gzj6+f+YJhhb/ozw9CFQoNu8iD9ScjEsL1JA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EMXJCKJL5L+OIdUMjdYdJvzg52pZ5z8gc+RR0kzGSzR0UMw4trL5P1vPUqGPyST+qKkocR6NQwd3FcptlXQT3GosnaB3InisoW8I+WjochzsFkLdOTXdCC7wyxfSLurVtXuUdRg5+QC2ijNUUoMJn2l3omS1UySewh6TTBYBC8s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tycho.pizza; spf=pass smtp.mailfrom=tycho.pizza; dkim=pass (2048-bit key) header.d=tycho.pizza header.i=@tycho.pizza header.b=FdgYdwWY; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=vwNnU0A9; arc=none smtp.client-ip=64.147.123.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tycho.pizza Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tycho.pizza Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id D88AF3200564; Wed, 31 Jan 2024 12:23:57 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 31 Jan 2024 12:23:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho.pizza; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1706721837; x=1706808237; bh=zMKGJxHDLh y9XiJ/65aFtBKWBCwquZ0HqRnigxHPmzQ=; b=FdgYdwWYm8m9HkTbaWdKBsylST z0y5qnTQ+EfzjRWQEca94JPF5VLWGMyb1y4BbSd7kdL+XQ4wHWATPRJiLH+RMnb5 16BlZ2r9RH9A8+opNvMb4U4/Leiwjyq/fj7iA//cpRVEyh9ZmsMTVIwyfpvGwlqK Gf0wJjMO5fLVJunY+6tCx6gIsQqZ2BI/EK7fblJEpKi3MDKL0zx8Vk9irlYfVpxE zrmj1Rj6HCIf3ky9aL3IdWf7Ow1tmEdAmx7y6pBhsNrFSQHvHiS2oM8z8n+M6X1p l1oNPberumR5Fi7pCtoji5DJ0BFv3Zl/9OlViemJg9BHgN3q9IXHJdSqUslQ== 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:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1706721837; x=1706808237; bh=zMKGJxHDLhy9XiJ/65aFtBKWBCwq uZ0HqRnigxHPmzQ=; b=vwNnU0A9C9Yai7toKg6f1Q0bMNdpPKCQ3uYzbup8sB/0 pvFltR2plitNjjOOQwDX7iNsgtpT8BYJaCc8WrQ1byVvB6y0/+Aa+4vy9OpqDrhy pmtcDg8dzzDpgBik7htIkJ/xygD2T8J3mjaXQhQj3mYZNk6FH7xmIR5Qp3wPHxL6 HlhsOCgJH7kTFASSWkEbkgs+aVSxQhiY56qmcUT74a5zZTtj2b2H4AL+JjlkHWRy 6E6fKu9nUDeXSiItbWuEoDIyWV0vM4coix058jVTaYxCeLlMbXlNwdeiXp/7vmBO dJfBvjg5EbwnqZ0BCeEDKm/GimryNFsPkstjxFX2Ng== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedtledgleekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepvfihtghh ohcutehnuggvrhhsvghnuceothihtghhohesthihtghhohdrphhiiiiirgeqnecuggftrf grthhtvghrnhepueettdetgfejfeffheffffekjeeuveeifeduleegjedutdefffetkeel hfelleetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epthihtghhohesthihtghhohdrphhiiiiirg X-ME-Proxy: Feedback-ID: i21f147d5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 31 Jan 2024 12:23:56 -0500 (EST) Date: Wed, 31 Jan 2024 10:23:54 -0700 From: Tycho Andersen To: Oleg Nesterov Cc: Christian Brauner , "Eric W. Biederman" , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/1] pidfd: implement PIDFD_THREAD flag for pidfd_open() Message-ID: References: <20240131132541.GA23632@redhat.com> <20240131132602.GA23641@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240131132602.GA23641@redhat.com> Hi Oleg, On Wed, Jan 31, 2024 at 02:26:02PM +0100, Oleg Nesterov wrote: > With this flag: > > - pidfd_open() doesn't require that the target task must be > a thread-group leader > > - pidfd_poll() succeeds when the task exits and becomes a > zombie (iow, passes exit_notify()), even if it is a leader > and thread-group is not empty. > > This means that the behaviour of pidfd_poll(PIDFD_THREAD, > pid-of-group-leader) is not well defined if it races with > exec() from its sub-thread; pidfd_poll() can succeed or not > depending on whether pidfd_task_exited() is called before > or after exchange_tids(). > > Perhaps we can improve this behaviour later, pidfd_poll() > can probably take sig->group_exec_task into account. But > this doesn't really differ from the case when the leader > exits before other threads (so pidfd_poll() succeeds) and > then another thread execs and pidfd_poll() will block again. I don't have a strong opinion here; leaving it "undefined" for now is fine with me. > @@ -2173,7 +2195,9 @@ static int __pidfd_prepare(struct pid *pid, unsigned int flags, struct file **re > */ > int pidfd_prepare(struct pid *pid, unsigned int flags, struct file **ret) > { > - if (!pid || !pid_has_task(pid, PIDTYPE_TGID)) > + bool thread = flags & PIDFD_THREAD; > + > + if (!pid || !pid_has_task(pid, thread ? PIDTYPE_PID : PIDTYPE_TGID)); Small typo here, trailing ;. When I fix that, tests pass for me. Assuming that's fixed up: Reviewed-by: Tycho Andersen Tested-by: Tycho Andersen Thanks for your help! Tycho