selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/1] selinux-testsuite: Add btrfs support for filesystem tests
@ 2020-11-03 11:01 Richard Haines
  2020-11-03 11:01 ` [PATCH V2 1/1] " Richard Haines
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Haines @ 2020-11-03 11:01 UTC (permalink / raw)
  To: selinux; +Cc: Richard Haines

This patch allows BTRFS filesystems to be tested.

The tests/filesystem all pass using './test -f btrfs' on Fedora 33.
The tests/fs_filesystem fail 42 of 57 using './test -f btrfs' on Fedora 33.

These fs_filesystem failures are caused by a bug when using the fsmount(2)
type calls that was reported in [1].

Note btrfs requires a much larger image size (min 115 MiB), and therefore
takes more than 2x longer to run tests than ext4.

[1] https://lore.kernel.org/selinux/c02674c970fa292610402aa866c4068772d9ad4e.camel@btinternet.com/

V2 changes:
1) Add btrfs-progs entries for README and travis.
2) Add CONFIG_BTRFS_FS=y to defconfig.
3) Support testing all valid filesystems.

Richard Haines (1):
  selinux-testsuite: Add btrfs support for filesystem tests

 README.md                      |  3 +++
 defconfig                      |  4 ++++
 tests/Makefile                 |  2 +-
 tests/filesystem/Filesystem.pm | 10 +++++++++-
 tests/filesystem/btrfs         |  1 +
 tests/filesystem/test          |  6 ++++++
 tests/fs_filesystem/btrfs      |  1 +
 tests/fs_filesystem/test       |  6 ++++++
 travis-ci/run-testsuite.sh     |  1 +
 9 files changed, 32 insertions(+), 2 deletions(-)
 create mode 120000 tests/filesystem/btrfs
 create mode 120000 tests/fs_filesystem/btrfs

-- 
2.28.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH V2 1/1] selinux-testsuite: Add btrfs support for filesystem tests
  2020-11-03 11:01 [PATCH V2 0/1] selinux-testsuite: Add btrfs support for filesystem tests Richard Haines
@ 2020-11-03 11:01 ` Richard Haines
  2020-11-04  7:24   ` Ondrej Mosnacek
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Haines @ 2020-11-03 11:01 UTC (permalink / raw)
  To: selinux; +Cc: Richard Haines

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>
---
 README.md                      |  3 +++
 defconfig                      |  4 ++++
 tests/Makefile                 |  2 +-
 tests/filesystem/Filesystem.pm | 10 +++++++++-
 tests/filesystem/btrfs         |  1 +
 tests/filesystem/test          |  6 ++++++
 tests/fs_filesystem/btrfs      |  1 +
 tests/fs_filesystem/test       |  6 ++++++
 travis-ci/run-testsuite.sh     |  1 +
 9 files changed, 32 insertions(+), 2 deletions(-)
 create mode 120000 tests/filesystem/btrfs
 create mode 120000 tests/fs_filesystem/btrfs

diff --git a/README.md b/README.md
index 4a22389..6134270 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 )_
 
 On a modern Fedora system you can install these dependencies with the
@@ -87,6 +88,7 @@ following command (NOTE: On Fedora 32 and below you need to remove
 		e2fsprogs \
 		jfsutils \
 		dosfstools \
+		btrfs-progs \
 		nftables \
 		kernel-devel-$(uname -r) \
 		kernel-modules-$(uname -r)
@@ -134,6 +136,7 @@ command:
 		e2fsprogs \
 		jfsutils \
 		dosfstools \
+		btrfs-progs \
 		nftables
 
 On Debian, you need to build and install netlabel_tools manually since
diff --git a/defconfig b/defconfig
index 46eb673..5a8fb1a 100644
--- a/defconfig
+++ b/defconfig
@@ -117,3 +117,7 @@ CONFIG_VFAT_FS=m
 # They are not required for SELinux operation itself.
 CONFIG_WATCH_QUEUE=y
 CONFIG_KEY_NOTIFICATIONS=y
+
+# Test BTRFS filesystem.
+# This is not required for SELinux operation itself.
+CONFIG_BTRFS_FS=y
diff --git a/tests/Makefile b/tests/Makefile
index b441031..3920380 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 c14e760..55e3d75 100644
--- a/tests/filesystem/Filesystem.pm
+++ b/tests/filesystem/Filesystem.pm
@@ -122,10 +122,18 @@ sub attach_dev {
 
 sub make_fs {
     my ( $mk_type, $mk_dev, $mk_dir ) = @_;
+
+    # BTRFS requires a larger minimum size that takes >2x longer to generate
+    if ( $mk_type eq "btrfs" ) {
+        $count = "28000";
+    }
+    else {
+        $count = "4096";
+    }
     print "Create $mk_dir/fstest with dd\n";
     $result =
       system(
-        "dd if=/dev/zero of=$mk_dir/fstest bs=4096 count=4096 2>/dev/null");
+        "dd if=/dev/zero of=$mk_dir/fstest bs=4096 count=$count 2>/dev/null");
     if ( $result != 0 ) {
         print "dd failed to create $mk_dir/fstest\n";
     }
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 c94deda..dcd4704 100755
--- a/tests/filesystem/test
+++ b/tests/filesystem/test
@@ -78,6 +78,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 e706e42..59f7ea3 100755
--- a/tests/fs_filesystem/test
+++ b/tests/fs_filesystem/test
@@ -81,6 +81,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;
     }
diff --git a/travis-ci/run-testsuite.sh b/travis-ci/run-testsuite.sh
index bd9073c..ed3813f 100755
--- a/travis-ci/run-testsuite.sh
+++ b/travis-ci/run-testsuite.sh
@@ -41,6 +41,7 @@ dnf install -y \
     e2fsprogs \
     jfsutils \
     dosfstools \
+    btrfs-progs \
     kernel-devel-"$(uname -r)" \
     kernel-modules-"$(uname -r)"
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2 1/1] selinux-testsuite: Add btrfs support for filesystem tests
  2020-11-03 11:01 ` [PATCH V2 1/1] " Richard Haines
@ 2020-11-04  7:24   ` Ondrej Mosnacek
  0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Mosnacek @ 2020-11-04  7:24 UTC (permalink / raw)
  To: Richard Haines; +Cc: SElinux list

On Tue, Nov 3, 2020 at 12:02 PM Richard Haines
<richard_c_haines@btinternet.com> wrote:
> 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>
> ---
>  README.md                      |  3 +++
>  defconfig                      |  4 ++++
>  tests/Makefile                 |  2 +-
>  tests/filesystem/Filesystem.pm | 10 +++++++++-
>  tests/filesystem/btrfs         |  1 +
>  tests/filesystem/test          |  6 ++++++
>  tests/fs_filesystem/btrfs      |  1 +
>  tests/fs_filesystem/test       |  6 ++++++
>  travis-ci/run-testsuite.sh     |  1 +
>  9 files changed, 32 insertions(+), 2 deletions(-)
>  create mode 120000 tests/filesystem/btrfs
>  create mode 120000 tests/fs_filesystem/btrfs

Thanks! The patch looks good to me and passes in CI (except the known
bug). However, I'm going to hold off on merging the patch until the
btrfs fsconfig issue is fixed (still working on that). If that doesn't
happen for a long time, I'll consider adding a condition for btrfs to
skip the failing part of the tests and merging it like that.

-- 
Ondrej Mosnacek
Software Engineer, Platform Security - SELinux kernel
Red Hat, Inc.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-04  7:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03 11:01 [PATCH V2 0/1] selinux-testsuite: Add btrfs support for filesystem tests Richard Haines
2020-11-03 11:01 ` [PATCH V2 1/1] " Richard Haines
2020-11-04  7:24   ` Ondrej Mosnacek

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).