Bug 1191802
Summary: | security labels are changed for virtlocked disks | ||||||
---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Yang Yang <yanyang> | ||||
Component: | libvirt | Assignee: | Ján Tomko <jtomko> | ||||
Status: | CLOSED DUPLICATE | QA Contact: | Virtualization Bugs <virt-bugs> | ||||
Severity: | medium | Docs Contact: | |||||
Priority: | medium | ||||||
Version: | 7.1 | CC: | dyuan, hhan, jtomko, mzhan, rbalakri, xuzhang, yafu, yisun, zhwang | ||||
Target Milestone: | rc | ||||||
Target Release: | --- | ||||||
Hardware: | x86_64 | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2016-02-11 09:28:45 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: | |||||||
Attachments: |
|
Description
Yang Yang
2015-02-12 02:52:12 UTC
Created attachment 990726 [details]
/var/log/libvirt/qemu/vm3.log
After 1st guest os booted, start 2nd vm. It will cause 1st guest os crash. The real problem is that the svirt label of image file is erased after 2nd vm startup failed. # getenforce Enforcing # virsh start vm3 Domain vm3 started # ll /var/lib/libvirt/images/vm1.raw -Z -rw-r--r--. qemu qemu system_u:object_r:svirt_image_t:s0:c555,c775 /var/lib/libvirt/images/vm1.raw # virsh start vm5 error: Failed to start domain vm5 error: resource busy Lockspace resource '19c1987e09bfe9af2a7f2756b19460f5750e147333b2e36854479915ce44a19c' is locked # ll /var/lib/libvirt/images/vm1.raw -Z -rw-r--r--. root root system_u:object_r:virt_image_t:s0 /var/lib/libvirt/images/vm1.raw Libvirt needs to set the SELinux labels before starting QEMU. The disks need to be locked after forking the process for the domain, because the PID is needed to lock it. This could be solved by adding two more steps of handshake before running QEMU, but that won't solve migration on shared storage that supports NFS. The cause of this bug is the ownership changed from qemu:qemu to root:root by libvirtd after the second guest start failure due to lock. It's about ownership change not selinux label change. If a guest created by virt-manager, its disk image mode bits is 600 and ownership is root:root. When the first guest starts, the disk image ownership is change to qemu:qemu by libvirtd to make it accessible to qemu-kvm. When the second guest starts failed, we detect that libvirtd change the disk image ownership to root:root. Qemu-kvm cannot access it and the first guest shows disk 'hd0,msdos1' not found. If we change mode bits to 606, the problem disappears. But it's not so secure. Though we can setfacl to qemu user with read&write, but it is a little complex and not supported in NFS. So I suggest that libvirtd should not change the ownership when start failed due to lock. Virtlockd's purpose is to protect the disk content from simultaneous writes by different VMs. https://www.redhat.com/archives/libvir-list/2016-January/msg01104.html Not changing the disk image's ownership and labels is the security driver's responsibility. *** This bug has been marked as a duplicate of bug 547546 *** |