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.
Description of problem:
When upgrading to the RHEL7.3 selinux-policy (along with its corresponding updates to libsemanage 2.5 and policycoreutils 2.5) files are relabelled without taking into account the rules from custom policy modules.
Version-Release number of selected component (if applicable):
libsemanage-2.5-3.el7
policycoreutils-2.5-5.1.el7
selinux-policy-3.13.1-82.el7
selinux-policy-targeted-3.13.1-82.el7
How reproducible:
with some difficulty
Steps to Reproduce:
1. Write a custom policy module with file context rules for /var/lib/something
2. On RHEL7.2, semodule -i <policy>
3. Upgrade to libsemanage-2.5-3.el7, policycoreutils-2.5-5.1.el7, selinux-policy-3.13.1-82.el7
Actual results:
Files in /var/lib/something have been relabelled ignoring the rules from the custom policy (changed back to var_lib_t).
Expected results:
Labels should not be wrong. File context rules from the custom policy module should still be applied.
Additional info:
Workaround is to restorecon after the yum transaction is complete. This works because at that point, the custom policy module *is* loaded again -- it's just not loaded when fixfiles is invoked in the %post scriptlet for selinux-policy-targeted.
We hit this in Beaker, where the harness (beah) includes a custom policy module. Background info is in bug 1351202. This can be reproduced fairly easily in a Beaker job.
I think this might be related to:
https://github.com/SELinuxProject/selinux/wiki/Policy-Store-Migration
By some very unscientific methods (basically SIGSTOP'ing yum at various points during the upgrade and poking around at what it's doing) I saw that there is a triggerpostun scriptlet for the newer selinux-policy-targeted, which is moving custom policy modules to the new store location:
[...]
for i in `find /etc/selinux/targeted/modules/active/modules/ -name *.pp 2> /dev/null`; do
INSTALL_MODULES="${INSTALL_MODULES} $i"
done
if [ -n "$INSTALL_MODULES" ]; then
semodule -s targeted -X 400 -i $INSTALL_MODULES
fi
[...]
But it seems that this happens *after* the %post scriptlet from selinux-policy-targeted which is running fixfiles -C, to relabel files whose contexts have changed. So the fixfiles invocation is running without custom policy modules installed, therefore it gets the labels wrong.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://rhn.redhat.com/errata/RHBA-2016-2283.html