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 'bootupctl adopt-and-update' works well
Date: Fri, 11 Sep 2026 13:22:24 GMT	[thread overview]
Message-ID: <178913294409.1.13327522448660181790.tests-selinux-d1fffc88e823@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : d1fffc88e8232c24d79895b45f14ad213fee6124
            Author : Milos Malik <mmalik@redhat.com>
            Date   : 2025-02-19T18:32:05+00:00
            Stats  : +71/-10 in 3 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/d1fffc88e8232c24d79895b45f14ad213fee6124?branch=pr775-checkpolicy-revdeps

            Log:
            test if 'bootupctl adopt-and-update' works well

Recent bootupd + bootupctl testing revealed that SELinux prevents
the bootupd processes from the following actions:
 * removal of the /boot/bootupd-state.json file
 * execution of findmnt, mount, udevadm, grub2-install, lsblk commands
 * automatic transition into their SELinux domains

The TC reproduces the situation on EFI configured machines.

In order to support the adopt-and-update feature, I believe that
SELinux policy should allow these actions. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-66584 and RHEL-70849.

---
diff --git a/selinux-policy/bootupd-and-similar/Makefile b/selinux-policy/bootupd-and-similar/Makefile
index c7e9ff5..2134c06 100644
--- a/selinux-policy/bootupd-and-similar/Makefile
+++ b/selinux-policy/bootupd-and-similar/Makefile
@@ -67,6 +67,8 @@ $(METADATA): Makefile
 	@echo "Bug:             2218106" >> $(METADATA) # Fedora rawhide
 	@echo "Bug:             RHEL-36289" >> $(METADATA) # RHEL-9
 	@echo "Bug:             RHEL-39514" >> $(METADATA) # RHEL-10
+	@echo "Bug:             RHEL-66584" >> $(METADATA) # RHEL-9
+	@echo "Bug:             RHEL-70849" >> $(METADATA) # RHEL-9
 
 	rhts-lint $(METADATA)
 

diff --git a/selinux-policy/bootupd-and-similar/main.fmf b/selinux-policy/bootupd-and-similar/main.fmf
index 54fa5e9..ef081b1 100644
--- a/selinux-policy/bootupd-and-similar/main.fmf
+++ b/selinux-policy/bootupd-and-similar/main.fmf
@@ -38,6 +38,8 @@ link:
   - verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2218106
   - verifies: https://issues.redhat.com/browse/RHEL-36289
   - verifies: https://issues.redhat.com/browse/RHEL-39514
+  - verifies: https://issues.redhat.com/browse/RHEL-66584
+  - verifies: https://issues.redhat.com/browse/RHEL-70849
 adjust:
   - enabled: false
     when: distro == rhel-4, rhel-5, rhel-6, rhel-7, rhel-8, centos-stream-8

diff --git a/selinux-policy/bootupd-and-similar/runtest.sh b/selinux-policy/bootupd-and-similar/runtest.sh
index 7746e1a..73e5322 100755
--- a/selinux-policy/bootupd-and-similar/runtest.sh
+++ b/selinux-policy/bootupd-and-similar/runtest.sh
@@ -32,7 +32,11 @@
 PACKAGE="selinux-policy"
 FILE_PATH="/usr/libexec/bootupd"
 SERVICE_PACKAGE="bootupd"
-SERVICE_NAME="bootupd"
+if rlIsFedora ; then
+    SERVICE_NAME="bootloader-update"
+else
+    SERVICE_NAME="bootupd"
+fi
 PROCESS_NAME="bootupd"
 if seinfo -t | grep -q bootupd ; then
     FILE_CONTEXT="bootupd_exec_t"
@@ -70,37 +74,82 @@ rlJournalStart
 
     rlPhaseStartTest "bz#2218106"
         rlSEMatchPathCon "/usr/libexec/bootupd" "${FILE_CONTEXT}"
-        rlRun "ls -RlZ /boot/efi"
+        if [ -d /boot/efi ] ; then
+            rlRun "ls -aRlZ /boot/efi"
+        fi
         rlSESearchRule "allow ${PROCESS_CONTEXT} dosfs_t : dir { getattr search } [ ]"
     rlPhaseEnd
 
     rlPhaseStartTest "RHEL-36289 + RHEL-39514"
         rlSEMatchPathCon "/usr/libexec/bootupd" "${FILE_CONTEXT}"
         if [ -d /sys/firmware/efi/efivars ] ; then
-            rlRun "ls -RlZ /sys/firmware/efi/efivars"
+            rlRun "ls -aRlZ /sys/firmware/efi/efivars"
         fi
         rlSESearchRule "allow ${PROCESS_CONTEXT} efivarfs_t : dir { getattr search } [ ]"
     rlPhaseEnd
 
-    if [ -f /usr/lib/systemd/system/bootupd.service ] ; then
+    if rlSEDefined "bootupd_t" ; then
+    rlPhaseStartTest "RHEL-66584"
+        rlSEMatchPathCon "/boot/bootupd-state.json" "boot_t"
+        rlSESearchRule "allow bootupd_t boot_t : dir { write remove_name } [ ]"
+        rlSESearchRule "allow bootupd_t boot_t : file { unlink } [ ]"
+        rlSESearchRule "allow bootupd_t dosfs_t : dir { search } [ ]"
+        rlSESearchRule "allow bootupd_t dosfs_t : file { open } [ ]"
+    rlPhaseEnd
+
+    rlPhaseStartTest "RHEL-70849"
+        rlSEMatchPathCon "/usr/bin/findmnt" "bin_t"
+        rlSEMatchPathCon "/usr/bin/lsblk" "bin_t"
+        rlSEMatchPathCon "/usr/bin/udevadm" "udev_exec_t"
+        rlSEMatchPathCon "/usr/bin/mount" "mount_exec_t"
+        rlSEMatchPathCon "/usr/sbin/grub2-install" "bootloader_exec_t"
+        rlSESearchRule "allow bootupd_t fixed_disk_device_t : blk_file { getattr } [ ]"
+        rlSESearchRule "allow bootupd_t bin_t : file { execute execute_no_trans map } [ ]"
+        rlSESearchRule "allow bootupd_t sysfs_t : dir { read } [ ]"
+        rlSESearchRule "allow bootupd_t sysfs_t : file { getattr open read } [ ]"
+        rlSESearchRule "allow bootupd_t sysfs_t : lnk_file { read } [ ]"
+        rlSESearchRule "allow bootupd_t cert_t : dir { getattr open read search } [ ]"
+        rlSESearchRule "allow bootupd_t cert_t : file { getattr open read } [ ]"
+
+        rlSESearchRule "allow bootupd_t udev_exec_t : file { getattr open read map execute } [ ]"
+        rlSESearchRule "type_transition bootupd_t udev_exec_t : process udev_t"
+        rlSESearchRule "allow bootupd_t udev_t : process { transition } [ ]"
+
+        rlSESearchRule "allow bootupd_t mount_exec_t : file { getattr open read map execute } [ ]"
+        rlSESearchRule "type_transition bootupd_t mount_exec_t : process mount_t"
+        rlSESearchRule "allow bootupd_t mount_t : process { transition } [ ]"
+
+        rlSESearchRule "allow bootupd_t bootloader_exec_t : file { getattr open read map execute } [ ]"
+        rlSESearchRule "type_transition bootupd_t bootloader_exec_t : process bootloader_t"
+        rlSESearchRule "allow bootupd_t bootloader_t : process { transition } [ ]"
+    rlPhaseEnd
+    fi
+
+    if [ -f /usr/lib/systemd/system/${SERVICE_NAME}.service ] ; then
     rlPhaseStartTest "real scenario -- standalone service"
         if ! rlSEDefined ${PROCESS_CONTEXT} ; then
             # for OSes where the SELinux domain does not exist yet
             PROCESS_CONTEXT="unconfined_service_t"
         fi
-        rlRun "systemctl start ${SERVICE_NAME}.socket"
-        rlSEService - ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "start status" 1
-        rlRun "restorecon -Rv /var /run -e /var/ARTIFACTS" 0-255
-        rlSEService - ${SERVICE_NAME} ${PROCESS_NAME} ${PROCESS_CONTEXT} "restart status stop status" 1
-        rlRun "systemctl stop ${SERVICE_NAME}.socket"
+        if [ -f /usr/lib/systemd/system/${SERVICE_NAME}.socket ] ; then
+            rlRun "systemctl start ${SERVICE_NAME}.socket"
+        fi
+        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
+        if [ -f /usr/lib/systemd/system/${SERVICE_NAME}.socket ] ; then
+            rlRun "systemctl stop ${SERVICE_NAME}.socket"
+        fi
     rlPhaseEnd
     fi
 
-    if [ -f /usr/lib/systemd/system/bootupd.socket ] ; then
+    if [ -f /usr/lib/systemd/system/${SERVICE_NAME}.socket ] ; then
     rlPhaseStartTest "real scenario -- ${SERVICE_NAME}.socket"
         rlRun "systemctl enable ${SERVICE_NAME}.socket"
         rlRun "systemctl start ${SERVICE_NAME}.socket"
         sleep 1
+        rlRun "rm -f /boot/bootupd-state.json"
+        rlRun "bootupctl adopt-and-update" 0,1
         rlRun "bootupctl status" 0,1
         rlRun "bootupctl validate" 0,1
         rlRun "lsblk"
@@ -109,6 +158,14 @@ rlJournalStart
     rlPhaseEnd
     fi
 
+    rlPhaseStartTest "real scenario without the service or the socket"
+        rlRun "rm -f /boot/bootupd-state.json"
+        rlRun "bootupctl adopt-and-update" 0,1
+        rlRun "bootupctl status" 0,1
+        rlRun "bootupctl validate" 0,1
+        rlRun "lsblk"
+    rlPhaseEnd
+
     rlPhaseStartCleanup
         sleep 2
         rlSECheckAVC

                 reply	other threads:[~2026-09-11 13:22 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=178913294409.1.13327522448660181790.tests-selinux-d1fffc88e823@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