Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1164033rdb; Fri, 1 Dec 2023 08:32:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGiN0jM2OcuYXLz1BQWgjzmJnYoxRG4RQjcfnlHbG8XWdfORFsL3std1yClT6gnl4gQP5iZ X-Received: by 2002:a05:6a20:160d:b0:138:2fb8:6c48 with SMTP id l13-20020a056a20160d00b001382fb86c48mr27509203pzj.8.1701448337900; Fri, 01 Dec 2023 08:32:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701448337; cv=none; d=google.com; s=arc-20160816; b=BGqhyufrIu++aovhmW/RcwPnKBPJfg9t3zps4kdVBWKhzj2YnOvhPzKyz0uyvw3HnX E0eatxYYZPqbzvv4gPu9yZrsUH3gJ9/8zcUzV1s7n0kIddpxT4KrBJsbLQErSPFe2ZNS g7pncbIFcpn1nN5/KXxIQeTfxRb4UDSx3b3Omsj/cOCuaG/ekUflv1D7pIUHmdqMdhjk Fd0sjIa4zO9WQSmThAT9lZBolcKzVxOoszCEJeoyr4Ybvx8ngjuHcYFtu/xqN9dm96II qwh+dppTt2pqUjrIVn+s69go56a2IJUeIaHyo8TGCnC6FFriH4t0diX2fkz7OTsQRAIn 870w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=C2Y0gaUdgFqndLTP/soczxZ/uabrIF0SdWstDCI27xM=; fh=ZvX2+2EYGrPDPrHIb4xscRuTqbfN9kJDE/+1r7/4tlY=; b=a8egATa/sHbQA/JJx7pxwOzrLU/CrPVhcvRDLyj7BxsEu8vfLhXm1Ta0LcTgnySJEC A8XGAiyUQzy54IWezhjBBHctBnLbzUMtj8kZHK+9bit/+qt+LxgU+3RuhVC2lZcJwYvc C64oQhr2aAke1uc+W+TUKeyMQ0eYpqiRgBVujw0fRgBqA5FDWnZZHJP6PNvQ1QzE2E3S Z40zjJusY6eFlqDGqGcJrSL2wprNTqqIcdTZJFIpLw4XXcDSGVH6YiSK9+aaMYnpvAS4 Bjko5wqa3kSa9p2YKXi4gkndEt9R2BrZwYJc5GX4Xw8OGa+6C+Y0/QRT3WL0vybIPJmN 1TyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm3 header.b=ICDRAV1H; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=kA9fc0Ix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id m3-20020a632603000000b0057d7cff25b8si3684220pgm.198.2023.12.01.08.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 08:32:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm3 header.b=ICDRAV1H; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=kA9fc0Ix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id EACFB81F84D4; Fri, 1 Dec 2023 08:32:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378258AbjLAQbl (ORCPT + 99 others); Fri, 1 Dec 2023 11:31:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbjLAQbj (ORCPT ); Fri, 1 Dec 2023 11:31:39 -0500 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF3B010E4; Fri, 1 Dec 2023 08:31:43 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id AC72B3200B4A; Fri, 1 Dec 2023 11:31:42 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 01 Dec 2023 11:31:43 -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:sender :subject:subject:to:to; s=fm3; t=1701448302; x=1701534702; bh=C2 Y0gaUdgFqndLTP/soczxZ/uabrIF0SdWstDCI27xM=; b=ICDRAV1H1ss/mZYIdG KoBPQ6QefiW04MDvPjpMOXEbld27B0s9t985tuF33RU/krZYXZT1/iH/7S9hBjtp tmxOGqdG+YFxH6fIFNSD4p40GbpiEOZIv36BFl/UOGYSNR4o0AzJV/o8TH5TNSWk EkffS9G3D0leip1R045pJUeNIyUM3mcV6bVGPF72+NynWjujIPtteRtuRtjZfAwV 2z5f2CMHNj9hNsLCkpf0K2J5NGATl+bKEetcCiYmkzwOt7pT7KdQ+khU0X1SHWVD JFUOPSCgCNJtetWjbir6cT6KN9ki12/CM/dW4liw3CU1ocJ1cum50fLntmdxuqlh nFBg== 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=1701448302; x=1701534702; bh=C2Y0gaUdgFqnd LTP/soczxZ/uabrIF0SdWstDCI27xM=; b=kA9fc0Ixhg2tmOPZe10MVIs+EwBvL P7pFYj28rJZ2C+Mve1gqmg3sNUzuVQJDK6t5T5GoRRUYicDYCpfrQWLC/2/dOpH2 PxrOfH6FQ3aggywD34jyA1+Ygu43Cu4ZOWHt39L3X//gWqVTn0dgilKfqPmGtwlo NTsCws4m3201VPuTo93yLmj4ZpUrXePImE0/gzxQ9KYLM5s0QMc5FplgGveu07zr NiOcjpDaSTSPjZlgaSaHNOBd4BcAogbhGRp+zJ7FqVU8xlUgIWvR1KwbZHHkbSZs vlJbh4JpTVEg1P+DTWkU259lD39Ovsdgcs8WUEtbn8OxqDukseh1x/Mtw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeiledgledtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepvfihtghh ohcutehnuggvrhhsvghnuceothihtghhohesthihtghhohdrphhiiiiirgeqnecuggftrf grthhtvghrnhepueettdetgfejfeffheffffekjeeuveeifeduleegjedutdefffetkeel hfelleetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epthihtghhohesthihtghhohdrphhiiiiirg X-ME-Proxy: Feedback-ID: i21f147d5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 1 Dec 2023 11:31:41 -0500 (EST) Date: Fri, 1 Dec 2023 09:31:40 -0700 From: Tycho Andersen To: Oleg Nesterov Cc: Christian Brauner , "Eric W . Biederman" , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Tycho Andersen Subject: Re: [RFC 1/3] pidfd: allow pidfd_open() on non-thread-group leaders Message-ID: References: <20231130163946.277502-1-tycho@tycho.pizza> <20231130173938.GA21808@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 01 Dec 2023 08:32:10 -0800 (PST) On Thu, Nov 30, 2023 at 10:57:01AM -0700, Tycho Andersen wrote: > On Thu, Nov 30, 2023 at 06:39:39PM +0100, Oleg Nesterov wrote: > > I think that wake_up_all(wait_pidfd) should have a single caller, > > do_notify_pidfd(). This probably means it should be shiftef from > > do_notify_parent() to exit_notify(), I am not sure... Indeed, below passes the tests without issue and is much less ugly. I'll respin with that later next week sometime. Thanks, Tycho diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 3499c1a8b929..04c4423ebed0 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -332,6 +332,7 @@ extern int kill_pid_usb_asyncio(int sig, int errno, sigval_t addr, struct pid *, extern int kill_pgrp(struct pid *pid, int sig, int priv); extern int kill_pid(struct pid *pid, int sig, int priv); extern __must_check bool do_notify_parent(struct task_struct *, int); +extern void do_notify_pidfd(struct task_struct *); extern void __wake_up_parent(struct task_struct *p, struct task_struct *parent); extern void force_sig(int); extern void force_fatal_sig(int); diff --git a/kernel/exit.c b/kernel/exit.c index 34eeefc7ee21..fd6048c20c48 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -769,6 +769,8 @@ static void exit_notify(struct task_struct *tsk, int group_dead) wake_up_process(tsk->signal->group_exec_task); write_unlock_irq(&tasklist_lock); + do_notify_pidfd(tsk); + list_for_each_entry_safe(p, n, &dead, ptrace_entry) { list_del_init(&p->ptrace_entry); release_task(p); diff --git a/kernel/signal.c b/kernel/signal.c index 47a7602dfe8d..7b3a1e147225 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2028,7 +2028,7 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type) return ret; } -static void do_notify_pidfd(struct task_struct *task) +void do_notify_pidfd(struct task_struct *task) { struct pid *pid; @@ -2060,9 +2060,6 @@ bool do_notify_parent(struct task_struct *tsk, int sig) WARN_ON_ONCE(!tsk->ptrace && (tsk->group_leader != tsk || !thread_group_empty(tsk))); - /* Wake up all pidfd waiters */ - do_notify_pidfd(tsk); - if (sig != SIGCHLD) { /* * This is only possible if parent == real_parent.