Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1449977

Summary: SELinux is preventing /usr/libexec/qemu-kvm from 'ioctl' accesses on the blk_file /dev/sdb.
Product: Red Hat Enterprise Linux 7 Reporter: Han Han <hhan>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: dyuan, jiyan, lvrabec, mgrepl, mmalik, plautrba, pvrabec, ssekidde, xuzhang, yafu
Target Milestone: rcKeywords: Regression, TestBlocker
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: abrt_hash:0cdf698c9c14125c49b3332d490d0148aa6ba48a854be54c21579887f7ce6940
Fixed In Version: selinux-policy-3.13.1-149.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 15:26:23 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 Han Han 2017-05-11 09:40:41 UTC
Description of problem:
1. Create a running VM with following xml:
# virsh dumpxml VM|awk '/<disk/,/<\/disk/'                                                                                                
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/VM.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
    </disk>

2. Prepare a local storage sdb, sdc, sdd. Prepare snapshot xml as following:
/tmp/disk1.xml:
<domainsnapshot><name>layer2</name><disks><disk name="vda" snapshot="external" type="block"><source dev="/dev/sdb" /></disk></disks></domainsnapshot>
/tmp/disk2.xml:
<domainsnapshot><name>layer3</name><disks><disk name="vda" snapshot="external" type="block"><source dev="/dev/sdc" /></disk></disks></domainsnapshot>
/tmp/disk3.xml:
<domainsnapshot><name>layer3</name><disks><disk name="vda" snapshot="external" type="block"><source dev="/dev/sdd" /></disk></disks></domainsnapshot>

Create snapshots:
# for i in {1..3};do virsh snapshot-create VM /tmp/disk$i.xml --no-metadata --disk-only;done
Domain snapshot layer2 created from '/tmp/disk1.xml'
Domain snapshot layer3 created from '/tmp/disk2.xml'
Domain snapshot layer3 created from '/tmp/disk3.xml'

3. Do blockcommit:
# for i in {1..3};do virsh blockcommit VM vda --active --shallow --wait --verbose --pivot;done
Block commit: [100 %]
Successfully pivoted
Block commit: [100 %]
Successfully pivoted
Block commit: [100 %]
Successfully pivoted

Then got the selinux alert:
SELinux is preventing /usr/libexec/qemu-kvm from ioctl access on the blk_file /dev/sdb.
SELinux is preventing /usr/libexec/qemu-kvm from 'ioctl' accesses on the blk_file /dev/sdb.

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

If you believe that qemu-kvm should be allowed ioctl access on the sdb blk_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-kvm' --raw | audit2allow -M my-qemukvm
# semodule -i my-qemukvm.pp

Additional Information:
Source Context                system_u:system_r:svirt_t:s0:c726,c750
Target Context                system_u:object_r:fixed_disk_device_t:s0
Target Objects                /dev/sdb [ blk_file ]
Source                        qemu-kvm
Source Path                   /usr/libexec/qemu-kvm
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           qemu-kvm-rhev-2.9.0-3.el7.x86_64
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-148.el7.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Permissive
Host Name                     (removed)
Platform                      Linux (removed) 3.10.0-664.el7.x86_64 #1 SMP Mon
                              May 8 11:14:30 EDT 2017 x86_64 x86_64
Alert Count                   2
First Seen                    2017-05-11 17:31:30 CST
Last Seen                     2017-05-11 17:32:22 CST
Local ID                      b67fa5c8-4757-4046-beb9-cbf76dc19586

Raw Audit Messages
type=AVC msg=audit(1494495142.421:1052): avc:  denied  { ioctl } for  pid=25325 comm="qemu-kvm" path="/dev/sdb" dev="tmpfs" ino=113920 scontext=system_u:system_r:svirt_t:s0:c726,c750 tcontext=system_u:object_r:fixed_disk_device_t:s0 tclass=blk_file


type=SYSCALL msg=audit(1494495142.421:1052): arch=x86_64 syscall=ioctl success=yes exit=0 a0=5b a1=1267 a2=7ffc3e9ad360 a3=800 items=0 ppid=1 pid=25325 auid=4294967295 uid=107 gid=107 euid=107 suid=107 fsuid=107 egid=107 sgid=107 fsgid=107 tty=(none) ses=4294967295 comm=qemu-kvm exe=/usr/libexec/qemu-kvm subj=system_u:system_r:svirt_t:s0:c726,c750 key=(null)

Hash: qemu-kvm,svirt_t,fixed_disk_device_t,blk_file,ioctl

Version-Release number of selected component:
selinux-policy-3.13.1-148.el7.noarch

Additional info:
reporter:       libreport-2.1.11.1
hashmarkername: setroubleshoot
kernel:         3.10.0-664.el7.x86_64
reproducible:   Not sure how to reproduce the problem
type:           libreport

Comment 2 Han Han 2017-05-11 09:43:18 UTC
The bug will cause the blockcommit failed.

Comment 4 Han Han 2017-05-15 06:07:40 UTC
It works well on:
libvirt-2.0.0-10.virtcov.el7_3.9.x86_64
qemu-kvm-rhev-2.6.0-28.el7_3.9.x86_64
selinux-policy-3.13.1-102.el7_3.16.noarch

Marked as regression.

Comment 8 errata-xmlrpc 2017-08-01 15:26:23 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:1861