fstests: btrfs/314: fix the failure when SELinux is enabled
PATCH 1/1 fstests: btrfs/314: fix the failure when SELinux is enabled
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out
+++ results//btrfs/314.out.bad
@@ -17,5 +17,6 @@
At subvol TEST_DIR/314/tempfsid_mnt/snap1
Receive SCRATCH_MNT
At subvol snap1
+ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported
Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo
-Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo
+Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo
...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdb /mnt/scratch
See commit 3839d299 ("xfstests: mount xfs with a context when selinux is on")
fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tests/btrfs/314 +5 -1
@@ -21,6 +21,10 @@ _cleanup() . ./common/filter.btrfs +# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS= + _require_scratch_dev_pool 2 _require_btrfs_fs_feature temp_fsid
@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount ${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1
Signature · 1 line
2.48.1
Quoted 27 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out +++ results//btrfs/314.out.bad @@ -17,5 +17,6 @@ At subvol TEST_DIR/314/tempfsid_mnt/snap1 Receive SCRATCH_MNT At subvol snap1 +ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 4 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>
Thanks,
Qu
Quoted 28 lines
--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/btrfs/314 +5
-1@@ -21,6 +21,10 @@ _cleanup() . ./common/filter.btrfs +# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS= + _require_scratch_dev_pool 2 _require_btrfs_fs_feature temp_fsid@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount ${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1
Quoted 44 lines · Qu Wenruo
Quoted 27 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out
+++ results//btrfs/314.out.bad
@@ -17,5 +17,6 @@
At subvol TEST_DIR/314/tempfsid_mnt/snap1
ReceiveSCRATCH_MNT
At subvol snap1
+ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/ tempfsid_mnt/foo
-Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo
+Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo
...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 4 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>Reviewed-by Qu Wenruo <[email protected]>Thanks,
QuQuoted 4 lines
---
tests/btrfs/314 | 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)
Quoted 9 lines
tests/btrfs/314 _cleanup() · line 26
Quoted 9 lines
tests/btrfs/314 +0
-0@@ -21,6 +21,10 @@ _cleanup(). ./common/filter.btrfs
tests/btrfs/314 +3
-0+# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS=
Wait for a minute, this means you're disabling SELINUX mount options completely.
I'm not sure if this is really needed.
Quoted 10 lines
Quoted 10 lines
+
_require_scratch_dev_pool2
_require_btrfs_fs_featuretemp_fsidtests/btrfs/314 +0
-0@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]}
_scratch_mount
-_mount${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} +_mount${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
The problem of the old code is it doesn't have any SELinux related mount option, thus later receive will fail to set SELinux context.
But since you have already added SELINUX_MOUNT_OPTIONS, I think you do not need to disable the SELINUX_MOUNT_OPTIONS.
Have you tested with only this change, without resetting SELINUX_MOUNT_OPTIONS?
Thanks,
Qu
Quoted 4 lines
Quoted 2 lines
$XFS_IO_PROG -fc 'pwrite -S
0x610 9000' ${src}/foo |_filter_xfs_io_btrfssubvolume snapshot -r ${src} ${src}/snap1
Quoted 81 lines · Qu Wenruo
Quoted 49 lines · Qu Wenruo
Quoted 32 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out
+++ results//btrfs/314.out.bad
@@ -17,5 +17,6 @@
At subvol TEST_DIR/314/tempfsid_mnt/snap1 ReceiveSCRATCH_MNT
At subvol snap1
+ERROR: lsetxattr foo
security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed:
Operation not supportedSend: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/ tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 4 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>Reviewed-by Qu Wenruo <[email protected]>Thanks,
QuQuoted 4 lines
--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)Quoted 9 lines
tests/btrfs/314 _cleanup() · line 24
Quoted 9 lines
tests/btrfs/314 +3
-0@@ -21,6 +21,10 @@ _cleanup() . ./common/filter.btrfs +# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS=Wait for a minute, this means you're disabling SELINUX mount options completely.
I'm not sure if this is really needed.
Quoted 10 lines
tests/btrfs/314 send_receive_tempfsid() · line 46
Quoted 10 lines
tests/btrfs/314 +2
-1+ _require_scratch_dev_pool 2 _require_btrfs_fs_feature temp_fsid@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount ${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}The problem of the old code is it doesn't have any SELinux related mount option, thus later receive will fail to set SELinux context.
Quoted 5 lines
But since you have already added
SELINUX_MOUNT_OPTIONS, I think you do not need to disable theSELINUX_MOUNT_OPTIONS.Have you tested with only this change, without resetting
SELINUX_MOUNT_OPTIONS?
Yes, I tested both. Actually resetting this option was the first fix I came up with, that's why I kept it. This option breaks the test case when SELinux is enabled.
But then I figured the other way around (using the option consistently with all the mounts) also works. So I added it for consistency. At that point, resetting the option is not really strictly needed anymore (as you correctly suspect).
So there are two possible solutions. Each one makes the testcase 314 pass. But they can as well be combined.
Anyways, this test is fine without forcing the default mount context, which is more a bandaid for other fstests, IIUC. There's no need for this option in this case, at least with my testing. Hence I disabled it. Does it fail for you?
Quoted 8 lines
Thanks,
QuQuoted 5 lines
Quoted 3 lines
tests/btrfs/314 +0
-0$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo |
_filter_xfs_io_btrfs subvolume snapshot -r ${src} ${src}/snap1
Quoted 96 lines · Daniel Vacek
Quoted 81 lines · Qu Wenruo
Quoted 49 lines · Qu Wenruo
Quoted 32 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out
+++ results//btrfs/314.out.bad
@@ -17,5 +17,6 @@
At subvol TEST_DIR/314/tempfsid_mnt/snap1 ReceiveSCRATCH_MNT
At subvol snap1
+ERROR: lsetxattr foo
security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed:
Operation not supportedSend: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/ tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 4 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>Reviewed-by Qu Wenruo <[email protected]>Thanks,
QuQuoted 4 lines
--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)Quoted 9 lines
tests/btrfs/314 _cleanup() · line 24
Quoted 9 lines
tests/btrfs/314 +3
-0@@ -21,6 +21,10 @@ _cleanup() . ./common/filter.btrfs +# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS=Wait for a minute, this means you're disabling SELINUX mount options completely.
I'm not sure if this is really needed.
Quoted 10 lines
tests/btrfs/314 send_receive_tempfsid() · line 46
Quoted 10 lines
tests/btrfs/314 +2
-1+ _require_scratch_dev_pool 2 _require_btrfs_fs_feature temp_fsid@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount ${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}The problem of the old code is it doesn't have any SELinux related mount option, thus later receive will fail to set SELinux context.
Quoted 5 lines
But since you have already added
SELINUX_MOUNT_OPTIONS, I think you do not need to disable theSELINUX_MOUNT_OPTIONS.Have you tested with only this change, without resetting
SELINUX_MOUNT_OPTIONS?Yes, I tested both. Actually resetting this option was the first fix I came up with, that's why I kept it. This option breaks the test case when SELinux is enabled.
But then I figured the other way around (using the option consistently with all the mounts) also works. So I added it for consistency. At that point, resetting the option is not really strictly needed anymore (as you correctly suspect).
Quoted 2 lines
So there are two possible solutions. Each one makes the testcase 314 pass. But they can as well be combined.
Resetting the SELINUX one is not a good solution, that just means we reduce the coverage (No more SELINUX coverage for this test case anymore).
So please only fix the mount command (with the extra selinux mount option), without overriding the existing SElinux config.
Thanks,
Qu
Quoted 14 lines
Anyways, this test is fine without forcing the default mount context, which is more a bandaid for other fstests, IIUC. There's no need for this option in this case, at least with my testing. Hence I disabled it. Does it fail for you?
Quoted 8 lines
Thanks,
QuQuoted 5 lines
Quoted 3 lines
tests/btrfs/314 +0
-0$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo |
_filter_xfs_io_btrfs subvolume snapshot -r ${src} ${src}/snap1
Quoted 100 lines · Qu Wenruo
Quoted 96 lines · Daniel Vacek
Quoted 81 lines · Qu Wenruo
Quoted 49 lines · Qu Wenruo
Quoted 32 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out
+++ results//btrfs/314.out.bad
@@ -17,5 +17,6 @@
At subvol TEST_DIR/314/tempfsid_mnt/snap1 ReceiveSCRATCH_MNT
At subvol snap1
+ERROR: lsetxattr foo
security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed:
Operation not supportedSend: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/ tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 4 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>Reviewed-by Qu Wenruo <[email protected]>Thanks,
QuQuoted 4 lines
--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)Quoted 9 lines
tests/btrfs/314 _cleanup() · line 24
Quoted 9 lines
tests/btrfs/314 +3
-0@@ -21,6 +21,10 @@ _cleanup() . ./common/filter.btrfs +# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS=Wait for a minute, this means you're disabling SELINUX mount options completely.
I'm not sure if this is really needed.
Quoted 10 lines
tests/btrfs/314 send_receive_tempfsid() · line 46
Quoted 10 lines
tests/btrfs/314 +2
-1+ _require_scratch_dev_pool 2 _require_btrfs_fs_feature temp_fsid@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount ${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}The problem of the old code is it doesn't have any SELinux related mount option, thus later receive will fail to set SELinux context.
Quoted 5 lines
But since you have already added
SELINUX_MOUNT_OPTIONS, I think you do not need to disable theSELINUX_MOUNT_OPTIONS.Have you tested with only this change, without resetting
SELINUX_MOUNT_OPTIONS?Yes, I tested both. Actually resetting this option was the first fix I came up with, that's why I kept it. This option breaks the test case when SELinux is enabled.
But then I figured the other way around (using the option consistently with all the mounts) also works. So I added it for consistency. At that point, resetting the option is not really strictly needed anymore (as you correctly suspect).
Quoted 5 lines
Quoted 2 lines
So there are two possible solutions. Each one makes the testcase 314 pass. But they can as well be combined.
Resetting the SELINUX one is not a good solution, that just means we reduce the coverage (No more SELINUX coverage for this test case anymore).
I understand it's the other way around. Forcing a default mount context basically disables SELinux. Well, more precisely it partially cripples it.
Removing this option enables the usual default SELinux behavior. Note, SELinux is always enabled unless you cripple it.
Or do you use such an option with any of your mounts? I doubt so.
Check the mentioned commit 3839d299. fstests cripple SELinux by default. Which doesn't look good by itself.
At least I'd say it's good for diversity to have one test different. Diverse tests are prefered with testing, right?
Quoted 20 lines
So please only fix the mount command (with the extra selinux mount option), without overriding the existing SElinux config.
Thanks,
QuQuoted 14 lines
Anyways, this test is fine without forcing the default mount context, which is more a bandaid for other fstests, IIUC. There's no need for this option in this case, at least with my testing. Hence I disabled it. Does it fail for you?
Quoted 8 lines
Thanks,
QuQuoted 5 lines
Quoted 3 lines
tests/btrfs/314 +0
-0$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo |
_filter_xfs_io_btrfs subvolume snapshot -r ${src} ${src}/snap1
Quoted 104 lines · Daniel Vacek
Quoted 103 lines · Qu Wenruo
Quoted 98 lines · Daniel Vacek
Quoted 81 lines · Qu Wenruo
Quoted 49 lines · Qu Wenruo
Quoted 32 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out
+++ results//btrfs/314.out.bad
@@ -17,5 +17,6 @@
At subvol TEST_DIR/314/tempfsid_mnt/snap1 ReceiveSCRATCH_MNT
At subvol snap1
+ERROR: lsetxattr foo
security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed:
Operation not supportedSend: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/ tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 4 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>Reviewed-by Qu Wenruo <[email protected]>Thanks,
QuQuoted 4 lines
--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)Quoted 9 lines
tests/btrfs/314 _cleanup() · line 24
Quoted 9 lines
tests/btrfs/314 +3
-0@@ -21,6 +21,10 @@ _cleanup() . ./common/filter.btrfs +# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS=Wait for a minute, this means you're disabling SELINUX mount options completely.
I'm not sure if this is really needed.
Quoted 10 lines
tests/btrfs/314 send_receive_tempfsid() · line 46
Quoted 10 lines
tests/btrfs/314 +2
-1+ _require_scratch_dev_pool 2 _require_btrfs_fs_feature temp_fsid@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount ${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}The problem of the old code is it doesn't have any SELinux related mount option, thus later receive will fail to set SELinux context.
Quoted 5 lines
But since you have already added
SELINUX_MOUNT_OPTIONS, I think you do not need to disable theSELINUX_MOUNT_OPTIONS.Have you tested with only this change, without resetting
SELINUX_MOUNT_OPTIONS?Yes, I tested both. Actually resetting this option was the first fix I came up with, that's why I kept it. This option breaks the test case when SELinux is enabled.
But then I figured the other way around (using the option consistently with all the mounts) also works. So I added it for consistency. At that point, resetting the option is not really strictly needed anymore (as you correctly suspect).So there are two possible solutions. Each one makes the testcase 314 pass. But they can as well be combined.
Quoted 8 lines
Quoted 2 lines
Resetting the SELINUX one is not a good solution, that just means we reduce the coverage (No more SELINUX coverage for this test case anymore).
I understand it's the other way around. Forcing a default mount context basically disables SELinux. Well, more precisely it partially cripples it.
Removing this option enables the usual default SELinux behavior. Note, SELinux is always enabled unless you cripple it.
Nope, it's the other way around.
You only disable SELinux when there is a reason that SELinux context is going to change. E.g. we're mounting two different filesystems, like btrfs/012.
Which can created different SELinux context since the converted fs is a different one (Well, completely different fs type).
Unless you have a strong reason that the security context is definitely going to be different, you should not override the existing one. Especially I believe the mount fix is already enough.
Then you have no reason to keep the SELINUX override.
Remember, user can provide their own mount options (including the SELinux ones) through MOUNT_OPTIONS environmental variables.
So you at least need a full reason why SElinux context must be disable for this case. And I see none.
Quoted 5 lines
Or do you use such an option with any of your mounts? I doubt so.
Check the mentioned commit
3839d299. fstests cripple SELinux by default. Which doesn't look good by itself.
Do you really believe that commit is going crippling SELINUX?
All it does are just:
- Allow scratch mount filter to ripple off selinux context This is only to make certain golden output to skip the SElinux ones.
- Make sure scratch mount follows the SELINUX context
Please explain why you believe that commit "cripples" the whole SELinux thing.
Quoted 3 lines
At least I'd say it's good for diversity to have one test different. Diverse tests are prefered with testing, right?
What diversity? You just ripped off the whole SELinux for this test case, that's killing the diversity.
Reasons please, and "just to make it pass" doesn't count.
Quoted 21 lines
Quoted 21 lines
So please only fix the mount command (with the extra selinux mount option), without overriding the existing SElinux config.
Thanks,
QuQuoted 14 lines
Anyways, this test is fine without forcing the default mount context, which is more a bandaid for other fstests, IIUC. There's no need for this option in this case, at least with my testing. Hence I disabled it. Does it fail for you?
Quoted 8 lines
Thanks,
QuQuoted 5 lines
Quoted 3 lines
tests/btrfs/314 +0
-0$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo |
_filter_xfs_io_btrfs subvolume snapshot -r ${src} ${src}/snap1
Quoted 133 lines · Qu Wenruo
Quoted 104 lines · Daniel Vacek
Quoted 103 lines · Qu Wenruo
Quoted 98 lines · Daniel Vacek
Quoted 81 lines · Qu Wenruo
Quoted 49 lines · Qu Wenruo
Quoted 32 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out
+++ results//btrfs/314.out.bad
@@ -17,5 +17,6 @@
At subvol TEST_DIR/314/tempfsid_mnt/snap1 ReceiveSCRATCH_MNT
At subvol snap1
+ERROR: lsetxattr foo
security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed:
Operation not supportedSend: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/ tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 4 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>Reviewed-by Qu Wenruo <[email protected]>Thanks,
QuQuoted 4 lines
--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)Quoted 9 lines
tests/btrfs/314 _cleanup() · line 24
Quoted 9 lines
tests/btrfs/314 +3
-0@@ -21,6 +21,10 @@ _cleanup() . ./common/filter.btrfs +# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS=Wait for a minute, this means you're disabling SELINUX mount options completely.
I'm not sure if this is really needed.
Quoted 10 lines
tests/btrfs/314 send_receive_tempfsid() · line 46
Quoted 10 lines
tests/btrfs/314 +2
-1+ _require_scratch_dev_pool 2 _require_btrfs_fs_feature temp_fsid@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount ${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}The problem of the old code is it doesn't have any SELinux related mount option, thus later receive will fail to set SELinux context.
Quoted 5 lines
But since you have already added
SELINUX_MOUNT_OPTIONS, I think you do not need to disable theSELINUX_MOUNT_OPTIONS.Have you tested with only this change, without resetting
SELINUX_MOUNT_OPTIONS?Yes, I tested both. Actually resetting this option was the first fix I came up with, that's why I kept it. This option breaks the test case when SELinux is enabled.
But then I figured the other way around (using the option consistently with all the mounts) also works. So I added it for consistency. At that point, resetting the option is not really strictly needed anymore (as you correctly suspect).So there are two possible solutions. Each one makes the testcase 314 pass. But they can as well be combined.
Quoted 8 lines
Quoted 2 lines
Resetting the SELINUX one is not a good solution, that just means we reduce the coverage (No more SELINUX coverage for this test case anymore).
I understand it's the other way around. Forcing a default mount context basically disables SELinux. Well, more precisely it partially cripples it.
Removing this option enables the usual default SELinux behavior. Note, SELinux is always enabled unless you cripple it.Nope, it's the other way around.
You only disable SELinux when there is a reason that SELinux context is going to change.
E.g. we're mounting two different filesystems, like btrfs/012.Which can created different SELinux context since the converted fs is a different one (Well, completely different fs type).
Unless you have a strong reason that the security context is definitely going to be different, you should not override the existing one. Especially I believe the mount fix is already enough.
Then you have no reason to keep the SELINUX override.
Quoted 6 lines
Remember, user can provide their own mount options (including the SELinux ones) through
MOUNT_OPTIONSenvironmental variables.So you at least need a full reason why SElinux context must be disable for this case.
And I see none.
It does not need to be disabled. But it also does not have to be enabled for this test.
At least not with the default policy on the latest Tumbleweed I was testing on.
But your mileage may vary, I guess.
Quoted 7 lines
Quoted 5 lines
Or do you use such an option with any of your mounts? I doubt so.
Check the mentioned commit
3839d299. fstests cripple SELinux by default. Which doesn't look good by itself.Do you really believe that commit is going crippling SELINUX?
Well, in a way, yes.
What it does is that it overrides the system's default policy. Which may make sense, as for example your system policy may deny some operations the tests do, eventually resulting in failed tests. Though as a side-effect it also prevents writing the security label file attribute by design with the mount option override. In such a case SELinux just returns with -EOPNOTSUPP.
3213 sbsec = selinux_superblock(inode->i_sb);
3214 if (!(sbsec->flags & SBLABEL_MNT))
3215 return -EOPNOTSUPP;
... ^^^^^^^^^^^^^^^^^^^
The documentation says that this option is usually used with external devices like USB flash key-drives or filesystems where you do not want to mess/break their labels. Like mounting a filesystem from another machine.
Or eventually this option can be used for filesystems which do not support extended file attributes, like for example the FAT filesystem. In that case all files inherit the forced mount label and SELinux treats them using that context.
Quoted 9 lines
All it does are just:
- Allow scratch mount filter to ripple off selinux context This is only to make certain golden output to skip the SElinux ones.
- Make sure scratch mount follows the SELINUX context
Please explain why you believe that commit "cripples" the whole SELinux thing.
Well, maybe not cripples. It overrides the system policy.
The SELinux is always tested, just with different options/configuration.
Thinking about it again, I guess fstests are not supposed to test the SELinux policy and it's better to override it. SELinux should have it's own tests after all.
That said, I'm fine with dropping the first hunk when merged.
Thank you for the review, btw.
Quoted 31 lines
Quoted 3 lines
At least I'd say it's good for diversity to have one test different. Diverse tests are prefered with testing, right?
What diversity? You just ripped off the whole SELinux for this test case, that's killing the diversity.
Reasons please, and "just to make it pass" doesn't count.
Quoted 21 lines
Quoted 21 lines
So please only fix the mount command (with the extra selinux mount option), without overriding the existing SElinux config.
Thanks,
QuQuoted 14 lines
Anyways, this test is fine without forcing the default mount context, which is more a bandaid for other fstests, IIUC. There's no need for this option in this case, at least with my testing. Hence I disabled it. Does it fail for you?
Quoted 8 lines
Thanks,
QuQuoted 5 lines
Quoted 3 lines
tests/btrfs/314 +0
-0$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo |
_filter_xfs_io_btrfs subvolume snapshot -r ${src} ${src}/snap1
Quoted 1 line · Daniel Vacek
On Fri, 21 Feb 2025 at 09:20, Qu Wenruo <[email protected]> wrote:
[...]
Quoted 9 lines
Quoted 6 lines
Remember, user can provide their own mount options (including the SELinux ones) through
MOUNT_OPTIONSenvironmental variables.So you at least need a full reason why SElinux context must be disable for this case.
And I see none.It does not need to be disabled. But it also does not have to be enabled for this test.
Then good lucky if one day some QA guy finds out the send/receive behavior has a SELINUX specific bug, and you need to explain to them why it's a good idea to not test SELinux for this particular workload.
Your mindset of "XX feature doesn't have to be tested" makes nosense for a test suite.
Quoted 21 lines
At least not with the default policy on the latest Tumbleweed I was testing on.
But your mileage may vary, I guess.
Quoted 7 lines
Quoted 5 lines
Or do you use such an option with any of your mounts? I doubt so.
Check the mentioned commit
3839d299. fstests cripple SELinux by default. Which doesn't look good by itself.Do you really believe that commit is going crippling SELINUX?
Well, in a way, yes.
What it does is that it overrides the system's default policy. Which may make sense, as for example your system policy may deny some operations the tests do, eventually resulting in failed tests. Though as a side-effect it also prevents writing the security label file attribute by design with the mount option override. In such a case SELinux just returns with
-EOPNOTSUPP.
Quoted 4 lines
3213 sbsec =
selinux_superblock(inode->i_sb);
3214 if (!(sbsec->flags &SBLABEL_MNT))
3215 return-EOPNOTSUPP;
... ^^^^^^^^^^^^^^^^^^^
This only explains why your mount option fix is correct.
The send stream has SELinux attrs, that's because the original fs is mounted with SELinux context (the regular _scratch_mount() helper added SELinux context).
But later we manually mounted a btrfs, not using _scratch_mount(), thus the new mounted btrfs doesn't have SELinux context, thus unable to set the SELinux attrs at receive side.
It doesn't show why you need both the mount fix and overriding SELINUX context at all.
Quoted 6 lines
Quoted 6 lines
All it does are just:
- Allow scratch mount filter to ripple off selinux context This is only to make certain golden output to skip the SElinux ones.
Quoted 8 lines
Quoted 4 lines
- Make sure scratch mount follows the SELINUX context
Please explain why you believe that commit "cripples" the whole SELinux thing.
Well, maybe not cripples. It overrides the system policy.
The SELinux is always tested, just with different options/configuration.
Not if you override the SELINUX context, then the test case will never have SELinux tested.
And you never know if someone in the future will find a bug in send/receive with SElinux enabled.
And I do not think your "combining two working fixes is fine" mindset makes any sense either.
Every fix should have a reason, if you have different ways to fix a test case, you need to evaluate the pros and cons.
Overriding SElinux means we will never test SElinux for this particular workload, which is not a small trade-off.
Fixing the mount command brings no obvious problem.
So the choice should be obvious.
But combining the two? You have all the cons (no more SElinux for this test case), but not any new benefit.
Quoted 3 lines
Thinking about it again, I guess fstests are not supposed to test the SELinux policy and it's better to override it.
It not your call.
Quoted 2 lines
SELinux should have
it's own tests after all.
Say it again loud to all the SElinux guys, and better CC them.
Quoted 37 lines
That said, I'm fine with dropping the first hunk when merged.
Thank you for the review, btw.
Quoted 31 lines
Quoted 3 lines
At least I'd say it's good for diversity to have one test different. Diverse tests are prefered with testing, right?
What diversity? You just ripped off the whole SELinux for this test case, that's killing the diversity.
Reasons please, and "just to make it pass" doesn't count.
Quoted 21 lines
Quoted 21 lines
So please only fix the mount command (with the extra selinux mount option), without overriding the existing SElinux config.
Thanks,
QuQuoted 14 lines
Anyways, this test is fine without forcing the default mount context, which is more a bandaid for other fstests, IIUC. There's no need for this option in this case, at least with my testing. Hence I disabled it. Does it fail for you?
Quoted 8 lines
Thanks,
QuQuoted 5 lines
Quoted 3 lines
$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1
Quoted 16 lines · Qu Wenruo
Quoted 1 line · Daniel Vacek
On Fri, 21 Feb 2025 at 09:20, Qu Wenruo <[email protected]> wrote:
[...]
Quoted 9 lines
Quoted 6 lines
Remember, user can provide their own mount options (including the SELinux ones) through
MOUNT_OPTIONSenvironmental variables.So you at least need a full reason why SElinux context must be disable for this case.
And I see none.It does not need to be disabled. But it also does not have to be enabled for this test.
Quoted 6 lines
Then good lucky if one day some QA guy finds out the send/receive behavior has a SELINUX specific bug, and you need to explain to them why it's a good idea to not test SELinux for this particular workload.
Your mindset of "XX feature doesn't have to be tested" makes nosense for a test suite.
Huh, this is a huge misunderstanding.You still got it the other way around. I'm sorry if I was confusing you.
I never said I'm against testing SELinux. Quite the opposite, to be honest. I did argue that testing the default system policy without overriding the context also works for this test, at least with my testing on the latest TW.
SELinux is always tested. Just either with the default system policy or with the given forced context.
Quoted 21 lines
Quoted 21 lines
At least not with the default policy on the latest Tumbleweed I was testing on.
But your mileage may vary, I guess.
Quoted 7 lines
Quoted 5 lines
Or do you use such an option with any of your mounts? I doubt so.
Check the mentioned commit
3839d299. fstests cripple SELinux by default. Which doesn't look good by itself.Do you really believe that commit is going crippling SELINUX?
Well, in a way, yes.
What it does is that it overrides the system's default policy. Which may make sense, as for example your system policy may deny some operations the tests do, eventually resulting in failed tests. Though as a side-effect it also prevents writing the security label file attribute by design with the mount option override. In such a case SELinux just returns with
-EOPNOTSUPP.
Quoted 6 lines
Quoted 4 lines
3213 sbsec =
selinux_superblock(inode->i_sb);
3214 if (!(sbsec->flags &SBLABEL_MNT))
3215 return-EOPNOTSUPP;
... ^^^^^^^^^^^^^^^^^^^This only explains why your mount option fix is correct.
Nope. This triggers precisely when the context is forced with the mount option. In that case setting the file attribute is not supported.
Quoted 3 lines
The send stream has SELinux attrs, that's because the original fs is mounted with SELinux context (the regular
_scratch_mount()helper added SELinux context).
Nope. Again, the other way around. The send stream has the security.selinux attribute precisely because the mount was missing the option and hence the file labels were used (and not refused). But the receive side fails as that mount actually did use the context mount option and so it was refusing setting the file label returning this -EOPNOTSUPP error.
Quoted 3 lines
But later we manually mounted a btrfs, not using
_scratch_mount(), thus the new mounted btrfs doesn't have SELinux context, thus unable to set the SELinux attrs at receive side.
This is just wrong.
Quoted 2 lines
It doesn't show why you need both the mount fix and overriding SELINUX context at all.
I'm saying you don't need both from the very beginning. Where did I say you do?
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
All it does are just:
- Allow scratch mount filter to ripple off selinux context This is only to make certain golden output to skip the SElinux ones.
- Make sure scratch mount follows the SELINUX context
Please explain why you believe that commit "cripples" the whole SELinux thing.
Quoted 6 lines
Quoted 3 lines
Well, maybe not cripples. It overrides the system policy.
The SELinux is always tested, just with different options/configuration.
Not if you override the SELINUX context, then the test case will never have SELinux tested.
Wrong. SELinux is always tested. Either with the system-defined policy or the overridden context.
Quoted 2 lines
And you never know if someone in the future will find a bug in send/receive with SElinux enabled.
More likely you may find the test failing in the future as you'd be testing on a distribution which changed it's policy to forbid access to /mnt path. Or you configure fstests to mount somewhere else where it's forbidden by the default system policy.
Again, SELinux is always tested. And it may just be easier for fstests to force the context to prevent test failures due to the system default policy. That's why I also said that I'm fine with dropping that hunk.
Quoted 2 lines
And I do not think your "combining two working fixes is fine" mindset makes any sense either.
One is a fix, one is a configuration. You change the configuration (ie, keep the default system policy, no forced context) and it works. You apply the fix and it works no matter what configuration.
So the configuration does not really need to be changed, which I'm saying from the beginning. But I left it there as no biggie. Now, after the discussion with you, I agree that fstests may be better forcing the context explicitly instead of relying on the default system policy.
Quoted 2 lines
Every fix should have a reason, if you have different ways to fix a test case, you need to evaluate the pros and cons.
The pro was to test the real thing and not force override it. But that may not be a good idea for fstests.
Quoted 2 lines
Overriding SElinux means we will never test SElinux for this particular workload, which is not a small trade-off.
Wrong. Again, SELinux is always used and tested. Only the policy is overridden or the default one.
Quoted 6 lines
Fixing the mount command brings no obvious problem.
So the choice should be obvious.
But combining the two? You have all the cons (no more SElinux for this test case), but not any new benefit.
You're just confused by what the configuration changes. SELinux is still tested.
Quoted 5 lines
Quoted 3 lines
Thinking about it again, I guess fstests are not supposed to test the SELinux policy and it's better to override it.
It not your call.
Agreed. The intention was to cover it as an additional bonus but in the end that may not be wanted. In the end I agree fstests may be better to force the given context and not be eventually broken by the default system policy. Eventhough it does not seem likely to happen at this point.
Quoted 4 lines
Quoted 2 lines
SELinux should have
it's own tests after all.Say it again loud to all the SElinux guys, and better CC them.
What I meant is that for sure they have way more fundamental tests then checking the correctness of the applied policy. That's more a user/devops thing. That's what we're talking here about, whether to use one policy or the other. Not whether to use SELinux as it's enabled in both cases.
Quoted 38 lines
Quoted 37 lines
That said, I'm fine with dropping the first hunk when merged.
Thank you for the review, btw.
Quoted 31 lines
Quoted 3 lines
At least I'd say it's good for diversity to have one test different. Diverse tests are prefered with testing, right?
What diversity? You just ripped off the whole SELinux for this test case, that's killing the diversity.
Reasons please, and "just to make it pass" doesn't count.
Quoted 21 lines
Quoted 21 lines
So please only fix the mount command (with the extra selinux mount option), without overriding the existing SElinux config.
Thanks,
QuQuoted 14 lines
Anyways, this test is fine without forcing the default mount context, which is more a bandaid for other fstests, IIUC. There's no need for this option in this case, at least with my testing. Hence I disabled it. Does it fail for you?
Quoted 8 lines
Thanks,
QuQuoted 5 lines
Quoted 3 lines
$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1
Quoted 59 lines · Daniel Vacek
Quoted 16 lines · Qu Wenruo
Quoted 1 line · Daniel Vacek
On Fri, 21 Feb 2025 at 09:20, Qu Wenruo <[email protected]> wrote:
[...]
Quoted 9 lines
Quoted 6 lines
Remember, user can provide their own mount options (including the SELinux ones) through
MOUNT_OPTIONSenvironmental variables.So you at least need a full reason why SElinux context must be disable for this case.
And I see none.It does not need to be disabled. But it also does not have to be enabled for this test.
Quoted 6 lines
Then good lucky if one day some QA guy finds out the send/receive behavior has a SELINUX specific bug, and you need to explain to them why it's a good idea to not test SELinux for this particular workload.
Your mindset of "XX feature doesn't have to be tested" makes nosense for a test suite.
Huh, this is a huge misunderstanding.You still got it the other way around. I'm sorry if I was confusing you.
I never said I'm against testing SELinux. Quite the opposite, to be honest. I did argue that testing the default system policy without overriding the context also works for this test, at least with my testing on the latest TW.
SELinux is always tested. Just either with the default system policy or with the given forced context.Quoted 26 lines
Quoted 25 lines
At least not with the default policy on the latest Tumbleweed I was testing on.
But your mileage may vary, I guess.
Quoted 7 lines
Quoted 5 lines
Or do you use such an option with any of your mounts? I doubt so.
Check the mentioned commit
3839d299. fstests cripple SELinux by default. Which doesn't look good by itself.Do you really believe that commit is going crippling SELINUX?
Well, in a way, yes.
What it does is that it overrides the system's default policy. Which may make sense, as for example your system policy may deny some operations the tests do, eventually resulting in failed tests. Though as a side-effect it also prevents writing the security label file attribute by design with the mount option override. In such a case SELinux just returns with
-EOPNOTSUPP.3213 sbsec =
selinux_superblock(inode->i_sb);
3214 if (!(sbsec->flags &SBLABEL_MNT))
3215 return-EOPNOTSUPP;
... ^^^^^^^^^^^^^^^^^^^
Quoted 5 lines
Quoted 1 line
This only explains why your mount option fix is correct.
Nope. This triggers precisely when the context is forced with the mount option. In that case setting the file attribute is not supported.
BS, overriding the SELINUX context just means disabling SELINUX.
Your "fix" from the very beginning is doing two conflicting things:
- Disable SELINUX context by overriding it
- Add back the empty SELinux context for mount
Explain why it makes any sense?
Quoted 8 lines
Quoted 4 lines
The send stream has SELinux attrs, that's because the original fs is mounted with SELinux context (the regular
_scratch_mount()helper added SELinux context).Nope. Again, the other way around. The send stream has the
security.selinuxattribute precisely because the mount was missing the option and hence the file labels were used (and not refused).
There is no SELinux xattrs because you damn disabled SELinux for this test case!!
But
Quoted 9 lines
the receive side fails as that mount actually did use the context mount option and so it was refusing setting the file label returning this
-EOPNOTSUPPerror.Quoted 3 lines
But later we manually mounted a btrfs, not using
_scratch_mount(), thus the new mounted btrfs doesn't have SELinux context, thus unable to set the SELinux attrs at receive side.This is just wrong.
Whatever you believe, I think I have wasted too much time on this non-sense.
Quoted 5 lines
Quoted 3 lines
It doesn't show why you need both the mount fix and overriding SELINUX context at all.
I'm saying you don't need both from the very beginning. Where did I say you do?
Then why damn putting the override and mount fix in the same damn patch?
Quoted 27 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out +++ results//btrfs/314.out.bad @@ -17,5 +17,6 @@ At subvol TEST_DIR/314/tempfsid_mnt/snap1 Receive SCRATCH_MNT At subvol snap1 +ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 5 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>---
Take it easy, Thanks for both of you would like to help fstests to get better :)
Firstly, SELINUX_MOUNT_OPTIONS isn't a parameter to enable or disable SELinux test. We just use it to avoid tons of ondisk selinux lables to mess up the testing. So mount with a specified SELINUX_MOUNT_OPTIONS to avoid new ondisk selinux labels always be created in each file's extended attributes field.
Secondly, I don't want to attend the argument :) Just for this patch review, I prefer just doing:
_scratch_mount
- _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
+ _mount $SELINUX_MOUNT_OPTIONS ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
or if you concern MOUNT_OPTIONS and SELINUX_MOUNT_OPTIONS both, maybe:
_scratch_mount
- _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
+ _mount $(_common_dev_mount_options) ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
That's enough to help "_scratch_mount" and later "_mount" use same SELINUX_MOUNT_OPTIONS, and fix the test failure you hit.
About resetting "SELINUX_MOUNT_OPTIONS", I think btrfs/314 isn't a test case cares about SELinux labels on-disk or not. So how about don't touch it.
If you'd like to talk about if xfstests cases should test with a specified SELINUX_MOUNT_OPTIONS mount option or not, you can send another patch to talk about 3839d299 ("xfstests: mount xfs with a context when selinux is on").
Now let's fix this failure at first :)
Thanks,
Zorro
Quoted 31 lines
tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/btrfs/314 +5
-1@@ -21,6 +21,10 @@ _cleanup() . ./common/filter.btrfs +# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS= + _require_scratch_dev_pool 2 _require_btrfs_fs_feature temp_fsid@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount ${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1Signature · 1 line
2.48.1
Quoted 56 lines · Zorro Lang
Quoted 27 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out +++ results//btrfs/314.out.bad @@ -17,5 +17,6 @@ At subvol TEST_DIR/314/tempfsid_mnt/snap1 Receive SCRATCH_MNT At subvol snap1 +ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 5 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>---
Take it easy, Thanks for both of you would like to help fstests to get better :)
Firstly,
SELINUX_MOUNT_OPTIONSisn't a parameter to enable or disable SELinux test. We just use it to avoid tons of ondisk selinux lables to mess up the testing. So mount with a specifiedSELINUX_MOUNT_OPTIONSto avoid new ondisk selinux labels always be created in each file's extended attributes field.Secondly, I don't want to attend the argument :) Just for this patch review, I prefer just doing:
_scratch_mount
-_mount${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
+_mount$SELINUX_MOUNT_OPTIONS ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}or if you concern
MOUNT_OPTIONSandSELINUX_MOUNT_OPTIONSboth, maybe:
_scratch_mount
-_mount${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
+_mount$(_common_dev_mount_options) ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
Quoted 5 lines
That's enough to help "
_scratch_mount" and later "_mount" use sameSELINUX_MOUNT_OPTIONS, and fix the test failure you hit.About resetting "
SELINUX_MOUNT_OPTIONS", I think btrfs/314 isn't a test case cares about SELinux labels on-disk or not. So how about don't touch it.
Thanks for the sane final call.
Exactly what I want in the first place.
Thanks,
Qu
Quoted 43 lines
If you'd like to talk about if xfstests cases should test with a specified
SELINUX_MOUNT_OPTIONSmount option or not, you can send another patch to talk about3839d299("xfstests: mount xfs with a context when selinux is on").Now let's fix this failure at first :)
Thanks,
ZorroQuoted 31 lines
tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/btrfs/314 +5
-2@@ -21,6 +21,10 @@ _cleanup() . ./common/filter.btrfs +# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS= + _require_scratch_dev_pool 2 _require_btrfs_fs_feature temp_fsid@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount ${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1 --2.48.1
Quoted 62 lines · Qu Wenruo
Quoted 59 lines · Zorro Lang
Quoted 27 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out +++ results//btrfs/314.out.bad @@ -17,5 +17,6 @@ At subvol TEST_DIR/314/tempfsid_mnt/snap1 Receive SCRATCH_MNT At subvol snap1 +ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 5 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>---
Take it easy, Thanks for both of you would like to help fstests to get better :)
Firstly,
SELINUX_MOUNT_OPTIONSisn't a parameter to enable or disable SELinux test. We just use it to avoid tons of ondisk selinux lables to mess up the testing. So mount with a specifiedSELINUX_MOUNT_OPTIONSto avoid new ondisk selinux labels always be created in each file's extended attributes field.Secondly, I don't want to attend the argument :) Just for this patch review, I prefer just doing:
_scratch_mount
-_mount${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
+_mount$SELINUX_MOUNT_OPTIONS ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}or if you concern
MOUNT_OPTIONSandSELINUX_MOUNT_OPTIONSboth, maybe:
_scratch_mount
-_mount${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
+_mount$(_common_dev_mount_options) ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}That's enough to help "
_scratch_mount" and later "_mount" use sameSELINUX_MOUNT_OPTIONS, and fix the test failure you hit.
Quoted 6 lines
Quoted 2 lines
About resetting "
SELINUX_MOUNT_OPTIONS", I think btrfs/314 isn't a test case cares about SELinux labels on-disk or not. So how about don't touch it.Thanks for the sane final call.
Exactly what I want in the first place.
Your suggestion is good to me, but I think you confused Daniel a bit with "overriding the SELINUX context just means disabling SELINUX" :) Anyway, I believe both of you know how to fix this issue and how SELinux works, maybe you're just not talking in the same channel, so take it easy, let's over it and move on :-D
Thanks,
Zorro
Quoted 48 lines
Thanks,
QuQuoted 43 lines
If you'd like to talk about if xfstests cases should test with a specified
SELINUX_MOUNT_OPTIONSmount option or not, you can send another patch to talk about3839d299("xfstests: mount xfs with a context when selinux is on").Now let's fix this failure at first :)
Thanks,
ZorroQuoted 31 lines
tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/btrfs/314 +5
-2@@ -21,6 +21,10 @@ _cleanup() . ./common/filter.btrfs +# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS= + _require_scratch_dev_pool 2 _require_btrfs_fs_feature temp_fsid@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount ${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1 --2.48.1
Quoted 35 lines · Zorro Lang
Quoted 27 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out +++ results//btrfs/314.out.bad @@ -17,5 +17,6 @@ At subvol TEST_DIR/314/tempfsid_mnt/snap1 Receive SCRATCH_MNT At subvol snap1 +ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 5 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>---
Quoted 8 lines
Take it easy, Thanks for both of you would like to help fstests to get better :)
Firstly,
SELINUX_MOUNT_OPTIONSisn't a parameter to enable or disable SELinux test. We just use it to avoid tons of ondisk selinux lables to mess up the testing. So mount with a specifiedSELINUX_MOUNT_OPTIONSto avoid new ondisk selinux labels always be created in each file's extended attributes field.
Well put. I was trying to explain that.
In fact it does not mess with this test and that's why originally I kept it and I did not remove it after coming up with the other way to address the bug. I thought a bit of diversity could be useful with the testing after all.
Quoted 6 lines
Secondly, I don't want to attend the argument :) Just for this patch review, I prefer just doing:
_scratch_mount
-_mount${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
+_mount$SELINUX_MOUNT_OPTIONS ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
I already agreed with dropping the other hunk before.
Quoted 5 lines
or if you concern
MOUNT_OPTIONSandSELINUX_MOUNT_OPTIONSboth, maybe:
_scratch_mount
-_mount${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
+_mount$(_common_dev_mount_options) ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
That's even better. I'll send a v2 with this change. Thanks for the hint.
Quoted 5 lines
That's enough to help "
_scratch_mount" and later "_mount" use sameSELINUX_MOUNT_OPTIONS, and fix the test failure you hit.About resetting "
SELINUX_MOUNT_OPTIONS", I think btrfs/314 isn't a test case cares about SELinux labels on-disk or not. So how about don't touch it.
Yup, as I said, I already agreed with that in the previous conversation.
Quoted 41 lines
If you'd like to talk about if xfstests cases should test with a specified
SELINUX_MOUNT_OPTIONSmount option or not, you can send another patch to talk about3839d299("xfstests: mount xfs with a context when selinux is on").Now let's fix this failure at first :)
Thanks,
ZorroQuoted 31 lines
tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/btrfs/314 +5
-2@@ -21,6 +21,10 @@ _cleanup() . ./common/filter.btrfs +# Disable the forced SELinux context. We are fine testing the +# security labels with this test when SELinux is enabled. +SELINUX_MOUNT_OPTIONS= + _require_scratch_dev_pool 2 _require_btrfs_fs_feature temp_fsid@@ -38,7 +42,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount ${SELINUX_MOUNT_OPTIONS} ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1 --2.48.1
PATCH v2 1/1 fstests: btrfs/314: fix the failure when SELinux is enabled
In reply to Daniel VacekWhen SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out
+++ results//btrfs/314.out.bad
@@ -17,5 +17,6 @@
At subvol TEST_DIR/314/tempfsid_mnt/snap1
Receive SCRATCH_MNT
At subvol snap1
+ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported
Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo
-Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo
+Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo
...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdb /mnt/scratch
See commit 3839d299 ("xfstests: mount xfs with a context when selinux is on")
fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tests/btrfs/314 +1 -1
@@ -38,7 +38,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount $(_common_dev_mount_options) ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1
Signature · 1 line
2.48.1
Quoted 23 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out +++ results//btrfs/314.out.bad @@ -17,5 +17,6 @@ At subvol TEST_DIR/314/tempfsid_mnt/snap1 Receive SCRATCH_MNT At subvol snap1 +ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")
Quoted 7 lines
fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
And of course I forgot to remove this sentence. Please, remove it if you decide to merge this fix.
Quoted 21 lines
Signed-off-by Daniel Vacek <[email protected]>--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/btrfs/314 +1
-2@@ -38,7 +38,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount $(_common_dev_mount_options) ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1 --2.48.1
Anand Jain
Reviewed-byQuoted 5 lines · Daniel Vacek
Quoted 4 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
Quoted 12 lines
Quoted 12 lines
--- tests/btrfs/314.out +++ results//btrfs/314.out.bad @@ -17,5 +17,6 @@ At subvol TEST_DIR/314/tempfsid_mnt/snap1 Receive SCRATCH_MNT At subvol snap1 +ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...
It’s actually good that the Btrfs receive failed because the send had an unlabeled security context—kind of a validation, even though it wasn’t intentional. The fix here fits the objective of the test case.
Quoted 12 lines
Quoted 12 lines
Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 5 lines
Quoted 2 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
And of course I forgot to remove this sentence. Please, remove it if you decide to merge this fix.
Fixed the changelog and pushed it (for-next).
Thanks, Anand
Quoted 22 lines
Quoted 22 lines
Signed-off-by Daniel Vacek <[email protected]>--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/btrfs/314 +1
-2@@ -38,7 +38,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount $(_common_dev_mount_options) ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1 --2.48.1
Quoted 20 lines · Anand Jain
Quoted 5 lines · Daniel Vacek
Quoted 4 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
Quoted 12 lines
Quoted 12 lines
--- tests/btrfs/314.out +++ results//btrfs/314.out.bad @@ -17,5 +17,6 @@ At subvol TEST_DIR/314/tempfsid_mnt/snap1 Receive SCRATCH_MNT At subvol snap1 +ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...
Quoted 3 lines
It’s actually good that the Btrfs receive failed because the send had an unlabeled security context—kind of a validation, even though it wasn’t intentional. The fix here fits the objective of the test case.
It's the other way around. Send (missing the mount option) had the label (as expected) which was refused by the receive side due to the explicit context mount option. That's how SELinux is designed.
Quoted 49 lines
Reviewed-by Anand Jain <[email protected]>Quoted 12 lines
Quoted 12 lines
Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Quoted 5 lines
Quoted 2 lines
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
And of course I forgot to remove this sentence. Please, remove it if you decide to merge this fix.
Fixed the changelog and pushed it (for-next).
Thanks, Anand
Quoted 22 lines
Quoted 22 lines
Signed-off-by Daniel Vacek <[email protected]>--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/btrfs/314 +1
-2@@ -38,7 +38,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount $(_common_dev_mount_options) ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1 --2.48.1
Quoted 1 line · Anand Jain
Fixed the changelog and pushed it (for-next).
Thank you.
Quoted 40 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out +++ results//btrfs/314.out.bad @@ -17,5 +17,6 @@ At subvol TEST_DIR/314/tempfsid_mnt/snap1 Receive SCRATCH_MNT At subvol snap1 +ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/btrfs/314 +0
-0
tests/btrfs/314 send_receive_tempfsid() · line 41
Quoted 5 lines
tests/btrfs/314 +1
-1@@ -38,7 +38,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount $(_common_dev_mount_options) ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
I note that there are several similar instances of this in common/, either as '_mount $(_common_dev_mount_options)' or as '$MOUNT_PROG -t $FSTYP _common_dev_mount_options $*'
That kinda says to me there should be a _mount_dev() wrapper, similar to the _mkfs_dev() wrapper like this:
_mount_dev()
{
_mount $(_common_dev_mount_options) $*
}And all these open coded device mounts be converted to use the wrapper. That way we don't have this problem of omitting _common_dev_mount_options when future tests open code specific device mounts.
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 55 lines · Dave Chinner
Quoted 40 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out +++ results//btrfs/314.out.bad @@ -17,5 +17,6 @@ At subvol TEST_DIR/314/tempfsid_mnt/snap1 Receive SCRATCH_MNT At subvol snap1 +ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/btrfs/314 +0
-0tests/btrfs/314 send_receive_tempfsid() · line 41
Quoted 5 lines
tests/btrfs/314 +1
-1@@ -38,7 +38,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount $(_common_dev_mount_options) ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}I note that there are several similar instances of this in common/, either as '
_mount$(_common_dev_mount_options)' or as '$MOUNT_PROG -t $FSTYP_common_dev_mount_options $*'That kinda says to me there should be a
_mount_dev()wrapper, similar to the_mkfs_dev()wrapper like this:
_mount_dev()
Quoted 8 lines
{ _mount $(_common_dev_mount_options) $* }And all these open coded device mounts be converted to use the wrapper. That way we don't have this problem of omitting
_common_dev_mount_optionswhen future tests open code specific device mounts.
OK, so we have two requirements about mount/umount now:
1) Use _mount_dev to replace _mount or even $MOUNT_PROG. But overlayfs tests might be special, he has to deal with underlying devices which is not suitable for $(_common_dev_mount_options).
2) Use _umount to replace $UMOUNT_PROG:
https://lore.kernel.org/fstests/20250221041819.GX21799@frogsfrogsfrogs/
Thanks,
Zorro
Quoted 6 lines
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 40 lines · Daniel Vacek
When SELinux is enabled this test fails unable to receive a file with security label attribute:
--- tests/btrfs/314.out +++ results//btrfs/314.out.bad @@ -17,5 +17,6 @@ At subvol TEST_DIR/314/tempfsid_mnt/snap1 Receive SCRATCH_MNT At subvol snap1 +ERROR: lsetxattr foo security.selinux=unconfined_u:object_r:unlabeled_t:s0 failed: Operation not supported Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo -Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo +Recv: d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/snap1/foo ...Setting the security label file attribute fails due to the default mount option implied by fstests:
MOUNT_OPTIONS-- -o context=system_u:object_r:root_t:s0/dev/sdb/mnt/scratchSee commit
3839d299("xfstests: mount xfs with a context when selinux is on")fstests by default mount test and scratch devices with forced SELinux context to get rid of the additional file attributes when SELinux is enabled. When a test mounts additional devices from the pool, it may need to honor this option to keep on par. Otherwise failures may be expected.
Moreover this test is perfectly fine labeling the files so let's just disable the forced context for this one.
Signed-off-by Daniel Vacek <[email protected]>--- tests/btrfs/314 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/btrfs/314 +0
-0
tests/btrfs/314 send_receive_tempfsid() · line 41
Quoted 5 lines
tests/btrfs/314 +1
-1@@ -38,7 +38,7 @@ send_receive_tempfsid() # Use first 2 devices from the SCRATCH_DEV_POOL mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]} _scratch_mount - _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} + _mount $(_common_dev_mount_options) ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
This's good to me,
Quoted 6 lines
tests/btrfs/314 +0
-0$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io _btrfs subvolume snapshot -r ${src} ${src}/snap1Signature · 1 line
2.48.1