selinux-testsuite: Add btrfs support for filesystem tests
Stephen Smalley
maintainerPATCH v3 1/1 selinux-testsuite: Add btrfs support for filesystem tests
From: Richard Haines <[email protected]>
This allows btrfs filesystems to be created to support the filesystem mount(2) type calls and the fs_filesystem fsmount(2) type calls.
--- README.md | 2 ++ defconfig | 5 +++++ tests/Makefile | 2 +- tests/filesystem/Filesystem.pm | 3 +++ tests/filesystem/btrfs | 1 + tests/filesystem/test | 6 ++++++ tests/fs_filesystem/btrfs | 1 + tests/fs_filesystem/test | 6 ++++++ 8 files changed, 25 insertions(+), 1 deletion(-) create mode 120000 tests/filesystem/btrfs create mode 120000 tests/fs_filesystem/btrfs
README.md +2 -0
@@ -61,6 +61,7 @@ similar dependencies): * e2fsprogs _(used by the ext4 filesystem tests)_ * jfsutils _(used by the jfs filesystem tests)_ * dosfstools _(used by the vfat filesystem tests)_ +* btrfs-progs _(used by the btrfs filesystem tests)_ * nftables _(used by inet_socket and sctp tests if ver >= 9.3 for secmark testing )_ * rdma-core-devel _(to build the `ibpkey` test program)_
@@ -136,6 +137,7 @@ command: e2fsprogs \ jfsutils \ dosfstools \ + btrfs-progs \ nftables \ netlabel-tools \ libibverbs-dev
defconfig +5 -0
@@ -122,6 +122,11 @@ CONFIG_XFS_QUOTA=y CONFIG_VFAT_FS=m CONFIG_FAT_DEFAULT_IOCHARSET="ascii" + +# Test BTRFS filesystem. +# This is not required for SELinux operation itself. +CONFIG_BTRFS_FS=y + # watch_queue for key changes. # They are not required for SELinux operation itself. CONFIG_WATCH_QUEUE=y
tests/Makefile +1 -1
@@ -4,7 +4,7 @@ SBINDIR ?= $(PREFIX)/sbin POLDEV ?= $(PREFIX)/share/selinux/devel INCLUDEDIR ?= $(PREFIX)/include SELINUXFS ?= /sys/fs/selinux -FILESYSTEMS ?= ext4 xfs jfs vfat +FILESYSTEMS ?= ext4 xfs jfs vfat btrfs export CFLAGS+=-g -O0 -Wall -D_GNU_SOURCE
tests/filesystem/Filesystem.pm +3 -0
@@ -123,6 +123,9 @@ sub attach_dev { sub make_fs { my ( $mk_type, $mk_dev, $mk_dir, $mk_opts ) = @_; my $mk_size = 16; + if ( $mk_type eq "btrfs" ) { + $mk_size = 300; + } if ( $mk_type eq "xfs" ) { $mk_size = 300; }
tests/filesystem/btrfs new file +1 -0
@@ -0,0 +1 @@ +.
tests/filesystem/test +6 -0
@@ -89,6 +89,12 @@ BEGIN { $test_count = 55; $quota_checks = 0; } + + # BTRFS uses internal quotas requiring no security hooks + elsif ( $fs_type eq "btrfs" ) { + $test_count = 55; + $quota_checks = 0; + } else { $test_count = 69; }
tests/fs_filesystem/btrfs new file +1 -0
@@ -0,0 +1 @@ +.
tests/fs_filesystem/test +6 -0
@@ -92,6 +92,12 @@ BEGIN { $test_count = 54; $quota_checks = 0; } + + # BTRFS uses internal quotas requiring no security hooks + elsif ( $fs_type eq "btrfs" ) { + $test_count = 54; + $quota_checks = 0; + } else { $test_count = 68; }
Signature · 1 line
2.51.0
Stephen Smalley
maintainerQuoted 9 lines · Stephen Smalley
From: Richard Haines <[email protected]>
This allows btrfs filesystems to be created to support the filesystem mount(2) type calls and the
fs_filesystemfsmount(2) type calls.Signed-off-by Richard Haines <[email protected]>Signed-off-by Stephen Smalley <[email protected]>
FYI, these tests pass cleanly for me on a current kernel.
Quoted 129 lines
--- README.md | 2 ++ defconfig | 5 +++++ tests/Makefile | 2 +- tests/filesystem/Filesystem.pm | 3 +++ tests/filesystem/btrfs | 1 + tests/filesystem/test | 6 ++++++ tests/fs_filesystem/btrfs | 1 + tests/fs_filesystem/test | 6 ++++++ 8 files changed, 25 insertions(+), 1 deletion(-) create mode 120000 tests/filesystem/btrfs create mode 120000 tests/fs_filesystem/btrfsREADME.md +2
-0@@ -61,6 +61,7 @@ similar dependencies): * e2fsprogs _(used by the ext4 filesystem tests)_ * jfsutils _(used by the jfs filesystem tests)_ * dosfstools _(used by the vfat filesystem tests)_ +* btrfs-progs _(used by the btrfs filesystem tests)_ * nftables _(used by inet_socket and sctp tests if ver >= 9.3 for secmark testing )_ * rdma-core-devel _(to build the `ibpkey` test program)_@@ -136,6 +137,7 @@ command: e2fsprogs \ jfsutils \ dosfstools \ + btrfs-progs \ nftables \ netlabel-tools \ libibverbs-devdefconfig +5
-0@@ -122,6 +122,11 @@ CONFIG_XFS_QUOTA=y CONFIG_VFAT_FS=m CONFIG_FAT_DEFAULT_IOCHARSET="ascii" + +# Test BTRFS filesystem. +# This is not required for SELinux operation itself. +CONFIG_BTRFS_FS=y + # watch_queue for key changes. # They are not required for SELinux operation itself. CONFIG_WATCH_QUEUE=ytests/Makefile +1
-1@@ -4,7 +4,7 @@ SBINDIR ?= $(PREFIX)/sbin POLDEV ?= $(PREFIX)/share/selinux/devel INCLUDEDIR ?= $(PREFIX)/include SELINUXFS ?= /sys/fs/selinux -FILESYSTEMS ?= ext4 xfs jfs vfat +FILESYSTEMS ?= ext4 xfs jfs vfat btrfs export CFLAGS+=-g -O0 -Wall -D_GNU_SOURCEtests/filesystem/Filesystem.pm +3
-0@@ -123,6 +123,9 @@ sub attach_dev { sub make_fs { my ( $mk_type, $mk_dev, $mk_dir, $mk_opts ) = @_; my $mk_size = 16; + if ( $mk_type eq "btrfs" ) { + $mk_size = 300; + } if ( $mk_type eq "xfs" ) { $mk_size = 300; }tests/filesystem/btrfs new file +1
-0@@ -0,0 +1 @@ +.tests/filesystem/test +6
-0@@ -89,6 +89,12 @@ BEGIN { $test_count = 55; $quota_checks = 0; } + + # BTRFS uses internal quotas requiring no security hooks + elsif ( $fs_type eq "btrfs" ) { + $test_count = 55; + $quota_checks = 0; + } else { $test_count = 69; }tests/fs_filesystem/btrfs new file +1
-0@@ -0,0 +1 @@ +.tests/fs_filesystem/test +6
-1@@ -92,6 +92,12 @@ BEGIN { $test_count = 54; $quota_checks = 0; } + + # BTRFS uses internal quotas requiring no security hooks + elsif ( $fs_type eq "btrfs" ) { + $test_count = 54; + $quota_checks = 0; + } else { $test_count = 68; } --2.51.0
Stephen Smalley
maintainerQuoted 77 lines · Stephen Smalley
Quoted 9 lines · Stephen Smalley
From: Richard Haines <[email protected]>
This allows btrfs filesystems to be created to support the filesystem mount(2) type calls and the
fs_filesystemfsmount(2) type calls.Signed-off-by Richard Haines <[email protected]>Signed-off-by Stephen Smalley <[email protected]>FYI, these tests pass cleanly for me on a current kernel.
Quoted 62 lines
--- README.md | 2 ++ defconfig | 5 +++++ tests/Makefile | 2 +- tests/filesystem/Filesystem.pm | 3 +++ tests/filesystem/btrfs | 1 + tests/filesystem/test | 6 ++++++ tests/fs_filesystem/btrfs | 1 + tests/fs_filesystem/test | 6 ++++++ 8 files changed, 25 insertions(+), 1 deletion(-) create mode 120000 tests/filesystem/btrfs create mode 120000 tests/fs_filesystem/btrfsREADME.md +2
-0@@ -61,6 +61,7 @@ similar dependencies): * e2fsprogs _(used by the ext4 filesystem tests)_ * jfsutils _(used by the jfs filesystem tests)_ * dosfstools _(used by the vfat filesystem tests)_ +* btrfs-progs _(used by the btrfs filesystem tests)_ * nftables _(used by inet_socket and sctp tests if ver >= 9.3 for secmark testing )_ * rdma-core-devel _(to build the `ibpkey` test program)_@@ -136,6 +137,7 @@ command: e2fsprogs \ jfsutils \ dosfstools \ + btrfs-progs \ nftables \ netlabel-tools \ libibverbs-devdefconfig +5
-0@@ -122,6 +122,11 @@ CONFIG_XFS_QUOTA=y CONFIG_VFAT_FS=m CONFIG_FAT_DEFAULT_IOCHARSET="ascii" + +# Test BTRFS filesystem. +# This is not required for SELinux operation itself. +CONFIG_BTRFS_FS=y + # watch_queue for key changes. # They are not required for SELinux operation itself. CONFIG_WATCH_QUEUE=ytests/Makefile +1
-1@@ -4,7 +4,7 @@ SBINDIR ?= $(PREFIX)/sbin POLDEV ?= $(PREFIX)/share/selinux/devel INCLUDEDIR ?= $(PREFIX)/include SELINUXFS ?= /sys/fs/selinux -FILESYSTEMS ?= ext4 xfs jfs vfat +FILESYSTEMS ?= ext4 xfs jfs vfat btrfs export CFLAGS+=-g -O0 -Wall -D_GNU_SOURCE
Quoted 10 lines
tests/filesystem/Filesystem.pm sub attach_dev { · line 127
Quoted 10 lines
tests/filesystem/Filesystem.pm +2
-0@@ -123,6 +123,9 @@ sub attach_dev { sub make_fs { my ( $mk_type, $mk_dev, $mk_dir, $mk_opts ) = @_; my $mk_size = 16; + if ( $mk_type eq "btrfs" ) { + $mk_size = 300;
Looks like I could drop this down to 109 if we care. 109M == 114294784 bytes is the smallest supported size reported by mkfs.btrfs. I don't know how stable that value remains across different versions or how it was derived.
Quoted 57 lines
Quoted 57 lines
tests/filesystem/Filesystem.pm +1
-0+ } if ( $mk_type eq "xfs" ) { $mk_size = 300; }tests/filesystem/btrfs new file +1
-0@@ -0,0 +1 @@ +.tests/filesystem/test +6
-0@@ -89,6 +89,12 @@ BEGIN { $test_count = 55; $quota_checks = 0; } + + # BTRFS uses internal quotas requiring no security hooks + elsif ( $fs_type eq "btrfs" ) { + $test_count = 55; + $quota_checks = 0; + } else { $test_count = 69; }tests/fs_filesystem/btrfs new file +1
-0@@ -0,0 +1 @@ +.tests/fs_filesystem/test +6
-1@@ -92,6 +92,12 @@ BEGIN { $test_count = 54; $quota_checks = 0; } + + # BTRFS uses internal quotas requiring no security hooks + elsif ( $fs_type eq "btrfs" ) { + $test_count = 54; + $quota_checks = 0; + } else { $test_count = 68; } --2.51.0
Paul Moore
maintainerQuoted 28 lines · Stephen Smalley
Quoted 26 lines · Stephen Smalley
Quoted 9 lines · Stephen Smalley
From: Richard Haines <[email protected]>
This allows btrfs filesystems to be created to support the filesystem mount(2) type calls and the
fs_filesystemfsmount(2) type calls.Signed-off-by Richard Haines <[email protected]>Signed-off-by Stephen Smalley <[email protected]>FYI, these tests pass cleanly for me on a current kernel.
Quoted 12 lines
--- README.md | 2 ++ defconfig | 5 +++++ tests/Makefile | 2 +- tests/filesystem/Filesystem.pm | 3 +++ tests/filesystem/btrfs | 1 + tests/filesystem/test | 6 ++++++ tests/fs_filesystem/btrfs | 1 + tests/fs_filesystem/test | 6 ++++++ 8 files changed, 25 insertions(+), 1 deletion(-) create mode 120000 tests/filesystem/btrfs create mode 120000 tests/fs_filesystem/btrfs
...
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
tests/filesystem/Filesystem.pm +0
-0@@ -123,6 +123,9 @@ sub attach_dev { sub make_fs { my ( $mk_type, $mk_dev, $mk_dir, $mk_opts ) = @_;
Quoted 8 lines
Quoted 3 lines
tests/filesystem/Filesystem.pm sub attach_dev { · line 127
Quoted 3 lines
tests/filesystem/Filesystem.pm +2
-0my $mk_size = 16; + if ( $mk_type eq "btrfs" ) { + $mk_size = 300;Looks like I could drop this down to 109 if we care. 109M == 114294784 bytes is the smallest supported size reported by mkfs.btrfs. I don't know how stable that value remains across different versions or how it was derived.
I'd be worried about tests failing at some point in the future if they are running right at the limit. Did you find 300 to be problematic in some way, e.g. excessively slow?
Assuming the exact number is arbitrary, as long as the minimum is met, we could always make it a little smaller while keeping it to a power of two, e.g. 128.
Signature · 1 line
paul-moore.com
Stephen Smalley
maintainerQuoted 50 lines · Paul Moore
Quoted 28 lines · Stephen Smalley
Quoted 26 lines · Stephen Smalley
Quoted 9 lines · Stephen Smalley
From: Richard Haines <[email protected]>
This allows btrfs filesystems to be created to support the filesystem mount(2) type calls and the
fs_filesystemfsmount(2) type calls.Signed-off-by Richard Haines <[email protected]>Signed-off-by Stephen Smalley <[email protected]>FYI, these tests pass cleanly for me on a current kernel.
Quoted 12 lines
--- README.md | 2 ++ defconfig | 5 +++++ tests/Makefile | 2 +- tests/filesystem/Filesystem.pm | 3 +++ tests/filesystem/btrfs | 1 + tests/filesystem/test | 6 ++++++ tests/fs_filesystem/btrfs | 1 + tests/fs_filesystem/test | 6 ++++++ 8 files changed, 25 insertions(+), 1 deletion(-) create mode 120000 tests/filesystem/btrfs create mode 120000 tests/fs_filesystem/btrfs...
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
tests/filesystem/Filesystem.pm +0
-0@@ -123,6 +123,9 @@ sub attach_dev { sub make_fs { my ( $mk_type, $mk_dev, $mk_dir, $mk_opts ) = @_;Quoted 8 lines
Quoted 3 lines
tests/filesystem/Filesystem.pm sub attach_dev { · line 127
Quoted 3 lines
tests/filesystem/Filesystem.pm +2
-0my $mk_size = 16; + if ( $mk_type eq "btrfs" ) { + $mk_size = 300;Looks like I could drop this down to 109 if we care. 109M == 114294784 bytes is the smallest supported size reported by mkfs.btrfs. I don't know how stable that value remains across different versions or how it was derived.
Quoted 3 lines
I'd be worried about tests failing at some point in the future if they are running right at the limit. Did you find 300 to be problematic in some way, e.g. excessively slow?
No, it wasn't excessively slow as far as I noticed - no more so than usual. 300M is the min size for xfs so I just reused it here.
Quoted 3 lines
Assuming the exact number is arbitrary, as long as the minimum is met, we could always make it a little smaller while keeping it to a power of two, e.g. 128.
Yep, can make it that too if desired.
Quoted 3 lines
--
paul-moore.com
Paul Moore
maintainerQuoted 7 lines · Stephen Smalley
Quoted 6 lines · Paul Moore
Quoted 4 lines · Stephen Smalley
Quoted 2 lines · Stephen Smalley
On Tue, Oct 7, 2025 at 2:37 PM Stephen Smalley
<[email protected]> wrote:
...
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 10 lines
tests/filesystem/Filesystem.pm sub attach_dev { · line 127
Quoted 10 lines
tests/filesystem/Filesystem.pm +2
-0@@ -123,6 +123,9 @@ sub attach_dev { sub make_fs { my ( $mk_type, $mk_dev, $mk_dir, $mk_opts ) = @_; my $mk_size = 16; + if ( $mk_type eq "btrfs" ) { + $mk_size = 300;Looks like I could drop this down to 109 if we care. 109M == 114294784 bytes is the smallest supported size reported by mkfs.btrfs. I don't know how stable that value remains across different versions or how it was derived.
Quoted 6 lines
Quoted 3 lines
I'd be worried about tests failing at some point in the future if they are running right at the limit. Did you find 300 to be problematic in some way, e.g. excessively slow?
No, it wasn't excessively slow as far as I noticed - no more so than usual. 300M is the min size for xfs so I just reused it here.
As long as it's not a problem, I've got no real preference. If there is some way to simplify the test code by adopting a common lowest acceptable fs fize that would probably be worthwhile, but I wouldn't bother too much with that.
Ultimately this is up to Ondrej if/when he sees this patch again.
Quoted 5 lines
Quoted 3 lines
Assuming the exact number is arbitrary, as long as the minimum is met, we could always make it a little smaller while keeping it to a power of two, e.g. 128.
Yep, can make it that too if desired.
Signature · 1 line
paul-moore.com
Paul Moore
maintainerQuoted 21 lines · Stephen Smalley
From: Richard Haines <[email protected]>
This allows btrfs filesystems to be created to support the filesystem mount(2) type calls and the
fs_filesystemfsmount(2) type calls.Signed-off-by Richard Haines <[email protected]>Signed-off-by Stephen Smalley <[email protected]>--- README.md | 2 ++ defconfig | 5 +++++ tests/Makefile | 2 +- tests/filesystem/Filesystem.pm | 3 +++ tests/filesystem/btrfs | 1 + tests/filesystem/test | 6 ++++++ tests/fs_filesystem/btrfs | 1 + tests/fs_filesystem/test | 6 ++++++ 8 files changed, 25 insertions(+), 1 deletion(-) create mode 120000 tests/filesystem/btrfs create mode 120000 tests/fs_filesystem/btrfs
...
tests/filesystem/btrfs line 1
Quoted 8 lines
tests/filesystem/btrfs new file +1
-0@@ -0,0 +1 @@ +.
This, and the similar file below, look odd to me. I only looked very quickly, but I don't see any references to these files in the rest of this patchset, is their inclusion in this patch a mistake, or am I missing something?
Quoted 8 lines
tests/fs_filesystem/btrfs new file +1
-0@@ -0,0 +1 @@ +.
Signature · 1 line
paul-moore.com
Stephen Smalley
maintainerQuoted 27 lines · Paul Moore
Quoted 21 lines · Stephen Smalley
From: Richard Haines <[email protected]>
This allows btrfs filesystems to be created to support the filesystem mount(2) type calls and the
fs_filesystemfsmount(2) type calls.Signed-off-by Richard Haines <[email protected]>Signed-off-by Stephen Smalley <[email protected]>--- README.md | 2 ++ defconfig | 5 +++++ tests/Makefile | 2 +- tests/filesystem/Filesystem.pm | 3 +++ tests/filesystem/btrfs | 1 + tests/filesystem/test | 6 ++++++ tests/fs_filesystem/btrfs | 1 + tests/fs_filesystem/test | 6 ++++++ 8 files changed, 25 insertions(+), 1 deletion(-) create mode 120000 tests/filesystem/btrfs create mode 120000 tests/fs_filesystem/btrfs...
Quoted 13 lines
tests/filesystem/btrfs line 1
Quoted 8 lines
tests/filesystem/btrfs new file +1
-0@@ -0,0 +1 @@ +.This, and the similar file below, look odd to me. I only looked very quickly, but I don't see any references to these files in the rest of this patchset, is their inclusion in this patch a mistake, or am I missing something?
These are symlinks - they just look strange in a patch file. Each tested filesystem type has a corresponding symlink in the directory that refers to the current directory and gets used to invoke the test script with a path that indicates the filesystem type. It's been like that for the other filesystem types for a long time.
Quoted 12 lines
tests/fs_filesystem/btrfs line 1
Quoted 9 lines
tests/fs_filesystem/btrfs new file +1
-0@@ -0,0 +1 @@ +.--
paul-moore.com
Paul Moore
maintainerQuoted 41 lines · Stephen Smalley
Quoted 26 lines · Paul Moore
Quoted 21 lines · Stephen Smalley
From: Richard Haines <[email protected]>
This allows btrfs filesystems to be created to support the filesystem mount(2) type calls and the
fs_filesystemfsmount(2) type calls.Signed-off-by Richard Haines <[email protected]>Signed-off-by Stephen Smalley <[email protected]>--- README.md | 2 ++ defconfig | 5 +++++ tests/Makefile | 2 +- tests/filesystem/Filesystem.pm | 3 +++ tests/filesystem/btrfs | 1 + tests/filesystem/test | 6 ++++++ tests/fs_filesystem/btrfs | 1 + tests/fs_filesystem/test | 6 ++++++ 8 files changed, 25 insertions(+), 1 deletion(-) create mode 120000 tests/filesystem/btrfs create mode 120000 tests/fs_filesystem/btrfs...
Quoted 13 lines
tests/filesystem/btrfs line 1
Quoted 8 lines
tests/filesystem/btrfs new file +1
-0@@ -0,0 +1 @@ +.This, and the similar file below, look odd to me. I only looked very quickly, but I don't see any references to these files in the rest of this patchset, is their inclusion in this patch a mistake, or am I missing something?
Quoted 5 lines
These are symlinks - they just look strange in a patch file. Each tested filesystem type has a corresponding symlink in the directory that refers to the current directory and gets used to invoke the test script with a path that indicates the filesystem type. It's been like that for the other filesystem types for a long time.
Ah ha! Yes, I'm aware of the symlinks, I just never noticed one in a diff before, or if I did I forgot :) Sorry for the noise.
Signature · 1 line
paul-moore.com