* [PATCH 1/2] selftests/filesystems/openat2: fix O_LARGEFILE definitions for non-arm64 architectures
@ 2026-09-17 9:57 Disha Goel
2026-09-17 9:57 ` [PATCH 2/2] selftests/filesystems/openat2: make /tmp a mountpoint inside private namespace Disha Goel
2026-09-25 11:02 ` [PATCH 1/2] selftests/filesystems/openat2: fix O_LARGEFILE definitions for non-arm64 architectures Christian Brauner
0 siblings, 2 replies; 4+ messages in thread
From: Disha Goel @ 2026-09-17 9:57 UTC (permalink / raw)
To: shuah; +Cc: aleksa, brauner, linux-kselftest, linux-kernel, Disha Goel
The openat2_test.c code previously hardcoded O_LARGEFILE to 0x8000 on
all architectures other than arm64 (aarch64).
However, on several architectures this value is different. For example,
on PowerPC (including ppc64le), O_LARGEFILE is defined as 0x10000,
whereas 0x8000 is actually O_NOFOLLOW.
This mismatch caused the flag_validation test case to pass
O_PATH | O_NOFOLLOW instead of O_PATH | O_LARGEFILE. Since
O_PATH | O_NOFOLLOW is a valid and compatible flag combination, the
kernel successfully opened the file instead of failing with -EINVAL,
causing a false test failure on PowerPC.
Fix this by introducing proper architecture-specific definitions for
O_LARGEFILE matching their respective UAPI asm/fcntl.h values.
Signed-off-by: Disha Goel <disgoel@linux.ibm.com>
---
.../selftests/filesystems/openat2/openat2_test.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/filesystems/openat2/openat2_test.c b/tools/testing/selftests/filesystems/openat2/openat2_test.c
index 6f5afbe2d8d3..e08c94ce0530 100644
--- a/tools/testing/selftests/filesystems/openat2/openat2_test.c
+++ b/tools/testing/selftests/filesystems/openat2/openat2_test.c
@@ -23,8 +23,16 @@
* XXX: This is wrong on {mips, parisc, powerpc, sparc}.
*/
#undef O_LARGEFILE
-#ifdef __aarch64__
+#if defined(__aarch64__) || defined(__alpha__)
#define O_LARGEFILE 0x20000
+#elif defined(__powerpc__) || defined(__ppc__)
+#define O_LARGEFILE 0x10000
+#elif defined(__sparc__)
+#define O_LARGEFILE 0x40000
+#elif defined(__mips__)
+#define O_LARGEFILE 0x2000
+#elif defined(__parisc__)
+#define O_LARGEFILE 0x800
#else
#define O_LARGEFILE 0x8000
#endif
--
2.45.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] selftests/filesystems/openat2: make /tmp a mountpoint inside private namespace
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
2026-09-24 6:39 ` andy_gao
2026-09-25 11:02 ` [PATCH 1/2] selftests/filesystems/openat2: fix O_LARGEFILE definitions for non-arm64 architectures Christian Brauner
1 sibling, 1 reply; 4+ messages in thread
From: Disha Goel @ 2026-09-17 9:57 UTC (permalink / raw)
To: shuah; +Cc: aleksa, brauner, linux-kselftest, linux-kernel, Disha Goel
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] selftests/filesystems/openat2: make /tmp a mountpoint inside private namespace
2026-09-17 9:57 ` [PATCH 2/2] selftests/filesystems/openat2: make /tmp a mountpoint inside private namespace Disha Goel
@ 2026-09-24 6:39 ` andy_gao
0 siblings, 0 replies; 4+ messages in thread
From: andy_gao @ 2026-09-24 6:39 UTC (permalink / raw)
To: Disha Goel
Cc: Shuah Khan, Aleksa Sarai, Christian Brauner, linux-kselftest,
linux-kernel
Hi Disha,
Tested patch 2/2 on 22 September 2026 on x86_64 with Linux 7.3-rc4,
using base commit
93f51579e7df248780214094418f205253383cc5.
Environment:
- QEMU 6.2.0 with TCG, 2 vCPUs and 2 GiB RAM, via virtme-ng 1.41.
- Guest kernel: 7.3.0-rc4-virtme; Ubuntu 22.04 userspace.
- GCC 11.4.0; resolve_test built with the upstream Makefile, retaining
-fsanitize=address -fsanitize=undefined and -static-libasan.
I ran the unmodified and patched resolve_test on the same guest kernel.
A temporary tmpfs-backed chroot in a private mount namespace provided
two /tmp layouts: an ordinary writable directory and a separate tmpfs
mount. /proc was mounted in the chroot and /dev/null was available.
Results for all five resolve_test harness tests:
/tmp layout Unmodified Patch 2/2 applied
ordinary directory 0 pass, 5 fail 5 pass, 0 fail
separate tmpfs mount 5 pass, 0 fail 5 pass, 0 fail
There were no skipped tests in any run. With an ordinary /tmp directory,
all five unmodified tests failed at the fixture setup assertion for
mount("", "/tmp", "", MS_PRIVATE, ""). With the patch, all five passed,
including resolve_no_xdev. The existing mountpoint layout also continued
to pass.
Only patch 2/2 was tested; this does not cover the architecture-specific
O_LARGEFILE changes in patch 1/2.
Tested-by: andy_gao <andy23320@yahoo.com>
Thanks,
andy_gao
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] selftests/filesystems/openat2: fix O_LARGEFILE definitions for non-arm64 architectures
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 ` [PATCH 2/2] selftests/filesystems/openat2: make /tmp a mountpoint inside private namespace Disha Goel
@ 2026-09-25 11:02 ` Christian Brauner
1 sibling, 0 replies; 4+ messages in thread
From: Christian Brauner @ 2026-09-25 11:02 UTC (permalink / raw)
To: shuah, Disha Goel
Cc: Christian Brauner, aleksa, linux-kselftest, linux-kernel
On Thu, 17 Sep 2026 15:27:05 +0530, Disha Goel wrote:
> The openat2_test.c code previously hardcoded O_LARGEFILE to 0x8000 on
> all architectures other than arm64 (aarch64).
>
> However, on several architectures this value is different. For example,
> on PowerPC (including ppc64le), O_LARGEFILE is defined as 0x10000,
> whereas 0x8000 is actually O_NOFOLLOW.
>
> [...]
Applied to the vfs-7.4.misc branch of the vfs/vfs.git tree.
Patches in the vfs-7.4.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.4.misc
[1/2] selftests/filesystems/openat2: fix O_LARGEFILE definitions for non-arm64 architectures
https://git.kernel.org/vfs/vfs/c/caddcdb829b2
[2/2] selftests/filesystems/openat2: make /tmp a mountpoint inside private namespace
https://git.kernel.org/vfs/vfs/c/26915b466490
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-25 11:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/2] selftests/filesystems/openat2: make /tmp a mountpoint inside private namespace Disha Goel
2026-09-24 6:39 ` andy_gao
2026-09-25 11:02 ` [PATCH 1/2] selftests/filesystems/openat2: fix O_LARGEFILE definitions for non-arm64 architectures Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox