public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: test if logwatch scripts can check files in /run/netns
@ 2026-09-11 13:23 Milos Malik
  0 siblings, 0 replies; only message in thread
From: Milos Malik @ 2026-09-11 13:23 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 4df7f3f7162314d809fc3e636eb045b88000d9d1
            Author : Milos Malik <mmalik@redhat.com>
            Date   : 2026-03-31T11:29:17+00:00
            Stats  : +18/-1 in 3 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/4df7f3f7162314d809fc3e636eb045b88000d9d1?branch=pr775-checkpolicy-revdeps

            Log:
            test if logwatch scripts can check files in /run/netns

Recent logwatch + selinux-policy testing revealed that SELinux
prevents one of the logwatch scripts from checking files labeled
nsfs_t located under /run/netns directory. The TC reproduces the
situation.

In order to support the 'df' command functionality (executed by
one of the scripts, syscall = newfstatat), I believe that SELinux
policy should allow this access. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-160896 and RHEL-160897.

---
diff --git a/selinux-policy/logwatch-and-similar/Makefile b/selinux-policy/logwatch-and-similar/Makefile
index 2c3dd3b..3292741 100644
--- a/selinux-policy/logwatch-and-similar/Makefile
+++ b/selinux-policy/logwatch-and-similar/Makefile
@@ -54,7 +54,7 @@ $(METADATA): Makefile
 	@echo "Type:            Regression" >> $(METADATA)
 	@echo "TestTime:        15m" >> $(METADATA)
 	@echo "RunFor:          selinux-policy" >> $(METADATA)
-	@echo "Requires:        audit libselinux libselinux-utils policycoreutils selinux-policy selinux-policy-targeted setools-console logwatch sendmail /usr/sbin/service" >> $(METADATA)
+	@echo "Requires:        audit libselinux libselinux-utils policycoreutils selinux-policy selinux-policy-targeted setools-console logwatch sendmail /usr/sbin/service iproute" >> $(METADATA)
 	@echo "RhtsRequires:    library(selinux-policy/common)" >> $(METADATA)
 	@echo "Environment:     AVC_ERROR=+no_avc_check" >> $(METADATA)
 	@echo "Priority:        Normal" >> $(METADATA)
@@ -65,6 +65,8 @@ $(METADATA): Makefile
 	@echo "Bug:             2183432" >> $(METADATA) # Fedora 38
 	@echo "Bug:             2270484" >> $(METADATA) # Fedora 40
 	@echo "Bug:             RHEL-34135" >> $(METADATA) # RHEL-9
+	@echo "Bug:             RHEL-160896" >> $(METADATA) # RHEL-9
+	@echo "Bug:             RHEL-160897" >> $(METADATA) # RHEL-10
 
 	rhts-lint $(METADATA)
 

diff --git a/selinux-policy/logwatch-and-similar/main.fmf b/selinux-policy/logwatch-and-similar/main.fmf
index 4be331b..d4d765a 100644
--- a/selinux-policy/logwatch-and-similar/main.fmf
+++ b/selinux-policy/logwatch-and-similar/main.fmf
@@ -18,6 +18,7 @@ recommend:
   - logwatch
   - sendmail
   - /usr/sbin/service
+  - iproute
 environment:
     AVC_ERROR: +no_avc_check
 duration: 15m
@@ -35,6 +36,8 @@ link:
   - verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2183432
   - verifies: https://issues.redhat.com/browse/RHEL-34135
   - verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2270484
+  - verifies: https://issues.redhat.com/browse/RHEL-160896
+  - verifies: https://issues.redhat.com/browse/RHEL-160897
 adjust+:
   - enabled: false
     when: distro == rhel-4, rhel-5, rhel-6, rhel-7, rhel-8, centos-stream-8

diff --git a/selinux-policy/logwatch-and-similar/runtest.sh b/selinux-policy/logwatch-and-similar/runtest.sh
index a7dadf8..2c06f96 100755
--- a/selinux-policy/logwatch-and-similar/runtest.sh
+++ b/selinux-policy/logwatch-and-similar/runtest.sh
@@ -74,9 +74,19 @@ rlJournalStart
     rlPhaseEnd
     fi
 
+    if rlIsRHEL '>= 9.8' || rlIsRHEL '>= 10.2' ; then
+    rlPhaseStartTest "RHEL-160896 + RHEL-160897"
+        rlSESearchRule "allow logwatch_t nsfs_t : file { getattr } [ ]"
+    rlPhaseEnd
+    fi
+
     if [ -f /usr/lib/systemd/system/${SERVICE_NAME}.service ] ; then
     rlPhaseStartTest "real scenario -- standalone service"
         rlRun "mkdir -p /var/cache/logwatch"
+        NS_NAME="test-ns-${RANDOM}"
+        rlRun "ip netns add ${NS_NAME}"
+        rlRun "ip netns list | grep ${NS_NAME}"
+        rlRun "ls -lZ /run/netns/ | grep :nsfs_t"
         if ! rlSEDefined ${PROCESS_CONTEXT} ; then
             # for environments where the SELinux domain does not exist yet
             PROCESS_CONTEXT="unconfined_service_t"
@@ -84,6 +94,8 @@ rlJournalStart
         rlSEService - ${SERVICE_NAME} - ${PROCESS_CONTEXT} "start status" 1
         rlRun "restorecon -Rv /etc /var /run -e /var/ARTIFACTS" 0-255
         rlSEService - ${SERVICE_NAME} - ${PROCESS_CONTEXT} "restart status stop status" 1
+        rlRun "ip netns del ${NS_NAME}"
+        rlRun "ip netns list | grep ${NS_NAME}" 1
     rlPhaseEnd
     fi
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-11 13:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 13:23 [tests/selinux] pr775-checkpolicy-revdeps: test if logwatch scripts can check files in /run/netns Milos Malik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox