From: sashiko-bot@kernel.org
To: "Jarkko Sakkinen" <jarkko@kernel.org>,
"David Howells" <dhowells@redhat.com>
Cc: linux-mm@kvack.org, linux-security-module@vger.kernel.org,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Andy Lutomirski" <luto@amacapital.net>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
"Ben Segall" <bsegall@google.com>,
"Christian Brauner" <brauner@kernel.org>,
"David Hildenbrand" <david@kernel.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>, "Jan Kara" <jack@suse.cz>,
"John Johansen" <john.johansen@canonical.com>,
"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>,
"Thomas Gleixner" <tglx@kernel.org>,
"Valentin Schneider" <vschneid@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Vincenzo Frascino" <vincenzo.frascino@arm.com>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Zygmunt Krynicki" <zygmunt.krynicki@canonical.com>
Subject: Re: [RFC PATCH v3 12/13] selftests/rootns: Add root namespace test suite
Date: Thu, 19 Nov 2026 19:37:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-223954@kernel.org> (raw)
In-Reply-To: <20261118193539.240065-13-jarkko@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] selftests/rootns: shared mount propagation in
move_mount_existing_mntns()
- [Medium] selftests/rootns: missing SKIP() on ENOSYS and silent skips
in child helpers
- [Low] selftests/rootns: stack direction and lifetime hazard in
clone_with_flags()
--
commit 101069d69b43912a16a7832bfad97b5398c581ce
Author: Jarkko Sakkinen <jarkko@kernel.org>
selftests/rootns: Add root namespace test suite
This commit adds a kselftest harness suite under
tools/testing/selftests/rootns to verify the root namespace and mount
namespace configuration uAPI and security invariants.
> diff --git a/tools/testing/selftests/rootns/smoke.c b/tools/testing/selftests/rootns/smoke.c
> new file mode 100644
> index 0000000000000..f0e3158ea4bec
> --- /dev/null
> +++ b/tools/testing/selftests/rootns/smoke.c
> @@ -0,0 +1,1934 @@
[ ... ]
> +static int clone_with_flags(int flags)
> +{
> + const size_t stack_size = 64 * 1024;
> + void *stack;
> + pid_t pid;
> + int status;
> + int ret;
> +
> + stack = malloc(stack_size);
> + if (!stack)
> + return -ENOMEM;
> +
> + pid = clone(clone_exit, (char *)stack + stack_size,
> + SIGCHLD | flags, NULL);
> + if (pid < 0)
> + ret = -errno;
> + else if (waitpid(pid, &status, 0) < 0)
> + ret = -errno;
> + else if (!WIFEXITED(status) || WEXITSTATUS(status))
> + ret = -EIO;
> + else
> + ret = 0;
> +
> + free(stack);
> + return ret;
> +}
[Severity: Low]
Can passing (char *)stack + stack_size to clone() write past the end of the
heap buffer on architectures where the stack grows upward, such as PA-RISC?
Also, if waitpid() fails (for example on EINTR), free(stack) runs while the
child may still be executing on that stack. Using sys_clone3() with stack = 0
and stack_size = 0 would avoid manual stack allocation and work regardless of
stack growth direction.
[ ... ]
> +FIXTURE_SETUP(rootns) {
> + self->cfd = create_test_rootns(false, ROOTNS_KILL_ON_CLOSE |
> + ROOTNS_CLOSE_ON_EXEC);
> + if (self->cfd < 0 && geteuid() != 0 &&
> + (errno == EPERM || errno == EACCES || errno == EINVAL ||
> + errno == ENOSPC || errno == EOVERFLOW))
> + SKIP(return, "pre-idmap submount setup requires mapped userns");
> + ASSERT_GE(self->cfd, 0);
> +}
[Severity: Medium]
Will this fail instead of skipping when CONFIG_ROOTNS is disabled (errno ==
ENOSYS) or when geteuid() == 0 hits EPERM, EACCES, or ENOSPC? Because rootns
is added unconditionally to TARGETS in tools/testing/selftests/Makefile while
CONFIG_ROOTNS defaults to n, running make run_tests on a kernel without
CONFIG_ROOTNS will fail all tests in this binary instead of skipping them.
The same issue applies to TEST(get_nsfd), while TEST_F(rootns, mount_perms)
omits -ENOSPC when checking the return value of create_rootns_as_uid(). In
addition, the forked child helpers in mount_perms, clone_perms, fsconfig, and
unpriv_no_userns call _exit(0) when unprivileged namespace creation fails
with EPERM, EACCES, EINVAL, or ENOSPC, causing the parent to report a silent
pass instead of a skip with a reason string (and unpriv_no_userns fails with
exit status 4 on ENOSYS).
[ ... ]
> +TEST_F(rootns, move_mount_existing_mntns) {
> + int ready_pipe[2];
> + int hold_pipe[2];
> + char path[64];
> + int marker_fd;
> + int mntns_fd;
> + char ch;
> + pid_t pid;
> + int fsfd;
> + int mfd;
> +
> + ASSERT_EQ(pipe2(ready_pipe, O_CLOEXEC), 0);
> + ASSERT_EQ(pipe2(hold_pipe, O_CLOEXEC), 0);
> +
> + pid = fork();
> + ASSERT_GE(pid, 0);
> + if (pid == 0) {
> + struct statfs st;
> +
> + close(self->cfd);
> + close(ready_pipe[0]);
> + close(hold_pipe[1]);
> +
> + if (unshare(CLONE_NEWNS) < 0)
> + _exit(1);
> + if (write(ready_pipe[1], "r", 1) != 1)
> + _exit(2);
> + close(ready_pipe[1]);
> +
> + if (read(hold_pipe[0], &ch, 1) != 1)
> + _exit(3);
> + close(hold_pipe[0]);
> +
> + if (statfs("/tmp", &st) < 0)
> + _exit(4);
> + if ((unsigned long)st.f_type != (unsigned long)TMPFS_MAGIC)
> + _exit(5);
> + if (access("/tmp/hot_mounted", F_OK) < 0)
> + _exit(6);
> + _exit(0);
> + }
> + close(ready_pipe[1]);
> + close(hold_pipe[0]);
> +
> + ASSERT_EQ(read(ready_pipe[0], &ch, 1), 1);
> + close(ready_pipe[0]);
> +
> + snprintf(path, sizeof(path), "/proc/%d/ns/mnt", (int)pid);
> + mntns_fd = open(path, O_RDONLY | O_CLOEXEC);
> + ASSERT_GE(mntns_fd, 0);
> +
> + fsfd = sys_fsopen("tmpfs", 0);
> + ASSERT_GE(fsfd, 0);
> + ASSERT_EQ(sys_fsconfig(fsfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0), 0);
> + mfd = sys_fsmount(fsfd, 0, 0);
> + close(fsfd);
> + ASSERT_GE(mfd, 0);
> +
> + marker_fd = openat(mfd, "hot_mounted",
> + O_CREAT | O_WRONLY | O_CLOEXEC, 0644);
> + ASSERT_GE(marker_fd, 0);
> + close(marker_fd);
> +
> + /* Existing mnt_ns already has "/", so "/" must fail with EBUSY. */
> + ASSERT_EQ(sys_move_mount(mfd, "", mntns_fd, "/",
> + MOVE_MOUNT_F_EMPTY_PATH |
> + MOVE_MOUNT_T_MNTNS), -1);
> + ASSERT_EQ(errno, EBUSY);
> +
> + /* Hot-mounting onto a relative path inside the live mnt_ns succeeds. */
> + ASSERT_EQ(sys_move_mount(mfd, "", mntns_fd, "tmp",
> + MOVE_MOUNT_F_EMPTY_PATH |
> + MOVE_MOUNT_T_MNTNS), 0);
[Severity: Medium]
Does sys_move_mount() here propagate the new tmpfs mount onto /tmp in the
host mount namespace?
Because the child calls unshare(CLONE_NEWNS) without unsharing a user
namespace or remounting "/" with MS_REC | MS_PRIVATE, its mounts stay in the
same shared peer group as the host mount namespace when "/" or "/tmp" is
mounted MS_SHARED (the default on systemd hosts). Attaching mfd onto "tmp"
in mntns_fd then propagates a peer tmpfs mount onto the host's /tmp that
remains mounted after the child and mntns_fd exit, hiding the host's /tmp
contents.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118193539.240065-1-jarkko@kernel.org?part=12
next prev parent reply other threads:[~2026-11-19 19:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 19:35 [RFC PATCH v3 00/13] Namespace for namespace roots Jarkko Sakkinen
2026-11-18 19:35 ` [RFC PATCH v3 01/13] nsproxy: Pass nsproxy to create_new_namespaces() Jarkko Sakkinen
2026-11-18 19:35 ` [RFC PATCH v3 02/13] rootns: Add core infrastructure for root namespaces Jarkko Sakkinen
2026-11-18 19:35 ` [RFC PATCH v3 03/13] rootns: Track init lifecycle via copy_process() and pid_namespace Jarkko Sakkinen
2026-11-18 19:35 ` [RFC PATCH v3 04/13] rootns: Add rootns_create() system call Jarkko Sakkinen
2026-11-18 19:35 ` [RFC PATCH v3 05/13] rootns: Add rootns_wait() " Jarkko Sakkinen
2026-11-19 19:36 ` sashiko-bot
2026-11-18 19:35 ` [RFC PATCH v3 06/13] rootns: Add rootns_kill() " Jarkko Sakkinen
2026-11-18 19:35 ` [RFC PATCH v3 07/13] fork: Support CLONE_INTO_ROOTNS in clone3() Jarkko Sakkinen
2026-11-19 19:36 ` sashiko-bot
2026-11-18 19:35 ` [RFC PATCH v3 08/13] fs: Support FSCONFIG_SET_ROOTNS in fsconfig() Jarkko Sakkinen
2026-11-19 19:36 ` sashiko-bot
2026-11-18 19:35 ` [RFC PATCH v3 09/13] fs: Support MOVE_MOUNT_T_MNTNS in move_mount() Jarkko Sakkinen
2026-11-19 19:36 ` sashiko-bot
2026-11-18 19:35 ` [RFC PATCH v3 10/13] arch: Wire up rootns system calls Jarkko Sakkinen
2026-11-18 19:35 ` [RFC PATCH v3 11/13] docs: Document root namespace uAPI Jarkko Sakkinen
2026-11-18 19:35 ` [RFC PATCH v3 12/13] selftests/rootns: Add root namespace test suite Jarkko Sakkinen
2026-11-19 19:37 ` sashiko-bot [this message]
2026-11-18 19:35 ` [RFC PATCH v3 13/13] MAINTAINERS: Add entry for ROOT NAMESPACE Jarkko Sakkinen
2026-11-18 19:54 ` [RFC PATCH v3 00/13] Namespace for namespace roots Jarkko Sakkinen
2026-11-18 20:42 ` Jarkko Sakkinen
2026-11-18 21:22 ` Jarkko Sakkinen
2026-11-19 4:43 ` Jarkko Sakkinen
2026-11-19 6:21 ` Jarkko Sakkinen
2026-11-18 22:36 ` Vlastimil Babka (SUSE)
2026-11-18 23:33 ` 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-223954@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anna-maria@linutronix.de \
--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=frederic@kernel.org \
--cc=jack@suse.cz \
--cc=jarkko@kernel.org \
--cc=john.johansen@canonical.com \
--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=luto@amacapital.net \
--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=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vincenzo.frascino@arm.com \
--cc=viro@zeniv.linux.org.uk \
--cc=vschneid@redhat.com \
--cc=zygmunt.krynicki@canonical.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