* [PATCH] selftests/filesystems: Fix idmapped_tmpfile layer dir ownership
@ 2026-10-01 8:24 Bjoern Doebel
0 siblings, 0 replies; only message in thread
From: Bjoern Doebel @ 2026-10-01 8:24 UTC (permalink / raw)
To: Christian Brauner, Shuah Khan
Cc: Jan Kara, linux-kselftest, linux-kernel, Bjoern Doebel, stable
The recent idmapped_tmpfile selftest creates a new directory in tmpfs
owned by user ID 0. It then idmaps the mount as caller [0,10000) to disk
[10000,20000). The original uid 0 owner does not exist in the mapped
range. As a result, mapped_caller_creates_and_links fails at the
O_TMPFILE open because inode_permission() rejects MAY_WRITE access:
idmapped_tmpfile.c:145:mapped_caller_creates_and_links:
Expected fd (-1) >= 0 (0)
Chown the directory into the mapped range to satisfy the UID
requirement.
Fixes: d943e68edc5cb ("selftests/filesystems: test O_TMPFILE creation on idmapped mounts")
Cc: stable@vger.kernel.org # 7.2+
Assisted-by: kiro:claude-opus-5
Signed-off-by: Bjoern Doebel <doebel@amazon.de>
---
tools/testing/selftests/filesystems/idmapped_tmpfile.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/testing/selftests/filesystems/idmapped_tmpfile.c b/tools/testing/selftests/filesystems/idmapped_tmpfile.c
index bc411ab8281ea..77b96d0943578 100644
--- a/tools/testing/selftests/filesystems/idmapped_tmpfile.c
+++ b/tools/testing/selftests/filesystems/idmapped_tmpfile.c
@@ -91,6 +91,13 @@ FIXTURE_SETUP(idmapped_tmpfile)
ASSERT_EQ(mkdir(self->dir, 0777), 0);
/* World-writable so an unmapped caller still passes permission(). */
ASSERT_EQ(chmod(self->dir, 0777), 0);
+ /*
+ * The directory itself must be inside the range the mount maps.
+ * Left owned by 0 it has no mapping in the mount, and
+ * inode_permission() then fails MAY_WRITE via HAS_UNMAPPED_ID()
+ * before any of the tmpfile logic is reached, regardless of mode.
+ */
+ ASSERT_EQ(chown(self->dir, MAP_HOST, MAP_HOST), 0);
}
FIXTURE_TEARDOWN(idmapped_tmpfile)
--
2.50.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-01 8:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01 8:24 [PATCH] selftests/filesystems: Fix idmapped_tmpfile layer dir ownership Bjoern Doebel
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®