Bug 609279 - qemu_t denies access to xserver_t, makes libvirt + SDL difficult
Summary: qemu_t denies access to xserver_t, makes libvirt + SDL difficult
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-06-29 20:21 UTC by Cole Robinson
Modified: 2016-05-11 18:30 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-04-10 13:38:03 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Cole Robinson 2010-06-29 20:21:42 UTC
This might not even be a bug, but I'm trying to figure somethings out here. I edit /etc/libvirt/qemu.conf to disable svirt, and run the qemu process as my regular user/group 'cole'. I configure SDL for graphics. The qemu command line looks like this (notice XAUTHORITY and DISPLAY at the beginning):

LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin XAUTHORITY=/home/cole/.Xauthority DISPLAY=:0.0 /usr/bin/qemu-kvm -S -M fedora-13 -enable-kvm -m 2048 -smp 1,sockets=1,cores=1,threads=1 -name livecd -uuid 813d0054-5d06-6fd2-64de-a4eff945eb6e -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/livecd.monitor,server,nowait -mon chardev=monitor,mode=readline -rtc base=utc -boot d -drive file=/var/lib/libvirt/images/livecd-disk.img,if=none,id=drive-ide0-0-0,format=raw -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/mnt/data/media/F13-Beta-x86_64-Live.iso,if=none,media=cdrom,id=drive-ide0-1-0 -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -device rtl8139,vlan=0,id=net0,mac=52:54:00:69:40:43,bus=pci.0,addr=0x4 -net tap,fd=40,vlan=0,name=hostnet0 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -sdl -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3

Guest startup fails with:

char device redirected to /dev/pts/3
Could not initialize SDL - exiting

tail -f audit.log shows:

ype=SYSCALL msg=audit(1277840560.933:35246): arch=c000003e syscall=16 success=yes exit=128 a0=27 a1=89a2 a2=7f067a1f8cb0 a3=7f067a1f8a30 items=0 ppid=1 pid=24658 auid=500 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4 comm="libvirtd" exe="/usr/sbin/libvirtd" subj=unconfined_u:system_r:virtd_t:s0-s0:c0.c1023 key=(null)
type=AVC msg=audit(1277840560.998:35247): avc:  denied  { connectto } for  pid=24716 comm="qemu-kvm" path=002F746D702F2E5831312D756E69782F5830 scontext=unconfined_u:system_r:qemu_t:s0-s0:c0.c1023 tcontext=system_u:system_r:xserver_t:s0-s0:c0.c1023 tclass=unix_stream_socket
type=SYSCALL msg=audit(1277840560.998:35247): arch=c000003e syscall=42 success=yes exit=128 a0=d a1=7fffdcd50490 a2=14 a3=7fffdcd50493 items=0 ppid=1 pid=24716 auid=500 uid=500 gid=500 euid=500 suid=500 fsuid=500 egid=500 sgid=500 fsgid=500 tty=(none) ses=4 comm="qemu-kvm" exe="/usr/bin/qemu-kvm" subj=unconfined_u:system_r:qemu_t:s0-s0:c0.c1023 key=(null)
type=AVC msg=audit(1277840560.999:35248): avc:  denied  { connectto } for  pid=24716 comm="qemu-kvm" path=002F746D702F2E5831312D756E69782F5830 scontext=unconfined_u:system_r:qemu_t:s0-s0:c0.c1023 tcontext=system_u:system_r:xserver_t:s0-s0:c0.c1023 tclass=unix_stream_socket
type=SYSCALL msg=audit(1277840560.999:35248): arch=c000003e syscall=42 success=yes exit=128 a0=d a1=7fffdcd50470 a2=14 a3=7fffdcd50473 items=0 ppid=1 pid=24716 auid=500 uid=500 gid=500 euid=500 suid=500 fsuid=500 egid=500 sgid=500 fsgid=500 tty=(none) ses=4 comm="qemu-kvm" exe="/usr/bin/qemu-kvm" subj=unconfined_u:system_r:qemu_t:s0-s0:c0.c1023 key=(null)


Enabling svirt yeilds similar results. 'setenforce 0' fixes things, guest acts normal. Running the manual command:

qemu-kvm -sdl

works fine. So, my question is, if svirt disabled and libvirt is running qemu as my user, what's the selinux difference between libvirt launching a VM and me launching a VM manually with qemu-kvm?

Comment 1 Cole Robinson 2010-06-29 20:24:50 UTC
Changed title: SDL and libvirt have never played well together, so it's not like this is a regression or urgent issue.

Comment 2 Daniel Berrangé 2010-06-30 10:37:44 UTC
sVirt provides isolation between guests and between the host & guests. With sVirt disabled, you still have the traditional isolation between the hosts & guests. 

We really don't want to change the policy to allow QEMU access to the X server. IIRC this kind of access was leveraged in a Xen QEMU security exploit in the past.

This is exposing one of the limitations of our current sVirt capabilities. For most areas of the VM config we can give access by labelling files in the correct way, but some things like granting xserver access would require new policy extensions. This perhaps suggests that we need to build an svirt_$myguest_t for each guest to give access to just the bits required for this one guest, or have a set of pre-defined targets svirt_t, svirt_with_xserver_t, etc

Comment 3 Cole Robinson 2010-06-30 14:40:52 UTC
Just for my own edification, why does manually launching qemu-kvm -sdl work fine then? Shouldn't that be constrained by the default selinux policy? How does selinux lock down other SDL using apps?

Comment 4 Daniel Walsh 2010-07-13 15:24:06 UTC
We are only doing svirt from libvirt.  unconfined_t running qemu runs it in an unconfined domains,  If you run from libvirt you get a confined domain.

Comment 5 Bug Zapper 2011-06-01 15:13:47 UTC
This message is a reminder that Fedora 13 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 13.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '13'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 13's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 13 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 6 Cole Robinson 2011-06-07 15:58:24 UTC
Pretty sure still relevant for f15

Comment 7 Martin Wilck 2012-04-10 10:05:07 UTC
AFAICS, "setsebool virt_use_xserver=1" can now be used to work around this problem, so it can be closed.

Comment 8 Cole Robinson 2012-04-10 13:38:03 UTC
Sounds good, closing.


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