Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1843873

Summary: MLS policy doesn't get applied on boot
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: policycoreutilsAssignee: Petr Lautrbach <plautrba>
Status: CLOSED NOTABUG QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.2CC: dwalsh, lvrabec, mmalik, plautrba, ssekidde, vmojzis
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-06-24 09:39:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2020-06-04 11:03:13 UTC
Description of problem:

This is a continuation of BZ #1843870.
Switching the system from Targeted to MLS by editing /etc/selinux/config, executing "fixfiles -B onboot" and booting with "enforcing=0" doesn't apply the policy correctly.

During relabeling, we see a lot of invalid labels (for MLS policy point of view) being untouched:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
[    9.461243] SELinux:  Context system_u:object_r:rhsmcertd_config_t:s0 is not valid (left unmapped).
[    9.467703] SELinux:  Context system_u:object_r:fwupd_cert_t:s0 is not valid (left unmapped).
[    9.480796] SELinux:  Context unconfined_u:object_r:system_conf_t:s0 is not valid (left unmapped).
[    9.498028] SELinux:  Context system_u:object_r:rhnsd_conf_t:s0 is not valid (left unmapped).
[    9.514821] SELinux:  Context unconfined_u:object_r:file_context_t:s0 is not valid (left unmapped).
...
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

After relabeling and boot with "enforcing=0" again (otherwise system isn't usable), "restorecon -Frnv /" command shows tons of files that have not been relabeled:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# restorecon -Frvn / > restorecon.out
# grep "exec_t" restorecon.out
[...]
Would relabel /usr/sbin/rasdaemon from system_u:object_r:rasdaemon_exec_t:s0 to system_u:object_r:bin_t:s0
Would relabel /usr/sbin/kpatch from system_u:object_r:kpatch_exec_t:s0 to system_u:object_r:bin_t:s0
Would relabel /usr/sbin/spice-vdagentd from system_u:object_r:vdagent_exec_t:s0 to system_u:object_r:bin_t:s0
Would relabel /usr/sbin/blkmapd from system_u:object_r:blkmapd_exec_t:s0 to system_u:object_r:bin_t:s0
Would relabel /usr/lib/realmd/realmd from system_u:object_r:realmd_exec_t:s0 to system_u:object_r:lib_t:s0
[...]
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Hence, to apply the MLS policy, the admin must apply "restorecon -Frv /" on the system while booting in Permissive mode.


Version-Release number of selected component (if applicable):

policycoreutils-2.9-9.el8.x86_64


How reproducible:

Always

Steps to Reproduce:
1. Install selinux-policy-mls package
2. Edit /etc/selinux/config and move to "mls"
3. Edit /etc/selinux/config and change to Permissive
4. Execute "fixfiles -B onboot"
5. Reboot

Comment 1 Petr Lautrbach 2020-06-04 11:14:22 UTC
(In reply to Renaud Métrich from comment #0)

> 4. Execute "fixfiles -B onboot"

You should execute:

# fixfiles -F onboot

Comment 2 Renaud Métrich 2020-06-04 11:23:55 UTC
Sorry, possible I made typos while reproducing.
But this also reproduces with a "touch /.autorelabel" and reboot.

I will double check anyway

Comment 3 Renaud Métrich 2020-06-04 11:27:20 UTC
I can confirm this doesn't change anything at all.

Comment 4 Petr Lautrbach 2020-06-04 11:32:04 UTC
"touch /.autorelabel" would not help, you need to push -F inside the file:

"fixfiles -F onboot" is equivalent to "echo -n '-F ' > /.autorelabel"

Comment 5 Renaud Métrich 2020-06-04 11:49:02 UTC
Indeed "fixfiles -F onboot" helps here.