Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.

Bug 999925

Summary: libvirtd is not relabelling the FD from virDomainOpenGraphics
Product: Red Hat Enterprise Linux 7 Reporter: Daniel Berrange <berrange>
Component: libvirtAssignee: Daniel Berrange <berrange>
Status: CLOSED DUPLICATE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: berrange, codong, dyuan, jdenemar, jtomko, lcui, rbalakri, ydu, zhwang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 999914 Environment:
Last Closed: 2014-09-18 06:03:29 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On: 999926    
Bug Blocks: 999291    

Description Daniel Berrange 2013-08-22 07:28:07 EDT
+++ This bug was initially created as a clone of Bug #999914 +++

Description of problem:
When virt-viewer attempts to run virDomainOpenGraphics, strace shows sendmsg() sending the FD, but QEMU never gets it with recvmsg(). THis leads to this error


2013-08-22 10:02:48.263+0000: 11573: debug : virDomainOpenGraphics:21172 : dom=0x1283e10, (VM: name=demo, uuid=62e2a27e-2f92-5545-2c8e-38b2cec76487), idx=0, fd=15, flags=1
(virt-viewer:11573): virt-viewer-DEBUG: Error internal error: unable to execute QEMU command 'getfd': No file descriptor supplied via SCM_RIGHTS


The problem is that the FD libvirt gets is from an unconfined app. It passes this onto QEMU, which will be forbidden to access it. Libvirt needs to relabel it to the svirt image label to allow QEMU access.


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

How reproducible:
Always

Steps to Reproduce:
1. virt-viewer -c qemu:///session --debug --attach guestname
2.
3.

Actual results:
See the error message
(virt-viewer:11573): virt-viewer-DEBUG: Error internal error: unable to execute QEMU command 'getfd': No file descriptor supplied via SCM_RIGHTS

Expected results:
virDomainOpenGraphics completes without error

Additional info:
Comment 2 Daniel Berrange 2013-08-27 12:07:29 EDT
commit b6b94374b3bf6b44633ee99a68868141b6cd9ed8
Author: Daniel P. Berrange <berrange@redhat.com>
Date:   Thu Aug 22 12:38:26 2013 +0100

    Set security label on FD for virDomainOpenGraphics
Comment 5 yanbing du 2013-09-02 01:53:19 EDT
Reproduce this problem with libvirt-1.1.1-2.el7.x86_64:
# virt-viewer -c qemu:///session --debug --attach $guestname
...
(virt-viewer:21706): virt-viewer-DEBUG: Error internal error: unable to execute QEMU command 'getfd': No file descriptor supplied via SCM_RIGHTS
...


When update libvirt to libvirt-1.1.1-3.el7.x86_64, when start virt-viwer, it will get a permission deny error:
# getenforce 
Enforcing

# virt-viewer -c qemu:///session --debug --attach $guestname
...
(virt-viewer:22496): virt-viewer-DEBUG: Error unable to set security context 'system_u:object_r:svirt_image_t:s0:c680,c863' on fd 24: Permission denied
...

in libvirtd.log:
...
2013-09-02 03:47:39.972+0000: 22362: error : virSecuritySELinuxFSetFilecon:975 : unable to set security context 'system_u:object_r:svirt_image_t:s0:c680,c863' on fd 24: Permission denied
...

And there's a avc message in audit.log:
type=AVC msg=audit(1378100765.320:30206): avc:  denied  { relabelto } for  pid=22361 comm="libvirtd" name="UNIX" dev="sockfs" ino=488466 scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:svirt_image_t:s0:c680,c863 tclass=unix_stream_socket

If set selinux to 'Permissive', the error will gone.
Comment 6 Daniel Berrange 2013-09-02 05:01:56 EDT
See bug 999926 for the selinux fix.
Comment 7 yanbing du 2013-09-02 05:35:24 EDT
(In reply to Daniel Berrange from comment #6)
> See bug 999926 for the selinux fix.

Thanks for your quickly reply.
bug 999926 fix in selinux-policy-3.12.1-73.el7, but i update selinux-policy and restart guest, the permission deny error still there. Please help to confirm this, thanks very much.
Comment 8 Daniel Berrange 2013-09-02 05:43:28 EDT
If you are still getting an AVC, then please provide an update on the selinux bug rather than this one. The AVC you list in comment #5 is the one the selinux bug is supposed to fix.
Comment 9 yanbing du 2013-09-02 06:27:06 EDT
(In reply to Daniel Berrange from comment #8)
> If you are still getting an AVC, then please provide an update on the
> selinux bug rather than this one. The AVC you list in comment #5 is the one
> the selinux bug is supposed to fix.

Okay, thanks.
I will re-test this bug when get feedback from bug 999926.
Comment 11 yanbing du 2013-11-19 04:16:32 EST
Blocked by bug 999926.
Comment 15 Ján Tomko 2014-09-18 06:03:29 EDT

*** This bug has been marked as a duplicate of bug 999926 ***