From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEE1DC282DD for ; Thu, 9 Jan 2020 15:07:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C0B6206ED for ; Thu, 9 Jan 2020 15:07:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=btinternet.com header.i=@btinternet.com header.b="uCdYAzEh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732173AbgAIPHQ (ORCPT ); Thu, 9 Jan 2020 10:07:16 -0500 Received: from mailomta29-re.btinternet.com ([213.120.69.122]:23957 "EHLO re-prd-fep-044.btinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730987AbgAIPHQ (ORCPT ); Thu, 9 Jan 2020 10:07:16 -0500 Received: from re-prd-rgout-001.btmx-prd.synchronoss.net ([10.2.54.4]) by re-prd-fep-044.btinternet.com with ESMTP id <20200109150713.NBTD18275.re-prd-fep-044.btinternet.com@re-prd-rgout-001.btmx-prd.synchronoss.net>; Thu, 9 Jan 2020 15:07:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=btinternet.com; s=btmx201904; t=1578582433; bh=cEtWJZhQeNrs4qFvP34hm0JR7WtZ4sqG3aTyU3LfV0Q=; h=From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version; b=uCdYAzEhOsHweb9JTHpSe+kLqrwvTwse1cWEvZTICuPKkugXx8kg9HsCtXIz7gSXvs90/Qp2mbjlVBJi0PflI/ukJP5rKvcIKifW1Cu+CO1BkgJjgIaNGVk+JCriBTrAn9oc2+RVpVTiHekNWGylCsHHwWXbx5sCr0WH6G8kKJ+va1akpA5oNy7oU6PbHgkv2/Akx0jtxbcilqdEc2E+b+iAdjr8avPhsnw9KJbrLpLcN6VY31F0o1txycPY8Z3Tg+H476WiKet7mN07cOTSkJHslRvq3s99COLUpg/ymbg9/4DwpNq26JhF+9Q9jjUEEuVdCPPNhU6Ge1i2uSIjfQ== Authentication-Results: btinternet.com; auth=pass (PLAIN) smtp.auth=richard_c_haines@btinternet.com X-Originating-IP: [86.134.6.185] X-OWM-Source-IP: 86.134.6.185 (GB) X-OWM-Env-Sender: richard_c_haines@btinternet.com X-VadeSecure-score: verdict=clean score=0/300, class=clean X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedufedrvdeiuddgfeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuueftkffvkffujffvgffngfevqffopdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeftihgthhgrrhguucfjrghinhgvshcuoehrihgthhgrrhgupggtpghhrghinhgvshessghtihhnthgvrhhnvghtrdgtohhmqeenucfkphepkeeirddufeegrdeirddukeehnecurfgrrhgrmhephhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhinhgvthepkeeirddufeegrdeirddukeehpdhmrghilhhfrhhomhepoehrihgthhgrrhgupggtpghhrghinhgvshessghtihhnthgvrhhnvghtrdgtohhmqedprhgtphhtthhopeeoohhmohhsnhgrtggvsehrvgguhhgrthdrtghomheqpdhrtghpthhtohepoehrihgthhgrrhgupggtpghhrghinhgvshessghtihhnthgvrhhnvghtrdgtohhmqecuqfftvefrvfeprhhftgekvddvnehrihgthhgrrhgupggtpghhrghinhgvshessghtihhnthgvrhhnvghtrdgtohhmpdhrtghpthhtohepoehsvghlihhnuhigsehvghgvrhdrkhgvrhhnvghlrdhorhhgqeenucevlhhushhtvghrufhiiigvpedt X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from localhost.localdomain (86.134.6.185) by re-prd-rgout-001.btmx-prd.synchronoss.net (5.8.337) (authenticated as richard_c_haines@btinternet.com) id 5DEE078D05495A2A; Thu, 9 Jan 2020 15:07:13 +0000 From: Richard Haines To: selinux@vger.kernel.org Cc: omosnace@redhat.com, Richard Haines Subject: [PATCH V2 0/1] selinux-testsuite: Add filesystem tests Date: Thu, 9 Jan 2020 15:07:07 +0000 Message-Id: <20200109150709.360345-1-richard_c_haines@btinternet.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org 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). V2 Changes: 1) If udisks(8) daemon is running, stop then restart after tests. The tests run faster and stops the annoying habit of adding mounts to the 'files' app on the desktop. Supports /usr/bin/systemctl or /usr/sbin/service More importantly it stops interferance with the '*context=' tests as it can cause intermittent failures. Tested by running 'test' in a continuous loop with udisks enabled, and then again disabled. Loop 200 times, with udisks failed between 1 to 70 iterations, without udisks, no failures. 2) Add "#define QFMT_VFS_V0 2" to quotas_test.c to fix a RHEL/CentOS 7 and below build issue. 3) Build new file context based on the original in create_file_change_context.c 4) Use "runcon `id -Z` quotacheck ..." to resolve RHEL-6 test run issue. 5) Fix free() contexts in create_file_change_context.c and check_mount_context.c 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 }') 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 | 125 +++ tests/filesystem/create_file.c | 79 ++ tests/filesystem/create_file_change_context.c | 146 +++ 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 | 143 +++ tests/filesystem/statfs_test.c | 65 ++ tests/filesystem/test | 882 ++++++++++++++++++ tests/filesystem/umount.c | 84 ++ 18 files changed, 2311 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.24.1