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.
I've changed the component to util-linux as the immediate cause is the failure of mkswap when it can't perform a relabel. However, I had a quick look at the selinux related code in mkswap in RHEL 7.4 (fails) and F27 (does not fail) and it doesn't seem very different. Consequently I wouldn't be surprised to find that the actual difference is in libselinux.
For context to the mkswap maintainer, in Openstack Nova, a user can request that a VM is presented with a variety of disks. They have the option to specify that one of these disks is pre-formatted as a swap disk. On the hypervisor, we create a file to contain the disk's data, run mkswap on that file, then attach it to the VM when it starts.
The issue here seems to be that mkswap wants to relabel the file to swapfile_t. This is actually not necessary or desirable in this case, as the hypervisor is never going to try to use it as a swap file; we're just formatting it. When the hypervisor is hosting VM data on NFS, the relabel fails on RHEL 7.4. The impact of this is that the user cannot launch their VM, which is high.
I've also noted that this does not fail on F27. Although mkswap does attempt the relabel, which does fail, mkswap does not exit with an error.
Ideally RHEL 7.4 would gain the same behaviour as F27, which would then just work for us. Alternatively there would be some flag to mkswap to indicate that the relabel behaviour is not required. This would require a patch to OpenStack to use this flag, but it would allow customers to enable the swap behaviour.
The difference between RHEL7 and upstream is
- if (fsetfilecon(DEV, context_string))
+ if (fsetfilecon(ctl.fd, context_string) && errno != ENOTSUP)
The ENOTSUP errno has been added by:
commit d97dc0ee2505e80c8e9fca89aa2001b2ec2c3695
Author: Lubomir Rintel <lkundrak>
Date: Mon Apr 18 09:01:23 2016 +0200
mkswap: tolerate ENOTSUP when failing to relabel
It might be that the underlying filesystem just doesn't support SELinux
labeling. This fixes creating swap on vfat live media:
# livecd-iso-to-disk.sh --msdos --swap-size-mb 666 ...
Signed-off-by: Lubomir Rintel <lkundrak>
I guess we need to backport this patch to RHEL7.
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://access.redhat.com/errata/RHBA-2018:0936