Re: [RFC PATCH v6 16/26] signal: Support userland fds in pidfd_send_signal()

From: bot+bpf-ci

Date: Sat Nov 21 2026 - 21:13:53 EST


> signal: Support userland fds in pidfd_send_signal()

TL;DR: userland_send_signal() may miss a child forked by a parent outside the
userland's PID namespace (e.g. after setns()), so a broadcast SIGSTOP/SIGTERM
could skip it; otherwise the commit message needs narrowing.

> diff --git a/kernel/userland.c b/kernel/userland.c
> --- a/kernel/userland.c
> +++ b/kernel/userland.c

[ ... ]

> +int userland_send_signal(struct file *file, int sig,
> + struct siginfo __user *info, unsigned int flags)
> +{

[ ... ]

> + scoped_guard(rcu) {
> + read_lock(&tasklist_lock);
> + idr_for_each_entry(&pid_ns->idr, pid, nr) {
> + struct task_struct *task = pid_task(pid, PIDTYPE_TGID);
> + int err;
> +
> + if (!task)
> + continue;
> +
> + err = group_send_sig_info(sig, SEND_SIG_NOINFO, task,
> + PIDTYPE_MAX);

The commit message says the signal is delivered "once to each thread group
including in-flight forks". Does that hold when the forking parent is not
a member of the userland's PID namespace?

The delayed multiprocess signal handling only reaches a child if the parent
itself is in pid_ns->idr, so that group_send_sig_info(..., PIDTYPE_MAX)
hits the parent. A parent outside the userland can still create a member
process, for example by calling setns() on the PID nsfd from
USERLAND_GET_NSFD(CLONE_NEWPID) and then fork(). A later patch in this
series, "fork: Support CLONE_INTO_USERLAND in clone3()", also lets
subsequent callers join the running PID namespace.

In that case:

parent P (outside pid_ns) userland_send_signal()
copy_process()
alloc_pid() -> idr_replace()
child pid now in pid_ns->idr
read_lock(&tasklist_lock)
idr walk: pid_task(child, TGID) == NULL
-> continue (skipped)
P is not in pid_ns->idr, so it is
never signalled
read_unlock(&tasklist_lock); return 0
write_lock_irq(&tasklist_lock)
fatal_signal_pending(P) == false
attach_pid(p, PIDTYPE_TGID)
child runs without the signal

The comment in copy_process() already notes "If current is not in the same
namespace, we can't rely on fatal_signal_pending() below", and only the
zap_pid_ns_processes() case is covered through the PIDNS_ADDING check.

Can a SIGSTOP, SIGTERM or SIGHUP broadcast miss a process that is being
spawned or exec'd into the userland at the same moment? Should the walk
cover these entrants, or should the commit message and the DOC comment be
narrowed to forks by member processes?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/44972669664