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

Qu Wenruo <[email protected]>
Newsgroups org.kernel.vger.fstests,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-unionfs
Message-ID <[email protected]>

在 2026/8/13 01:26, Zorro Lang 写道:
> On Mon, Jul 20, 2026 at 06:15:31PM +0930, Qu Wenruo wrote:
>>
>>
>> 在 2026/6/16 01:03, Christian Brauner 写道:
>>> 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]>
>>
>> Reviewed-by: Qu Wenruo <[email protected]>
>>
>> Furthermore, since kernel commit 539dce114465 ("fs: refuse O_TMPFILE
>> creation with an unmapped fsuid or fsgid"), even without overlayfs the
>> 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.
> 
> Hi Wenruo,
> 
> Before merging this patch, I've merged your:
>    commit 1cca2bc0d7a9462bb1b59edb108bac7c9e7c424d
>    Author: Qu Wenruo <[email protected]>
>    Date:   Fri Jul 17 16:37:17 2026 +0930
> 
>        fstests: vfstest: skip rejected tmpfile creation
> 
> Since (Christian's) patch seems to replace yours (I think), so do you mind
> if I revert your patch and merge this one instead?

Yes, please. That's exactly what I expect.

Thanks,
Qu

> 
> Thanks,
> Zorro
> 
>>
>> Thanks,
>> Qu
>>
>>> ---
>>>    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
>>>
>>
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.