Bug 1189275
Summary: | Resuming a block device (dm) changes its selinux context | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Nir Soffer <nsoffer> |
Component: | libvirt | Assignee: | Michal Privoznik <mprivozn> |
Status: | CLOSED ERRATA | QA Contact: | yafu <yafu> |
Severity: | high | Docs Contact: | |
Priority: | high | ||
Version: | 7.0 | CC: | agk, amureini, bazulay, bmarzins, bmr, danken, dwysocha, dyuan, eblake, extras-qa, fsimonce, hannsj_uhl, heinzm, jbrassow, johannbg, jonathan, jsuchane, jsynacek, kay, lmiksik, lnykryn, lpeer, lsurette, lvm-team, maurizio.antillon, mkletzan, mmalik, msekleta, msnitzer, mzhan, nsoffer, prajnoha, prockai, rbalakri, sbonazzo, scohen, srevivo, s, systemd-maint, thornber, vpavlin, xuzhang, yafu, ykaul, zbyszek, zkabelac |
Target Milestone: | pre-dev-freeze | Keywords: | Regression |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | libvirt-3.1.0-1.el7 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | 1147910 | Environment: | |
Last Closed: | 2017-08-01 17:06:41 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: | |||
Bug Depends On: | 1147910, 1265024 | ||
Bug Blocks: | 1122979, 1147923, 1148013, 1359843 |
Description
Nir Soffer
2015-02-04 20:50:09 UTC
This used to work in rhel 6. Undocumented behavior change in udev in rhel7 (and fedora 19) broke this. I'm not sure why is this bug created agains lvm2 - since lvm2 cannot not fix it. Should be likely passed to udev ? (In reply to Zdenek Kabelac from comment #5) > I'm not sure why is this bug created agains lvm2 - since lvm2 cannot not > fix it. > > Should be likely passed to udev ? Sure, this looks like udev bug to me, but I guess it should use the same component of the bug it was cloned from. Moving this to libvirt to make use of the new SECLABEL=value variable (see man ude) that can be set in udev rules and then interpreted by udev to set the exact selinux label needed. If the "value" is configure outside, it needs to be imported to udev with PROGRAM=... rule first. Having a binary that is able to get the current label that the device should have would not be such a big deal. The problem is that libvirtd (or virtlockd) would need to keep track of what the current label should be. And I'm afraid this might be blocked by Bug 547546. But then, the binary could just contact socket-activated virtlockd (for example) and export that label that needs to be set. I'm just wondering how come the seclabel gets changed, but the DAC permissions are kept? Note that the Fedora BZ this was cloned from (Bug 1147910) has several extra comments added after the cloning (32 and beyond) which are useful reading; in particular Dan's comment about the racy nature of udev's selinux labelling (see Bug 798605 for an example of that raciness in action - and that was in a situation when no new udev rules were added / the rule table wasn't reloaded). I think the user/group/mode setting itself is racy in udev - the device nodes are created first in devtmpfs in kernel with defaults and then changed a few moments later when the actual event is processed in userspace and then proper rights set based on udev USER/GROUP/MODE udev rule. So we already have a race there even with setting the usual permissions. *** Bug 1265024 has been marked as a duplicate of this bug. *** I think this bug is the same as bug 13542 D'oh. Somehow part of my message got lost. What I wanted to say is that I think this is the same as bug 1354251. The fix that I am working on right now would therefore fix this one too. This one is fixed now. I mean, as I explained in bug 1147910#c51 the fix as implemented by libvirt is to run qemu in a namespace with a separate /dev mount managed by libvirt. Therefore, udev no longer can mangle security labels for qemu. Some initial work was done in 3.0.0 release, but since this was a feature that touched the very core of libvirt it wasn't properly working until 3.1.0 release. The list of patches that implement the feature (and fix it) is very long, so unless somebody is really interested, I'm not going to paste it here. Reproduced with: libvirt-2.0.0-10.el7_3.9.x86_64 systemd-219-30.el7_3.9.x86_64 Reproduce steps: 1.Add the udev rules in the host os and reboot the host os : # cat /usr/lib/udev/rules.d/96-test-lvm.rules ACTION=="add|change", OWNER:="root", GROUP:="disk" ENV{DM_UUID}!="LVM-?*", GOTO="lvm_end" LABEL="lvm_end" #reboot 2.Start a guest whose os is running on the dm device: #virsh dumpxml rhel7.3-min ... <disk type='block' device='disk'> <driver name='qemu' type='raw'/> <source dev='/dev/dm-2'/> <backingStore/> <target dev='vdd' bus='virtio'/> <boot order='1'/> <alias name='virtio-disk3'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </disk> ... 3.Check the selinux context of the dm device: # ll -Z /dev/dm-2 brw-rw----. qemu qemu system_u:object_r:svirt_image_t:s0:c227,c231 /dev/dm-2 4.Suspend and resume the dm device: #dmsetup suspend /dev/dm-3 #dmsetup resume /dev/dm-3 5.Check the selinux context of the dm device after step 4: # ll -Z /dev/dm-2 brw-rw----. root disk system_u:object_r:fixed_disk_device_t:s0 /dev/dm-2 6.The guest os will crashed since I/O error after step 5. Verified pass with: libvirt-3.2.0-10.el7.x86_64 systemd-219-41.el7.x86_64 Test steps: 1.Repeat step1-2 in the reproduce steps; 2.Check the selinux context of the dm device both in the host os and qemu process namespaces: (1)In the host os: #ll -Z /dev/dm-2 brw-rw----. root disk system_u:object_r:fixed_disk_device_t:s0 /dev/dm-2 (2)In the qemu process namespaces: #lsns | grep -i qemu 4026532507 mnt 1 5356 qemu /usr/libexec/qemu-kvm -name guest=rhel7.3-min,debug-threads=on -S ... # nsenter -t 5356 -m # ll -Z /dev/dm-2 brw-rw----. qemu qemu system_u:object_r:svirt_image_t:s0:c746,c887 /dev/dm-2 3.Suspend and resume the dm device: #dmsetup suspend /dev/dm-3 #dmsetup resume /dev/dm-3 4.Check the selinux context of the dm device both in the host os and qemu process namespaces after step 4: (1)In the host os: #ll -Z /dev/dm-2 brw-rw----. root disk system_u:object_r:fixed_disk_device_t:s0 /dev/dm-2 (2)In the qemu process namespaces: #lsns | grep -i qemu 4026532507 mnt 1 5356 qemu /usr/libexec/qemu-kvm -name guest=rhel7.3-min,debug-threads=on -S ... # nsenter -t 5356 -m # ll -Z /dev/dm-2 brw-rw----. qemu qemu system_u:object_r:svirt_image_t:s0:c746,c887 /dev/dm-2 5.The guest os still running correctly after step 4; According to comment 19, move this bug to verified. 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/RHEA-2017:1846 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/RHEA-2017:1846 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/RHEA-2017:1846 |