These tests should cover all the areas in selinux/hooks.c that touch the 'filesystem' class. Each hooks.c function is listed in the 'test' script as there are some permissions that are checked in multiple places. Tested on Fedora 31 and Rawhide (5.5 for the new watch perm). To test fanotify fs watch perm on 5.5+: 1) Build the testsuite policy first: make -C policy load 2) Add the following CIL statements to watch.cil and install: semodule -i watch.cil (common filesystem (watch)) (classcommon filesystem filesystem) (allow test_filesystem_t self(filesystem (watch))) ; Until 'fs_watch_all_fs(test_filesystem_t)' in Policy use: (allow test_filesystem_t fs_t (filesystem (watch))) ; Required if notify policy enabled ;(allow test_filesystem_t self (dir (watch_sb))) 3) Edit /usr/share/selinux/devel/include/support/all_perms.spt and insert the 'watch' permission at: define(`all_filesystem_perms',`{ mount remount ..... watch }') Changes from RFC Patch: 1) Rename mount to filesystem as it is testing the fs permissions 2) Add tests for context=, rootcontext=, fscontext= and defcontext= 3) Add setfscreatecon(3) tests 4) Add tests to build fanotify on 5.5 and travis (not tested) Richard Haines (1): selinux-testsuite: Add filesystem tests defconfig | 6 + policy/Makefile | 4 + policy/test_filesystem.te | 324 +++++++ tests/Makefile | 7 + tests/filesystem/.gitignore | 11 + tests/filesystem/Makefile | 16 + tests/filesystem/check_file_context.c | 75 ++ tests/filesystem/check_mount_context.c | 109 +++ tests/filesystem/create_file.c | 79 ++ tests/filesystem/create_file_change_context.c | 143 +++ tests/filesystem/fanotify_fs.c | 79 ++ tests/filesystem/fs_relabel.c | 72 ++ tests/filesystem/grim_reaper.c | 63 ++ tests/filesystem/mount.c | 130 +++ tests/filesystem/quotas_test.c | 134 +++ tests/filesystem/statfs_test.c | 65 ++ tests/filesystem/test | 830 ++++++++++++++++++ tests/filesystem/umount.c | 84 ++ 18 files changed, 2231 insertions(+) create mode 100644 policy/test_filesystem.te create mode 100644 tests/filesystem/.gitignore create mode 100644 tests/filesystem/Makefile create mode 100644 tests/filesystem/check_file_context.c create mode 100644 tests/filesystem/check_mount_context.c create mode 100644 tests/filesystem/create_file.c create mode 100644 tests/filesystem/create_file_change_context.c create mode 100644 tests/filesystem/fanotify_fs.c create mode 100644 tests/filesystem/fs_relabel.c create mode 100644 tests/filesystem/grim_reaper.c create mode 100644 tests/filesystem/mount.c create mode 100644 tests/filesystem/quotas_test.c create mode 100644 tests/filesystem/statfs_test.c create mode 100755 tests/filesystem/test create mode 100644 tests/filesystem/umount.c -- 2.23.0