selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Smalley <stephen.smalley.work@gmail.com>
To: selinux@vger.kernel.org
Cc: paul@paul-moore.com, omosnace@redhat.com,
	Richard Haines <richard_c_haines@btinternet.com>,
	Stephen Smalley <stephen.smalley.work@gmail.com>
Subject: [PATCH v3] selinux-testsuite: Add btrfs support for filesystem tests
Date: Tue,  7 Oct 2025 14:35:53 -0400	[thread overview]
Message-ID: <20251007183552.74330-2-stephen.smalley.work@gmail.com> (raw)

From: Richard Haines <richard_c_haines@btinternet.com>

This allows btrfs filesystems to be created to support the
filesystem mount(2) type calls and the fs_filesystem fsmount(2)
type calls.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
---
 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

diff --git a/README.md b/README.md
index f067eeb..973028e 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/defconfig b/defconfig
index b2d4a90..214eb26 100644
--- a/defconfig
+++ b/defconfig
@@ -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
diff --git a/tests/Makefile b/tests/Makefile
index 903ab11..f002389 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -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
 
diff --git a/tests/filesystem/Filesystem.pm b/tests/filesystem/Filesystem.pm
index f169464..7ea9031 100644
--- a/tests/filesystem/Filesystem.pm
+++ b/tests/filesystem/Filesystem.pm
@@ -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;
     }
diff --git a/tests/filesystem/btrfs b/tests/filesystem/btrfs
new file mode 120000
index 0000000..945c9b4
--- /dev/null
+++ b/tests/filesystem/btrfs
@@ -0,0 +1 @@
+.
\ No newline at end of file
diff --git a/tests/filesystem/test b/tests/filesystem/test
index a7d8b24..56f116a 100755
--- a/tests/filesystem/test
+++ b/tests/filesystem/test
@@ -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;
     }
diff --git a/tests/fs_filesystem/btrfs b/tests/fs_filesystem/btrfs
new file mode 120000
index 0000000..945c9b4
--- /dev/null
+++ b/tests/fs_filesystem/btrfs
@@ -0,0 +1 @@
+.
\ No newline at end of file
diff --git a/tests/fs_filesystem/test b/tests/fs_filesystem/test
index 9af8971..1d04bbc 100755
--- a/tests/fs_filesystem/test
+++ b/tests/fs_filesystem/test
@@ -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


             reply	other threads:[~2025-10-07 18:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07 18:35 Stephen Smalley [this message]
2025-10-07 18:46 ` [PATCH v3] selinux-testsuite: Add btrfs support for filesystem tests Stephen Smalley
2025-10-07 19:14   ` Stephen Smalley
2025-10-07 19:33     ` Paul Moore
2025-10-07 19:50       ` Stephen Smalley
2025-10-07 19:59         ` Paul Moore
2025-10-07 19:28 ` Paul Moore
2025-10-07 19:47   ` Stephen Smalley
2025-10-07 19:56     ` Paul Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251007183552.74330-2-stephen.smalley.work@gmail.com \
    --to=stephen.smalley.work@gmail.com \
    --cc=omosnace@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=richard_c_haines@btinternet.com \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).