Bug 1337333

Summary: SELinux is preventing qemu-system-x86 from read, write access on the chr_file /dev/dri/renderD128.
Product: [Fedora] Fedora Reporter: Cole Robinson <crobinso>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 24CC: be.0, dominick.grift, dwalsh, jfrieben, jtomko, lantw44, lvrabec, marcandre.lureau, mgrepl, plautrba
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: abrt_hash:4d3881274010d12dcd37510cc98f11d15fadff0866f5947a19c7b028c5c9de7f;VARIANT_ID=workstation;
Fixed In Version: selinux-policy-3.13.1-191.16.fc24 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-08 14:33:38 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Cole Robinson 2016-05-18 21:14:08 UTC
Description of problem:
Using spice GL with usermode libvirt. spice GL support needs access to the /dev/dri render node
SELinux is preventing qemu-system-x86 from read, write access on the chr_file /dev/dri/renderD128.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that qemu-system-x86 should be allowed read write access on the renderD128 chr_file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'qemu-system-x86' --raw | audit2allow -M my-qemusystemx86
# semodule -X 300 -i my-qemusystemx86.pp

Additional Information:
Source Context                unconfined_u:unconfined_r:svirt_t:s0:c112,c716
Target Context                system_u:object_r:dri_device_t:s0
Target Objects                /dev/dri/renderD128 [ chr_file ]
Source                        qemu-system-x86
Source Path                   qemu-system-x86
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-185.fc24.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Permissive
Host Name                     (removed)
Platform                      Linux (removed) 4.5.4-300.fc24.x86_64 #1 SMP Wed
                              May 11 17:57:16 UTC 2016 x86_64 x86_64
Alert Count                   1
First Seen                    2016-05-18 17:10:15 EDT
Last Seen                     2016-05-18 17:10:15 EDT
Local ID                      4e2e089d-142b-4417-b3dd-417356fe5796

Raw Audit Messages
type=AVC msg=audit(1463605815.55:23715): avc:  denied  { read write } for  pid=8036 comm="qemu-system-x86" path="/dev/dri/renderD128" dev="devtmpfs" ino=13523 scontext=unconfined_u:unconfined_r:svirt_t:s0:c112,c716 tcontext=system_u:object_r:dri_device_t:s0 tclass=chr_file permissive=1


Hash: qemu-system-x86,svirt_t,dri_device_t,chr_file,read,write

Version-Release number of selected component:
selinux-policy-3.13.1-185.fc24.noarch

Additional info:
reporter:       libreport-2.7.0
hashmarkername: setroubleshoot
kernel:         4.5.4-300.fc24.x86_64
reproducible:   Not sure how to reproduce the problem
type:           libreport

Comment 1 Cole Robinson 2016-05-18 21:17:37 UTC
Also hits open and ioctl access on that file. And read+open+getattr access on   udev_var_run_t /run/udev/data/+pci:0000:01:00.0  which is my video card, so probably related.

Maybe libvirt svirt 'fixes' this but then again I'm not sure if it's acceptable for libvirt to go out and change labels/permissions on video related bits, since we aren't giving exclusive access to the hw

Comment 2 Joachim Frieben 2016-08-11 08:35:04 UTC
I did not get that far under Fedora 24, because the directive <gl enable='yes'/> was remove by libvirt (?) from the corresponding configuration file whenever I added it.
However, I do observe the same issue (three different alerts suggesting the same change of policiy) under Fedora 25 which was reported as bug 1364075 by the SELinux Troubeshooter utility. After switching to permissive mode, accelerated VirGL 3D is up and running but implementing the policy rule

  ausearch -c 'qemu-system-x86' --raw | audit2allow -M my-qemusystemx86
  semodule -X 300 -i my-qemusystemx86.pp

has -no- effect in my case.

Comment 3 Lukas Vrabec 2016-08-11 10:16:09 UTC
*** Bug 1364075 has been marked as a duplicate of this bug. ***

Comment 4 Fedora Update System 2016-08-16 05:55:33 UTC
selinux-policy-3.13.1-191.11.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-c4630499f5

Comment 5 Joachim Frieben 2016-08-23 17:05:07 UTC
No improvement for selinux-policy-3.13.1-191.12.fc24.

Comment 6 Joachim Frieben 2016-08-29 03:51:23 UTC
As of selinux-policy-3.13.1-191.13.fc24, I do still get notified that

  "SELinux is preventing qemu-system-x86 from read access on the file +pci:0000:01:00.0."

but despite the host running in enforcing mode the virtual machine launched by means of 'virsh start ..' completes start-up successfully and VirGL 3D is enabled and active:

Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Red Hat (0x1af4)
    Device: virgl (0x1010)
    Version: 12.0.1
    Accelerated: yes
    Video memory: 0MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 3.3
    Max compat profile version: 3.0
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL vendor string: Red Hat

Comment 7 Fedora Admin XMLRPC Client 2016-09-27 15:12:14 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 8 Joachim Frieben 2016-09-28 08:51:32 UTC
As of selinux-policy-3.13.1-191.16.fc24, a virtual Fedora 25 guest reliably starts up on a Fedora 24 host with VirGL 3D enabled and active, and no further SELinux alerts are reported.
For a virtual Fedora 24 guest, the graphical login manager crashes when trying to log in but this is likely to be a different issue. Anyway, no SELinux alerts are triggered in this case either.

Comment 9 Joachim Frieben 2016-10-01 12:07:18 UTC
Both Fedora 24 and 25 accelerated VirGL 3D sessions are working as expected with selinux-policy-3.13.1-191.16.fc24. Other issues like black virtual desktops are related to bug 1380894 and only occur in Fedora 24 "GNOME on Wayland" host sessions but are absent from Fedora 24 "GNOME" (on Xorg) host sessions.

Comment 10 Fedora End Of Life 2017-07-25 20:48:33 UTC
This message is a reminder that Fedora 24 is nearing its end of life.
Approximately 2 (two) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 24. 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 EOL if it remains open with a Fedora  'version'
of '24'.

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.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 24 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, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

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.

Comment 11 Fedora End Of Life 2017-08-08 14:33:38 UTC
Fedora 24 changed to end-of-life (EOL) status on 2017-08-08. Fedora 24 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 12 Be 2020-08-09 03:08:08 UTC
This bug still exists in Fedora 32. When starting a VM with OpenGL enabled, I get this SELinux warning:

SELinux is preventing qemu-system-x86 from getattr access on the file /proc/sys/dev/i915/perf_stream_paranoid.

*****  Plugin qemu_file_image (98.8 confidence) suggests   *******************

If perf_stream_paranoid is a virtualization target
Then you need to change the label on perf_stream_paranoid'
Do
# semanage fcontext -a -t virt_image_t '/proc/sys/dev/i915/perf_stream_paranoid'
# restorecon -v '/proc/sys/dev/i915/perf_stream_paranoid'

*****  Plugin catchall (2.13 confidence) suggests   **************************

If you believe that qemu-system-x86 should be allowed getattr access on the perf_stream_paranoid file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'qemu-system-x86' --raw | audit2allow -M my-qemusystemx86
# semodule -X 300 -i my-qemusystemx86.pp

Additional Information:
Source Context                system_u:system_r:svirt_t:s0:c71,c550
Target Context                system_u:object_r:sysctl_dev_t:s0
Target Objects                /proc/sys/dev/i915/perf_stream_paranoid [ file ]
Source                        qemu-system-x86
Source Path                   qemu-system-x86
Port                          <Unknown>
Host                          localhost.localdomain
Source RPM Packages           
Target RPM Packages           
SELinux Policy RPM            selinux-policy-targeted-3.14.5-42.fc32.noarch
Local Policy RPM              selinux-policy-targeted-3.14.5-42.fc32.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     localhost.localdomain
Platform                      Linux localhost.localdomain 5.7.11-200.fc32.x86_64
                              #1 SMP Wed Jul 29 17:15:52 UTC 2020 x86_64 x86_64
Alert Count                   1
First Seen                    2020-08-08 22:02:27 CDT
Last Seen                     2020-08-08 22:02:27 CDT
Local ID                      0d592313-5d1e-4605-826f-bda98b5ee9a7

Raw Audit Messages
type=AVC msg=audit(1596942147.158:1125): avc:  denied  { getattr } for  pid=15687 comm="qemu-system-x86" path="/proc/sys/dev/i915/perf_stream_paranoid" dev="proc" ino=269369 scontext=system_u:system_r:svirt_t:s0:c71,c550 tcontext=system_u:object_r:sysctl_dev_t:s0 tclass=file permissive=0


Hash: qemu-system-x86,svirt_t,sysctl_dev_t,file,getattr


As reported previously, the suggested commands to run to change the SELinux policy do not solve the problem.