Bug 575991 - SELinux preventing virt-manager from launching a VM with host USB device attached
Summary: SELinux preventing virt-manager from launching a VM with host USB device atta...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 13
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Daniel Walsh
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-03-22 22:16 UTC by Adam Williamson
Modified: 2010-03-25 22:29 UTC (History)
4 users (show)

Fixed In Version: selinux-policy-3.7.15-4.fc13
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-03-25 22:29:55 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Adam Williamson 2010-03-22 22:16:38 UTC
As discussed with Cole on IRC, in current F13, virt-manager cannot launch a VM with a host USB device attached to it, if SELinux is set to enforcing. Cole pointed out there's an sebool for this - virt_use_usb - but system-config-selinux shows that bool already checked.

The denial messages from /var/log/messages:

Mar 22 11:21:38 adam kernel: type=1400 audit(1269282098.531:28800): avc:  denied  { read } for  pid=3531 comm="qemu-kvm" name="usb1" dev=sysfs ino=9533 scontext=system_u:system_r:svirt_t:s0:c397,c889 tcontext=system_u:object_r:sysfs_t:s0 tclass=lnk_file
Mar 22 11:21:38 adam kernel: type=1400 audit(1269282098.531:28801): avc:  denied  { read } for  pid=3531 comm="qemu-kvm" name="devnum" dev=sysfs ino=9523 scontext=system_u:system_r:svirt_t:s0:c397,c889 tcontext=system_u:object_r:sysfs_t:s0 tclass=file
Mar 22 11:21:38 adam kernel: type=1400 audit(1269282098.531:28802): avc:  denied  { open } for  pid=3531 comm="qemu-kvm" name="devnum" dev=sysfs ino=9523 scontext=system_u:system_r:svirt_t:s0:c397,c889 tcontext=system_u:object_r:sysfs_t:s0 tclass=file
Mar 22 11:21:38 adam kernel: type=1400 audit(1269282098.531:28803): avc:  denied  { getattr } for  pid=3531 comm="qemu-kvm" path="/sys/devices/pci0000:00/0000:00:1a.7/usb1/devnum" dev=sysfs ino=9523 scontext=system_u:system_r:svirt_t:s0:c397,c889 tcontext=system_u:object_r:sysfs_t:s0 tclass=file
Mar 22 11:21:38 adam kernel: type=1400 audit(1269282098.537:28804): avc:  denied  { read write } for  pid=3531 comm="qemu-kvm" name="002" dev=devtmpfs ino=223009 scontext=system_u:system_r:svirt_t:s0:c397,c889 tcontext=system_u:object_r:svirt_image_t:s0:c397,c889 tclass=chr_file
Mar 22 11:21:38 adam kernel: type=1400 audit(1269282098.537:28805): avc:  denied  { open } for  pid=3531 comm="qemu-kvm" name="002" dev=devtmpfs ino=223009 scontext=system_u:system_r:svirt_t:s0:c397,c889 tcontext=system_u:object_r:svirt_image_t:s0:c397,c889 tclass=chr_file

http://fpaste.org/qAU6/

Comment 1 Daniel Walsh 2010-03-23 11:54:22 UTC
You need virt_use_sysfs for some of these.

svirt_image_t:chr_file access fixed in 

Fixed in selinux-policy-3.7.15-4.fc13.noarch

Miroslav, these fixes need to be back ported into F12.

Comment 2 Miroslav Grepl 2010-03-23 12:34:36 UTC
Fixed in selinux-policy-3.6.32-106.fc12

Comment 3 Fedora Update System 2010-03-23 13:33:25 UTC
selinux-policy-3.7.15-4.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/selinux-policy-3.7.15-4.fc13

Comment 4 Adam Williamson 2010-03-23 21:35:31 UTC
"You need virt_use_sysfs for some of these."

I would argue, in that case, that virt_use_usb should imply virt_use_sysfs, or something similar. The description of virt_use_usb just says "Allow virt to use usb devices"; it seems fairly reasonable for the user to think that enabling virt_use_usb is what is necessary to use USB devices in libvirt. It's something of a large leap of intuition to realize you should also enable virt_use_sysfs .

Do you agree? If so, who should I report that to?

I'll test the update soon.



-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers

Comment 5 Fedora Update System 2010-03-24 00:47:35 UTC
selinux-policy-3.7.15-4.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update selinux-policy'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/selinux-policy-3.7.15-4.fc13

Comment 6 Adam Williamson 2010-03-24 02:18:47 UTC
Oddly, after installing this update and a few others and rebooting, I couldn't get the VM to see the USB device at all, whatever I set SELinux to. I'll try it again later and see if it was just a one-off.

Comment 7 Daniel Walsh 2010-03-24 12:55:47 UTC
I actually would like to get rid of the virt_use booleans since one or both of these came into being before the kernel/libvirt supported labeling on usb/sysfs.

Comment 8 Daniel Walsh 2010-03-24 12:56:10 UTC
Daniel, What do you think?

Comment 9 Adam Williamson 2010-03-24 15:38:10 UTC
after a reboot, I'm able to see the host USB device in the VM even with selinux set to enforcing, if both bools are checked. If I uncheck the sysfs bool and restart libvirtd, the VM starts up but does not see the host USB device.



-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers

Comment 10 Daniel Walsh 2010-03-24 15:57:35 UTC
Ok I am going to eliminate virt_use_sysfs

And add the access to virt_use_usb, since this is what the admin would suspect.

unable_policy(`virt_use_usb',`
	dev_rw_usbfs(svirt_t)
	dev_read_sysfs(svirt_t)
	fs_manage_dos_dirs(svirt_t)
	fs_manage_dos_files(svirt_t)
')

So the question, I have is whether we still need 	dev_rw_usbfs(svirt_t)?

Which allows the confined virtual machine to read/write files on usbfs and usbdevfs.

Comment 11 Daniel Berrangé 2010-03-24 16:06:23 UTC
libvirt will explicitly label all USB devices with the MCS label associated with the VM, so I agree there should be no need to allow blanket access to host USB devices any more. The file we label is /dev/usb/NNN/MMM for the matching bus/dev addr.

We do the similar for PCI devices, but this time in sysfs.

Comment 12 Daniel Walsh 2010-03-24 16:44:45 UTC
Fixed in selinux-policy-3.7.16-1.fc13.noarch

Comment 13 Fedora Update System 2010-03-25 22:29:18 UTC
selinux-policy-3.7.15-4.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.