Bug 999922

Summary: Policy denies libvirtd the permission to relabel unix domain sockets
Product: Red Hat Enterprise Linux 6 Reporter: Daniel Berrangé <berrange>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED CURRENTRELEASE QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.5CC: dwalsh, mmalik
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 999926 (view as bug list) Environment:
Last Closed: 2013-10-30 09:46:26 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:
Bug Depends On:    
Bug Blocks: 999292    

Description Daniel Berrangé 2013-08-22 11:25:59 UTC
Description of problem:
With the virDomainOpenGraphics() API, a client app running unconfined creates a UNIX domain socket (using socketpair()). These socket FDs are label unconfined. It then passes one of these sockets to libvirtd using virDomainOpenGraphics, which passes the socket onto QEMU.

Before passing the socket to QEMU, libvirt must relabel it to svirt_image_t to allow QEMU the ability to use the socket - otherwise it gets silently dropped by sendmsg/recvmsg with an AVC

type=AVC msg=audit(1377167900.795:1188): avc:  denied  { getattr } for  pid=6642 comm="qemu-system-x86" scontext=unconfined_u:system_r:svirt_t:s0:c264,c560 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=unix_stream_socket

The fix to make libvirtd do this relabelling is tracked in bug 999914.

When I fix it to do relabelling though, libvirtd itself now triggers an AVC

type=AVC msg=audit(1377168984.442:1190): avc:  denied  { relabelto } for  pid=3521 comm="lt-libvirtd" name="UNIX" dev="sockfs" ino=879718 scontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:svirt_image_t:s0:c264,c560 tclass=unix_stream_socket


IIUC, the problem is the virt.te policy has the following rule

allow virtd_t self:unix_stream_socket { connectto create_stream_socket_perms };

whereas I believe it should be

allow virtd_t self:unix_stream_socket { relabelto connectto create_stream_socket_perms };





Version-Release number of selected component (if applicable):
selinux-policy-3.7.19-211

How reproducible:
Always

Comment 2 Miroslav Grepl 2013-08-23 11:46:22 UTC
Could you re-test it with

https://brewweb.devel.redhat.com/buildinfo?buildID=291782

Comment 3 Miroslav Grepl 2013-10-30 09:46:26 UTC
More fixes have been added during RHEL6.5 cycle related to libvirt and this bug should be fixed. If no, please re-open the bug and it will be addressed in RHEL6.6.