RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
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 ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.0
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Daniel Berrangé
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
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:
Environment:
Last Closed: 2010-11-11 14:48:25 UTC
Target Upstream Version:
Embargoed:


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

  unconfined_u:system_r:virtd_t:s0-s0:c0.c1023

In an MLS environment a guest might run with a context

  system_u:system_r:svirt_t:s0:c1 

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

  virtd_t:s0-s0:c0.c1023

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
  setsockcreatecon("");



Version-Release number of selected component (if applicable):
0.8.1-1.el6

How reproducible:


Steps to Reproduce:
1. Unknown
2.
3.
  
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
inclusion.

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.

Dave

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 127.0.0.1:3 -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.

verified.

- 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.