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.