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

Qu Wenruo <[email protected]> Mon, 20 Jul 2026 18:15:31 +0930
Newsgroups org.kernel.vger.linux-unionfs,org.kernel.vger.fstests,org.kernel.vger.linux-fsdevel
Message-ID <[email protected]>

=E5=9C=A8 2026/6/16 01:03, Christian Brauner =E5=86=99=E9=81=93:
> 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?".
>=20
> 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.
>=20
> 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.
>=20
> Signed-off-by: Christian Brauner (Amutable) <[email protected]>

Reviewed-by: Qu Wenruo <[email protected]>

Furthermore, since kernel commit 539dce114465 ("fs: refuse O_TMPFILE=20
creation with an unmapped fsuid or fsgid"), even without overlayfs the=20
involved tests will fail due to the extra checks.

So this is not only affecting overlayfs but all regular fses now.

I hope we can at least merge this one asap.

Thanks,
Qu

> ---
>   src/vfs/idmapped-mounts.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
>=20
> 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 vfst=
est_info *info)
>   		goto out;
>   	}
>  =20
> -	supported =3D openat_tmpfile_supported(open_tree_fd);
> +	supported =3D openat_tmpfile_supported(info->t_dir1_fd);
>  =20
>   	pid =3D fork();
>   	if (pid < 0) {
> @@ -4014,7 +4014,7 @@ int tcore_setgid_create_idmapped_in_userns(const s=
truct vfstest_info *info)
>   		goto out;
>   	}
>  =20
> -	supported =3D openat_tmpfile_supported(open_tree_fd);
> +	supported =3D openat_tmpfile_supported(info->t_dir1_fd);
>  =20
>   	pid =3D fork();
>   	if (pid < 0) {
> @@ -7733,7 +7733,7 @@ static int setgid_create_umask_idmapped(const stru=
ct vfstest_info *info)
>   		goto out;
>   	}
>  =20
> -	supported =3D openat_tmpfile_supported(open_tree_fd);
> +	supported =3D openat_tmpfile_supported(info->t_dir1_fd);
>  =20
>   	pid =3D fork();
>   	if (pid < 0) {
> @@ -7947,7 +7947,7 @@ static int setgid_create_umask_idmapped_in_userns(=
const struct vfstest_info *inf
>   		goto out;
>   	}
>  =20
> -	supported =3D openat_tmpfile_supported(open_tree_fd);
> +	supported =3D openat_tmpfile_supported(info->t_dir1_fd);
>  =20
>   	/*
>   	 * Below we verify that setgid inheritance for a newly created file o=
r
> @@ -8181,7 +8181,7 @@ static int setgid_create_acl_idmapped(const struct=
 vfstest_info *info)
>   		goto out;
>   	}
>  =20
> -	supported =3D openat_tmpfile_supported(open_tree_fd);
> +	supported =3D openat_tmpfile_supported(info->t_dir1_fd);
>  =20
>   	pid =3D fork();
>   	if (pid < 0) {
> @@ -8536,7 +8536,7 @@ static int setgid_create_acl_idmapped_in_userns(co=
nst struct vfstest_info *info)
>   		goto out;
>   	}
>  =20
> -	supported =3D openat_tmpfile_supported(open_tree_fd);
> +	supported =3D openat_tmpfile_supported(info->t_dir1_fd);
>  =20
>   	/*
>   	 * Below we verify that setgid inheritance for a newly created file o=
r
>=20