From: sashiko-bot@kernel.org
To: "Jarkko Sakkinen" <jarkko@kernel.org>
Cc: linux-mm@kvack.org, linux-security-module@vger.kernel.org,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Ben Segall" <bsegall@google.com>,
"Christian Brauner" <brauner@kernel.org>,
"David Hildenbrand" <david@kernel.org>,
"David Howells" <dhowells@redhat.com>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
"Ingo Molnar" <mingo@redhat.com>, "Jan Kara" <jack@suse.cz>,
"Jonathan Corbet" <corbet@lwn.net>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Kees Cook" <kees@kernel.org>,
"K Prateek Nayak" <kprateek.nayak@amd.com>,
"Liam R. Howlett" <liam@infradead.org>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Manfred Spraul" <manfred@colorfullife.com>,
"Mel Gorman" <mgorman@suse.de>, "Michal Hocko" <mhocko@suse.com>,
"Mike Rapoport" <rppt@kernel.org>, "Neal Gompa" <neal@gompa.dev>,
"Paul Moore" <paul@paul-moore.com>,
"Pavel Tikhomirov" <ptikhomirov@virtuozzo.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Serge Hallyn" <sergeh@kernel.org>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Valentin Schneider" <vschneid@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Vlastimil Babka" <vbabka@kernel.org>
Subject: Re: [RFC PATCH 06/13] rootns: Add rootns_kill() system call
Date: Wed, 18 Nov 2026 05:09:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-220141@kernel.org> (raw)
In-Reply-To: <20261117050841.3289652-7-jarkko@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] rootns: fork() race in rootns_kill_members() missing
tasklist_lock
- [High] rootns: missing PID namespace ancestry check in
rootns_kill_members()
--
commit af3e55bb2ee92ebb14699cd9c72b34e3ddb26ffe
Author: Jarkko Sakkinen <jarkko@kernel.org>
rootns: Add rootns_kill() system call
This commit adds the rootns_kill() system call to walk a root namespace's
PID namespace IDR and send a signal to every member thread group.
> diff --git a/kernel/rootns.c b/kernel/rootns.c
> index 8a1254db69df7..f59b2fe9910de 100644
> --- a/kernel/rootns.c
> +++ b/kernel/rootns.c
[ ... ]
> @@ -390,3 +391,67 @@ COMPAT_SYSCALL_DEFINE4(rootns_wait, int, rootnsfd,
> return ret;
> }
> #endif
> +
> +static int rootns_kill_members(struct rootns *rootns, int sig)
> +{
> + struct pid_namespace *pid_ns = rootns->ns->pid_ns_for_children;
[Severity: High]
Should rootns_kill_members() verify that the caller's active PID namespace
is equal to or an ancestor of pid_ns before delivering signals?
Without an ancestry check, a caller holding rootnsfd in a sibling or
descendant PID namespace can signal processes outside its PID namespace
hierarchy. Because kill_pid() passes SEND_SIG_NOINFO to
send_signal_locked():
kernel/signal.c:send_signal_locked() {
...
if (info == SEND_SIG_NOINFO) {
/* Force if sent from an ancestor pid namespace */
force = !task_pid_nr_ns(current, task_active_pid_ns(t));
}
...
}
when current has no PID in task_active_pid_ns(t), send_signal_locked()
treats the signal as coming from an ancestor PID namespace and sets
force = true, bypassing SIGNAL_UNKILLABLE and allowing SIGKILL or SIGSTOP
to kill or stop the PID namespace init process.
> + bool any_success = false;
> + bool any_other = false;
> + bool any_perm = false;
> + int other_err = 0;
> + struct pid *pid;
> + int nr;
> +
> + if (READ_ONCE(rootns->state) != ROOTNS_RUNNING)
> + return -ESRCH;
> +
> + scoped_guard(rcu) {
> + idr_for_each_entry(&pid_ns->idr, pid, nr) {
> + int err;
> +
> + if (!pid_task(pid, PIDTYPE_TGID))
> + continue;
> +
> + err = kill_pid(pid, sig, 0);
[Severity: High]
Can a concurrent fork() still escape signals sent by rootns_kill_members()?
CPU0 CPU1
copy_process()
hlist_add_head(&delayed.node,
¤t->signal->multiprocess)
...
pid = alloc_pid(...)
rootns_kill_members()
idr_for_each_entry(&pid_ns->idr, ...)
/* parent: kill_pid() uses
* PIDTYPE_TGID, so delayed.signal
* is not updated */
kill_pid(parent_pid, SIGTERM, 0)
/* child: not attached yet */
!pid_task(child_pid, PIDTYPE_TGID)
-> continue
write_lock_irq(&tasklist_lock)
p->signal->shared_pending.signal =
delayed.signal
attach_pid(p, PIDTYPE_TGID)
attach_pid(p, PIDTYPE_PID)
write_unlock_irq(&tasklist_lock)
/* child escapes SIGTERM */
__send_signal_locked() only records signals in t->signal->multiprocess for
in-flight forks when type > PIDTYPE_TGID, whereas kill_pid() passes
PIDTYPE_TGID. In addition, because pid_ns->idr is walked without holding
read_lock(&tasklist_lock), a parent at a higher IDR entry can fork and
attach a child at a lower, already-scanned IDR entry (via PID wrap-around
or clone3() set_tid) before the scan reaches the parent, allowing the child
to escape even SIGKILL, or rootns_kill_members() can observe
pid_task(pid, PIDTYPE_TGID) before attach_pid(p, PIDTYPE_PID) completes and
get -ESRCH from kill_pid().
Holding read_lock(&tasklist_lock) during the IDR walk and signaling via
group_send_sig_info(sig, SEND_SIG_NOINFO, task, PIDTYPE_MAX), as
zap_pid_ns_processes() and kill(-1, sig) do, would close these races.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117050841.3289652-1-jarkko@kernel.org?part=6
next prev parent reply other threads:[~2026-11-18 5:09 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 5:08 [RFC PATCH 00/13] Namespace for namespace roots Jarkko Sakkinen
2026-11-17 5:08 ` [RFC PATCH 01/13] nsproxy: Pass nsproxy to create_new_namespaces() Jarkko Sakkinen
2026-11-18 5:09 ` sashiko-bot
2026-11-17 5:08 ` [RFC PATCH 02/13] rootns: Add core infrastructure for root namespaces Jarkko Sakkinen
2026-11-18 5:09 ` sashiko-bot
2026-11-17 5:08 ` [RFC PATCH 03/13] rootns: Track init lifecycle via copy_process() and pid_namespace Jarkko Sakkinen
2026-11-18 5:09 ` sashiko-bot
2026-11-17 5:08 ` [RFC PATCH 04/13] rootns: Add rootns_create() system call Jarkko Sakkinen
2026-11-18 5:09 ` sashiko-bot
2026-11-17 5:08 ` [RFC PATCH 05/13] rootns: Add rootns_wait() " Jarkko Sakkinen
2026-11-18 5:09 ` sashiko-bot
2026-11-17 5:08 ` [RFC PATCH 06/13] rootns: Add rootns_kill() " Jarkko Sakkinen
2026-11-18 5:09 ` sashiko-bot [this message]
2026-11-17 5:08 ` [RFC PATCH 07/13] rootns: Add rootns_enter() " Jarkko Sakkinen
2026-11-17 17:42 ` Andy Lutomirski
2026-11-17 20:03 ` Jarkko Sakkinen
2026-11-17 20:53 ` Andy Lutomirski
2026-11-18 5:09 ` sashiko-bot
2026-11-17 5:08 ` [RFC PATCH 08/13] fs: Support FSCONFIG_SET_ROOTNS in fsconfig() Jarkko Sakkinen
2026-11-18 5:09 ` sashiko-bot
2026-11-17 5:08 ` [RFC PATCH 09/13] fs: Support installing rootns mount trees via move_mount() Jarkko Sakkinen
2026-11-18 5:09 ` sashiko-bot
2026-11-17 5:08 ` [RFC PATCH 10/13] arch: Wire up rootns system calls Jarkko Sakkinen
2026-11-18 5:09 ` sashiko-bot
2026-11-17 5:08 ` [RFC PATCH 11/13] docs: Document root namespace uAPI Jarkko Sakkinen
2026-11-18 5:09 ` sashiko-bot
2026-11-17 5:08 ` [RFC PATCH 12/13] selftests/rootns: Add root namespace test suite Jarkko Sakkinen
2026-11-18 5:09 ` sashiko-bot
2026-11-17 5:08 ` [RFC PATCH 13/13] MAINTAINERS: Add entry for ROOT NAMESPACE Jarkko Sakkinen
2026-11-17 11:10 ` [RFC PATCH 00/13] Namespace for namespace roots Jarkko Sakkinen
2026-11-17 17:44 ` Andy Lutomirski
2026-11-17 18:48 ` Jarkko Sakkinen
2026-11-17 19:10 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-220141@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=bsegall@google.com \
--cc=corbet@lwn.net \
--cc=dave@stgolabs.net \
--cc=david@kernel.org \
--cc=dhowells@redhat.com \
--cc=dietmar.eggemann@arm.com \
--cc=jack@suse.cz \
--cc=jarkko@kernel.org \
--cc=juri.lelli@redhat.com \
--cc=kees@kernel.org \
--cc=kprateek.nayak@amd.com \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=linux-security-module@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=manfred@colorfullife.com \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=neal@gompa.dev \
--cc=paul@paul-moore.com \
--cc=peterz@infradead.org \
--cc=ptikhomirov@virtuozzo.com \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sergeh@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=viro@zeniv.linux.org.uk \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox