public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: test if systemd-sysctl can read files under /proc/sys/ directory
@ 2026-09-11 13:19 Milos Malik
0 siblings, 0 replies; only message in thread
From: Milos Malik @ 2026-09-11 13:19 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : tests/selinux
Branch : pr775-checkpolicy-revdeps
Commit : aa575878d40cc219215c0b9ed32e1b9ed1920e51
Author : Milos Malik <mmalik@redhat.com>
Date : 2022-02-23T10:31:50+01:00
Stats : +152/-0 in 4 file(s)
URL : https://src.fedoraproject.org/tests/selinux/c/aa575878d40cc219215c0b9ed32e1b9ed1920e51?branch=pr775-checkpolicy-revdeps
Log:
test if systemd-sysctl can read files under /proc/sys/ directory
Recent systemd-sysctl testing revealed that the systemd-sysctl process
wants to read certain files located under /proc/sys/ directory, but
SELinux denies that access. The TC reproduces the situation.
Because the systemd-sysctl service is executed by default during each
reboot, I believe that SELinux policy should allow the service to
work successfully. The TC looks for appropriate policy rules and file
context patterns.
The TC covers BZ#2056207 and BZ#2056999.
---
diff --git a/selinux-policy/systemd-sysctl-and-similar/Makefile b/selinux-policy/systemd-sysctl-and-similar/Makefile
new file mode 100644
index 0000000..5b5981e
--- /dev/null
+++ b/selinux-policy/systemd-sysctl-and-similar/Makefile
@@ -0,0 +1,69 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Makefile of /CoreOS/selinux-policy/Regression/systemd-sysctl-and-similar
+# Description: Does the systemd-sysctl work correctly under SELinux confinement?
+# Author: Milos Malik <mmalik@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2022 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+export TEST=/CoreOS/selinux-policy/Regression/systemd-sysctl-and-similar
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(METADATA) runtest.sh Makefile PURPOSE
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+ ./runtest.sh
+
+build: $(BUILT_FILES)
+ test -x runtest.sh || chmod a+x runtest.sh
+ test -x runtest.sh || chcon -t bin_t runtest.sh
+
+clean:
+ rm -f *~ $(BUILT_FILES)
+
+include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+ @echo "Owner: Milos Malik <mmalik@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "Description: Does the systemd-sysctl work correctly under SELinux confinement?" >> $(METADATA)
+ @echo "Type: Regression" >> $(METADATA)
+ @echo "TestTime: 10m" >> $(METADATA)
+ @echo "RunFor: selinux-policy" >> $(METADATA)
+ @echo "RunFor: systemd" >> $(METADATA)
+ @echo "Requires: audit libselinux-utils policycoreutils selinux-policy setools-console systemd /usr/sbin/service" >> $(METADATA)
+ @echo "RhtsRequires: library(selinux-policy/common)" >> $(METADATA)
+ @echo "Priority: Normal" >> $(METADATA)
+ @echo "License: GPLv2+" >> $(METADATA)
+ @echo "Confidential: no" >> $(METADATA)
+ @echo "Destructive: no" >> $(METADATA)
+ @echo "Environment: AVC_ERROR=+no_avc_check" >> $(METADATA)
+ @echo "Releases: -RHEL4 -RHEL6 -RHEL7 -RHELClient5 -RHELServer5" >> $(METADATA)
+ @echo "Bug: 2056207" >> $(METADATA) # Fedora 36
+ @echo "Bug: 2056999" >> $(METADATA) # RHEL-9
+
+ rhts-lint $(METADATA)
+
diff --git a/selinux-policy/systemd-sysctl-and-similar/PURPOSE b/selinux-policy/systemd-sysctl-and-similar/PURPOSE
new file mode 100644
index 0000000..6660acb
--- /dev/null
+++ b/selinux-policy/systemd-sysctl-and-similar/PURPOSE
@@ -0,0 +1,5 @@
+PURPOSE of /CoreOS/selinux-policy/Regression/systemd-sysctl-and-similar
+Author: Milos Malik <mmalik@redhat.com>
+
+Does the systemd-sysctl work correctly under SELinux confinement?
+
diff --git a/selinux-policy/systemd-sysctl-and-similar/main.fmf b/selinux-policy/systemd-sysctl-and-similar/main.fmf
new file mode 100644
index 0000000..88d805d
--- /dev/null
+++ b/selinux-policy/systemd-sysctl-and-similar/main.fmf
@@ -0,0 +1,2 @@
+path: /selinux-policy/systemd-sysctl-and-similar
+tier: 2
diff --git a/selinux-policy/systemd-sysctl-and-similar/runtest.sh b/selinux-policy/systemd-sysctl-and-similar/runtest.sh
new file mode 100755
index 0000000..52ce90c
--- /dev/null
+++ b/selinux-policy/systemd-sysctl-and-similar/runtest.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# runtest.sh of /CoreOS/selinux-policy/Regression/systemd-sysctl-and-similar
+# Description: Does the systemd-sysctl work correctly under SELinux confinement?
+# Author: Milos Malik <mmalik@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2022 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# Include Beaker environment
+. /usr/bin/rhts-environment.sh || exit 1
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+PACKAGE="selinux-policy"
+PROCESS_CONTEXT="systemd_sysctl_t"
+PROCESS_NAME="systemd-sysctl"
+SERVICE_NAME="systemd-sysctl"
+SERVICE_PACKAGE="systemd"
+
+rlJournalStart
+ rlPhaseStartSetup
+ rlRun "rlImport 'selinux-policy/common'"
+ rlSESatisfyRequires
+ rlAssertRpm ${PACKAGE}
+ rlAssertRpm ${PACKAGE}-targeted
+ rlAssertRpm ${SERVICE_PACKAGE}
+
+ rlServiceStop ${SERVICE_NAME}
+
+ rlSESetEnforce
+ rlSEStatus
+ rlSESetTimestamp
+ sleep 2
+ rlPhaseEnd
+
+ rlPhaseStartTest "bz#2056207 + bz#2056999"
+ rlSEMatchPathCon "/usr/lib/systemd/systemd-sysctl" "systemd_sysctl_exec_t"
+ rlRun "ls -Z /proc/sys/fs/suid_dumpable | grep :proc_security_t"
+ rlRun "ls -Z /proc/sys/fs/protected_hardlinks | grep :proc_security_t"
+ rlRun "ls -Z /proc/sys/fs/protected_symlinks | grep :proc_security_t"
+ rlRun "ls -Z /proc/sys/kernel/kptr_restrict | grep :proc_security_t"
+ rlSESearchRule "allow systemd_sysctl_t proc_security_t : file { read } [ ]"
+ rlPhaseEnd
+
+ rlPhaseStartTest "real scenario"
+ rlSEService - ${SERVICE_NAME} - ${PROCESS_CONTEXT} "start status" 1
+ rlRun "restorecon -Rv /run /var" 0-255
+ rlSEService - ${SERVICE_NAME} - ${PROCESS_CONTEXT} "restart status stop status" 1
+ rlPhaseEnd
+
+ rlPhaseStartCleanup
+ sleep 2
+ rlSECheckAVC
+ rlServiceRestore ${SERVICE_NAME}
+ rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd
+
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-11 13:19 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:19 [tests/selinux] pr775-checkpolicy-revdeps: test if systemd-sysctl can read files under /proc/sys/ directory Milos Malik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox