[PATCH 1/2] src/vfs: probe O_TMPFILE support on the base mount in the idmapped tests

Christian Brauner <[email protected]>
Newsgroups org.kernel.vger.fstests,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-unionfs
Message-ID <[email protected]>
openat_tmpfile_supported() in the idmapped mount tests probes O_TMPFILE
on the idmapped mount (open_tree_fd) as the test's fsuid -- but that
fsuid is not mapped by the idmapped mount under test, so it really asks
"can this unmapped caller create a tmpfile through this idmap?" instead
of "does the filesystem support O_TMPFILE?".

On overlayfs this is a false negative: the backing tmpfile ends up owned
by an unmapped id, overlayfs opens it with O_NOATIME and may_open()
returns -EPERM, so the tmpfile sub-tests are wrongly skipped.

O_TMPFILE support is a property of the filesystem, not of the idmapped
mount or the caller's mapping. Probe info->t_dir1_fd, the base mount
that the caller owns, exactly as the non-idmapped setgid tests already
do. The probe then succeeds on every filesystem and the tmpfile
sub-tests run as the mapped fsuid.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 src/vfs/idmapped-mounts.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/vfs/idmapped-mounts.c b/src/vfs/idmapped-mounts.c
index ed9992f9..8f8441c9 100644
--- a/src/vfs/idmapped-mounts.c
+++ b/src/vfs/idmapped-mounts.c
@@ -3838,7 +3838,7 @@ int tcore_setgid_create_idmapped(const struct vfstest_info *info)
 		goto out;
 	}
 
-	supported = openat_tmpfile_supported(open_tree_fd);
+	supported = openat_tmpfile_supported(info->t_dir1_fd);
 
 	pid = fork();
 	if (pid < 0) {
@@ -4014,7 +4014,7 @@ int tcore_setgid_create_idmapped_in_userns(const struct vfstest_info *info)
 		goto out;
 	}
 
-	supported = openat_tmpfile_supported(open_tree_fd);
+	supported = openat_tmpfile_supported(info->t_dir1_fd);
 
 	pid = fork();
 	if (pid < 0) {
@@ -7733,7 +7733,7 @@ static int setgid_create_umask_idmapped(const struct vfstest_info *info)
 		goto out;
 	}
 
-	supported = openat_tmpfile_supported(open_tree_fd);
+	supported = openat_tmpfile_supported(info->t_dir1_fd);
 
 	pid = fork();
 	if (pid < 0) {
@@ -7947,7 +7947,7 @@ static int setgid_create_umask_idmapped_in_userns(const struct vfstest_info *inf
 		goto out;
 	}
 
-	supported = openat_tmpfile_supported(open_tree_fd);
+	supported = openat_tmpfile_supported(info->t_dir1_fd);
 
 	/*
 	 * Below we verify that setgid inheritance for a newly created file or
@@ -8181,7 +8181,7 @@ static int setgid_create_acl_idmapped(const struct vfstest_info *info)
 		goto out;
 	}
 
-	supported = openat_tmpfile_supported(open_tree_fd);
+	supported = openat_tmpfile_supported(info->t_dir1_fd);
 
 	pid = fork();
 	if (pid < 0) {
@@ -8536,7 +8536,7 @@ static int setgid_create_acl_idmapped_in_userns(const struct vfstest_info *info)
 		goto out;
 	}
 
-	supported = openat_tmpfile_supported(open_tree_fd);
+	supported = openat_tmpfile_supported(info->t_dir1_fd);
 
 	/*
 	 * Below we verify that setgid inheritance for a newly created file or

-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.