public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Milos Malik <mmalik@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/selinux] pr775-checkpolicy-revdeps: test if logwatch scripts can check files in /run/netns
Date: Fri, 11 Sep 2026 13:23:39 GMT	[thread overview]
Message-ID: <178913301921.1.4237404769109956755.tests-selinux-4df7f3f71623@fedoraproject.org> (raw)

            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
 

                 reply	other threads:[~2026-09-11 13:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=178913301921.1.4237404769109956755.tests-selinux-4df7f3f71623@fedoraproject.org \
    --to=mmalik@redhat.com \
    --cc=git-commits@fedoraproject.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