Patches to update xfs test "generic/645" for mount_setattr
Subsystems (2)
cover Patches to update xfs test "generic/645" for mount_setattr
The following patches fix the "generic/645" xfs test which was affected by the mount_setattr change in kernel commit dacfd001eaf2 (“fs/mnt_idmapping.c: Return -EINVAL when no map is written”).
---
Taylor Jackson (2):
vfs/idmapped_mounts.c: Incorrect array index for nested user ns vfs/idmapped_mounts.c: Change mount_setattr expected output
src/vfs/idmapped-mounts.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
---
base-commit: 9b6df9a01ac8ee3f28a2a24d71e45792e21b6d48
change-id: 20240326-mount-setattr-test-90942470c820
Best regards,
Signature · 1 line
Taylor Jackson <[email protected]>
PATCH 1/2 vfs/idmapped_mounts.c: Incorrect array index for nested user ns
Within the vfs test for idmapped mounts, the function nested_userns() is using an incorrect array index when attempting to set up the mapping for the 4th nested user ns within hierarchy[4]. The correct index that belongs to the 4th nested user ns is actually hierarchy[3]. And hierarchy[4] is reserved for the dummy entry that marks the end of the array.
--- src/vfs/idmapped-mounts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/vfs/idmapped-mounts.c +1 -1
@@ -6556,7 +6556,7 @@ static int nested_userns(const struct vfstest_info *info) }/* Don't write a mapping in the 4th userns. */ -list_empty (&hierarchy[4 ].id_map); +list_empty (&hierarchy[3 ].id_map);/* Create the actual userns hierarchy. */ ret =create_userns_hierarchy (hierarchy);
Signature · 1 line
2.34.1
Re: [PATCH 1/2] vfs/idmapped_mounts.c: Incorrect array index for nested user ns
Quoted 11 lines · On Tue, Mar 26, 2024 at 08:33:51PM +0000, Taylor Jackson via B4 Relay wrote:
From: Taylor Jackson <[email protected]>
Within the vfs test for idmapped mounts, the function
nested_userns()is using an incorrect array index when attempting to set up the mapping for the 4th nested user ns within hierarchy[4]. The correct index that belongs to the 4th nested user ns is actually hierarchy[3]. And hierarchy[4] is reserved for the dummy entry that marks the end of the array.Signed-off-by Taylor Jackson <[email protected]>---
Ah, thanks for fixing this!
PATCH 2/2 vfs/idmapped_mounts.c: Change mount_setattr expected output
In reply to Taylor JacksonIn kernel commit dacfd001eaf2 (“fs/mnt_idmapping.c: Return -EINVAL when no map is written”), the behavior of mount_setattr changed to return EINVAL when attempting to create an idmapped mount when using a user namespace with no mappings. The following commit updates the test to expect no mount to be created in that case. And since no mount is created, this commit also removes the check for overflow IDs because it does not make sense to check for overflow IDs for a mount that was not created.
--- src/vfs/idmapped-mounts.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
src/vfs/idmapped-mounts.c +1 -6
@@ -6667,7 +6667,7 @@ static int nested_userns(const struct vfstest_info *info) }if (sys_mount_setattr (fd_open_tree_level4,"" ,AT_EMPTY_PATH , - &attr_level4,sizeof (attr_level4))) { + &attr_level4,sizeof (attr_level4)) !=-1 || errno !=EINVAL ) {log_stderr ("failure: sys_mount_setattr" ); goto out; }
@@ -6706,11 +6706,6 @@ static int nested_userns(const struct vfstest_info *info)log_stderr ("failure: check ownership %s" , file); goto out; } - -if (!expected_uid_gid (fd_open_tree_level4, file,0 , info->t_overflowuid, info->t_overflowgid)) { -log_stderr ("failure: check ownership %s" , file); - goto out; - } }/* Verify that ownership looks correct for callers in the first userns. */
Signature · 1 line
2.34.1
Re: [PATCH 2/2] vfs/idmapped_mounts.c: Change mount_setattr expected output
Quoted 10 lines · On Tue, Mar 26, 2024 at 08:33:52PM +0000, Taylor Jackson via B4 Relay wrote:
From: Taylor Jackson <[email protected]>
In kernel commit
dacfd001eaf2(“fs/mnt_idmapping.c: Return-EINVALwhen no map is written”), the behavior ofmount_setattrchanged to return EINVAL when attempting to create an idmapped mount when using a user namespace with no mappings. The following commit updates the test to expect no mount to be created in that case. And since no mount is created, this commit also removes the check for overflow IDs because it does not make sense to check for overflow IDs for a mount that was not created.
Quoted 2 lines
Signed-off-by Taylor Jackson <[email protected]>---
Thanks for fixing this!
Quoted 33 lines
src/vfs/idmapped-mounts.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)src/vfs/idmapped-mounts.c +1
-6@@ -6667,7 +6667,7 @@ static int nested_userns(const struct vfstest_info *info) }if (sys_mount_setattr (fd_open_tree_level4,"" ,AT_EMPTY_PATH , - &attr_level4,sizeof (attr_level4))) { + &attr_level4,sizeof (attr_level4)) !=-1 || errno !=EINVAL ) {log_stderr ("failure: sys_mount_setattr" ); goto out; }@@ -6706,11 +6706,6 @@ static int nested_userns(const struct vfstest_info *info)log_stderr ("failure: check ownership %s" , file); goto out; } - -if (!expected_uid_gid (fd_open_tree_level4, file,0 , info->t_overflowuid, info->t_overflowgid)) { -log_stderr ("failure: check ownership %s" , file); - goto out; - } }/* Verify that ownership looks correct for callers in the first userns. */ Signature · 2 lines
-- 2.34.1
Quoted 19 lines · Darrick J. Wong
Quoted 18 lines · Christian Brauner
Quoted 16 lines · Darrick J. Wong
Quoted 5 lines · Christian Brauner
Quoted 4 lines · kernel test robot
Hello,
Quoted 7 lines
Quoted 4 lines
kernel test robot noticed "xfstests.generic.645.fail" on:
commit:
b4291c7fd9e550b91b10c3d7787b9bf5be38de67("fs/mnt_idmapping.c: Return-EINVALwhen no map is written")
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git masterThe test needs to be updated. We now explicitly fail when no map is written.
Has there been any progress on updating generic/645? 6.9-rc1 is out, and Dave and I have both noticed this regressing.
Quoted 6 lines
Quoted 3 lines
Iirc, Taylor wanted to fix this but it seems that hasn't happened yet. I'll ping again and if nothing's happened until tomorrow I'll send a patch.
Ok, glad to hear that this is still on your radar. Thank you for following up!
@Darrick, Taylor sent fixes for this now (I've took the liberty to respond to both mails combined.).
Re: [PATCH 2/2] vfs/idmapped_mounts.c: Change mount_setattr expected output
In reply to Taylor JacksonQuoted 10 lines · On Tue, Mar 26, 2024 at 08:33:52PM +0000, Taylor Jackson via B4 Relay wrote:
From: Taylor Jackson <[email protected]>
In kernel commit
dacfd001eaf2(“fs/mnt_idmapping.c: Return-EINVALwhen no map is written”), the behavior ofmount_setattrchanged to return EINVAL when attempting to create an idmapped mount when using a user namespace with no mappings. The following commit updates the test to expect no mount to be created in that case. And since no mount is created, this commit also removes the check for overflow IDs because it does not make sense to check for overflow IDs for a mount that was not created.
Quoted 2 lines
Signed-off-by Taylor Jackson <[email protected]>---
Thanks for fixing it!
Quoted 34 lines
src/vfs/idmapped-mounts.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)src/vfs/idmapped-mounts.c +1
-6@@ -6667,7 +6667,7 @@ static int nested_userns(const struct vfstest_info *info) }if (sys_mount_setattr (fd_open_tree_level4,"" ,AT_EMPTY_PATH , - &attr_level4,sizeof (attr_level4))) { + &attr_level4,sizeof (attr_level4)) !=-1 || errno !=EINVAL ) {log_stderr ("failure: sys_mount_setattr" ); goto out; }@@ -6706,11 +6706,6 @@ static int nested_userns(const struct vfstest_info *info)log_stderr ("failure: check ownership %s" , file); goto out; } - -if (!expected_uid_gid (fd_open_tree_level4, file,0 , info->t_overflowuid, info->t_overflowgid)) { -log_stderr ("failure: check ownership %s" , file); - goto out; - } }/* Verify that ownership looks correct for callers in the first userns. */ Signature · 2 lines
-- 2.34.1
Re: [PATCH 2/2] vfs/idmapped_mounts.c: Change mount_setattr expected output
In reply to Taylor JacksonQuoted 20 lines · On Tue, Mar 26, 2024 at 08:33:52PM +0000, Taylor Jackson via B4 Relay wrote:
From: Taylor Jackson <[email protected]>
In kernel commit
dacfd001eaf2(“fs/mnt_idmapping.c: Return-EINVALwhen no map is written”), the behavior ofmount_setattrchanged to return EINVAL when attempting to create an idmapped mount when using a user namespace with no mappings. The following commit updates the test to expect no mount to be created in that case. And since no mount is created, this commit also removes the check for overflow IDs because it does not make sense to check for overflow IDs for a mount that was not created.Signed-off-by Taylor Jackson <[email protected]>--- src/vfs/idmapped-mounts.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)src/vfs/idmapped-mounts.c +0
-0
src/vfs/idmapped-mounts.c static int nested_userns(const struct vfstest_info *info) · line 6670
Quoted 5 lines
src/vfs/idmapped-mounts.c +1
-1@@ -6667,7 +6667,7 @@ static int nested_userns(const struct vfstest_info *info) }if (sys_mount_setattr (fd_open_tree_level4,"" ,AT_EMPTY_PATH , - &attr_level4,sizeof (attr_level4))) { + &attr_level4,sizeof (attr_level4)) !=-1 || errno !=EINVAL ) {
Hi Taylor,
This patch has been merged, but I found it causes g/645 fail on old kernel[1]. Is it expected?
If it's an expected failure on kernel without dacfd001eaf2 (“fs/mnt_idmapping.c:
Return -EINVAL when no map is written”), we'd better to add this commit to generic/645 as a hint, to avoid others feel they hit a regression.
Thanks,
Zorro
[1]
FSTYP -- xfs (non-debug) PLATFORM -- Linux/x86_64 sheep-3 5.14.0-xxx.el9 #1 SMP PREEMPT_DYNAMIC Fri Apr 5 12:21:04 EDT 2024 MKFS_OPTIONS -- -f -m crc=1,finobt=1,reflink=1,rmapbt=0,bigtime=1,inobtcount=1 /dev/vda3
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/vda3 /mnt/xfstests/scratch
generic/645 [failed, exit status 1]- output mismatch (see /var/lib/xfstests/results//generic/645.out.bad)
--- tests/generic/645.out 2024-04-08 07:27:51.432955372 +0200
+++ /var/lib/xfstests/results//generic/645.out.bad 2024-04-08 07:31:49.811581285 +0200
@@ -1,2 +1,4 @@
QA output created by 645
Silence is golden
+idmapped-mounts.c: 6671: nested_userns - Success - failure: sys_mount_setattr
+vfstest.c: 2418: run_test - Success - failure: test that nested user namespaces behave correctly when attached to idmapped mounts
...
(Run 'diff -u /var/lib/xfstests/tests/generic/645.out /var/lib/xfstests/results//generic/645.out.bad' to see the entire diff)
Ran: generic/645
Failures: generic/645
Failed 1 of 1 tests
Quoted 21 lines
src/vfs/idmapped-mounts.c +0
-5log_stderr ("failure: sys_mount_setattr" ); goto out; }@@ -6706,11 +6706,6 @@ static int nested_userns(const struct vfstest_info *info)log_stderr ("failure: check ownership %s" , file); goto out; } - -if (!expected_uid_gid (fd_open_tree_level4, file,0 , info->t_overflowuid, info->t_overflowgid)) { -log_stderr ("failure: check ownership %s" , file); - goto out; - } }/* Verify that ownership looks correct for callers in the first userns. */ Signature · 2 lines
-- 2.34.1