Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be unavailable on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 593739 - Need to set socket context before connecting to QEMU monitor for SELinux MLS policy
Summary: Need to set socket context before connecting to QEMU monitor for SELinux MLS ...
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.0
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Daniel Berrangé
QA Contact: Virtualization Bugs
Depends On:
TreeView+ depends on / blocked
Reported: 2010-05-19 15:31 UTC by Daniel Berrangé
Modified: 2010-11-11 14:48 UTC (History)
6 users (show)

Fixed In Version: libvirt-0_8_1-8_el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-11-11 14:48:25 UTC
Target Upstream Version:

Attachments (Terms of Use)
Set socket context before connecting to monitor (752 bytes, patch)
2010-05-19 15:50 UTC, Daniel Berrangé
no flags Details | Diff
Set socket context before connecting to monitor (9.93 KB, patch)
2010-05-20 09:57 UTC, Daniel Berrangé
no flags Details | Diff

Description Daniel Berrangé 2010-05-19 15:31:11 UTC
Description of problem:
The libvirtd daemon normally runs with a context like


In an MLS environment a guest might run with a context


When connecting to the QEMU monitor, the libvirtd end of the UNIX domain socket currently inherits libvirt's labelling


whereas it needs to get a context matching the MLS level of the guest. To achieve this, libvirt needs to do some extra magic:

  setsockcreatecon("system_u:system_r:virtd_t:[MLS PORTION]");
  connect to KVM/QEMU

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Unknown
Actual results:

Expected results:

Additional info:

Comment 1 RHEL Program Management 2010-05-19 15:35:29 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for

Comment 2 Daniel Berrangé 2010-05-19 15:50:58 UTC
Created attachment 415168 [details]
Set socket context before connecting to monitor

Comment 4 Daniel Berrangé 2010-05-20 09:57:21 UTC
Created attachment 415373 [details]
Set socket context before connecting to monitor

Comment 6 Dave Allan 2010-06-10 21:30:14 UTC
libvirt-0_8_1-8_el6 has been built in RHEL-6-candidate with the fix.


Comment 8 Osier Yang 2010-07-09 11:53:57 UTC
[root@dhcp-66-65-163 SOURCES]# ps -efZ | grep libvirtd | grep -v grep
unconfined_u:system_r:virtd_t:s0-s0:c0.c1023 root 15716 1  0 18:56 ?   00:00:02 libvirtd --daemon

[root@dhcp-66-65-163 SOURCES]# ps -efZ | grep toy-f1
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 root 16546 13872  0 19:56 pts/1 00:00:00 grep toy-f1
system_u:system_r:svirt_t:s0:c431,c903 qemu 24011  1  1 Jun28 ?        04:45:53 /usr/libexec/qemu-kvm -S -M rhel6.0.0 -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name toy-f1 -uuid f9debf17-b8b5-a889-ec3f-47a0f5f723ae -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/toy-f1.monitor,server,nowait -mon chardev=monitor,mode=control -rtc base=utc -boot c -drive file=/var/lib/libvirt/migrate/toy.img,if=none,id=drive-ide0-0-0,boot=on,format=raw -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -netdev tap,fd=21,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:61:92:bc,bus=pci.0,addr=0x4 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -vnc -k en-us -vga cirrus -device AC97,id=sound0,bus=pci.0,addr=0x5 -device ES1370,id=sound1,bus=pci.0,addr=0x6 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3

[root@dhcp-66-65-163 SOURCES]# ls /var/lib/libvirt/qemu/toy-f1.monitor -lZ
srwxr-xr-x. qemu qemu system_u:object_r:svirt_var_run_t:s0:c431,c903 /var/lib/libvirt/qemu/toy-f1.monitor

as we can see the MLS portion of the Unix domain socket of monitor is same as the process of running the guest.


- Osier

Comment 9 releng-rhel@redhat.com 2010-11-11 14:48:25 UTC
Red Hat Enterprise Linux 6.0 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.

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