From: Disha Goel <disgoel@linux.ibm.com>
To: shuah@kernel.org
Cc: aleksa@amutable.com, brauner@kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Disha Goel <disgoel@linux.ibm.com>
Subject: [PATCH 2/2] selftests/filesystems/openat2: make /tmp a mountpoint inside private namespace
Date: Thu, 17 Sep 2026 15:27:06 +0530 [thread overview]
Message-ID: <20260917095707.16986-2-disgoel@linux.ibm.com> (raw)
In-Reply-To: <20260917095707.16986-1-disgoel@linux.ibm.com>
In resolve_test.c, the test unshares the mount namespace and attempts to
make /tmp private via:
mount("", "/tmp", "", MS_PRIVATE, "")
This fails with EINVAL on environments where /tmp is not already a
separate mount point (e.g. if /tmp is just a standard directory on the
root filesystem /). Furthermore, the resolve_no_xdev test relies on
crossing into /tmp to verify RESOLVE_NO_XDEV and trigger an -EXDEV
error. If /tmp is not a mount point, resolving /tmp never crosses a
mount boundary, leading to a test failure.
Fix this by:
1. Making the entire root directory recursively private (MS_PRIVATE |
MS_REC) after unsharing the mount namespace.
2. Performing a self-bind-mount of /tmp on /tmp inside the isolated
private mount namespace, which guarantees that /tmp is a separate
mount point and that resolving /tmp will cross a mount boundary as
expected by the test.
Signed-off-by: Disha Goel <disgoel@linux.ibm.com>
---
tools/testing/selftests/filesystems/openat2/resolve_test.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/filesystems/openat2/resolve_test.c b/tools/testing/selftests/filesystems/openat2/resolve_test.c
index eacde59ce158..6216a8546388 100644
--- a/tools/testing/selftests/filesystems/openat2/resolve_test.c
+++ b/tools/testing/selftests/filesystems/openat2/resolve_test.c
@@ -140,9 +140,12 @@ FIXTURE_SETUP(openat2_resolve)
if (!openat2_supported)
SKIP(return, "openat2(2) not supported");
- /* Unshare and make /tmp a new directory. */
+ /* Unshare and make the mount tree private. */
ASSERT_EQ(unshare(CLONE_NEWNS), 0);
- ASSERT_EQ(mount("", "/tmp", "", MS_PRIVATE, ""), 0);
+ ASSERT_EQ(mount("", "/", "", MS_PRIVATE | MS_REC, ""), 0);
+
+ /* Ensure /tmp is a mountpoint for RESOLVE_NO_XDEV test crossing into /tmp. */
+ ASSERT_EQ(mount("/tmp", "/tmp", NULL, MS_BIND, NULL), 0);
/* Make the top-level directory. */
ASSERT_NE(mkdtemp(dirname), NULL);
--
2.45.1
prev parent reply other threads:[~2026-09-17 9:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 9:57 [PATCH 1/2] selftests/filesystems/openat2: fix O_LARGEFILE definitions for non-arm64 architectures Disha Goel
2026-09-17 9:57 ` Disha Goel [this message]
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=20260917095707.16986-2-disgoel@linux.ibm.com \
--to=disgoel@linux.ibm.com \
--cc=aleksa@amutable.com \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
/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
all inboxes | Powered by JetHome®