From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>,
"Zhangbo (Oscar)" <oscar.zhangbo@huawei.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"Yanzheng (A)" <yanzheng759@huawei.com>,
"Huangweidong (C)" <weidong.huang@huawei.com>,
yinyipeng <yinyipeng1@huawei.com>,
"dengkai (A)" <dengkai1@huawei.com>,
jsnow@redhat.com
Subject: Re: [Qemu-devel] 'sys_rawio' selinux alarm triggered while doing SCSI reservation inside the guest
Date: Thu, 24 Jan 2019 11:48:57 +0100 [thread overview]
Message-ID: <4e8bf907-f8db-96e4-551e-a332b42de3ec@redhat.com> (raw)
In-Reply-To: <20190124102637.GE4764@stefanha-x1.localdomain>
[-- Attachment #1: Type: text/plain, Size: 2795 bytes --]
On 24/01/19 11:26, Stefan Hajnoczi wrote:
> On Thu, Jan 24, 2019 at 01:32:49AM +0000, Zhangbo (Oscar) wrote:
>> When performing SCSI reservation inside the guest, 'sys_rawio' selinux alarm is triggered, shown as below:
>> "type=AVC msg=audit(1548231520.416:8086): avc: denied { sys_rawio } for pid=30357 comm="worker" capability=17 scontext=system_u:system_r:svirt_t:s0:c72,c348 tcontext=system_u:system_r:svirt_t:s0:c72,c348 tclass=capability"
>>
>> It's quite possible that the *ioctl SG_IO * caused this problem.
>> Is it a design flaw in qemu? Ioctl SG_IO seems too privileged for qemu?
>
> CCing Paolo and John for SCSI.
>
>>
>> Here comes the possible solutions:
>> possible solution 1: Add an selinux policy boolean to allow the 'sys_rawio' action, which suggests that this scenario is not a problem/design flaw indeed.
>> possible solution 2: reconstruct the SCSI-related action scheme inside qemu? such as letting libvirtd to accomplish such SG_IO job.
>> Or, otherwise, any other solutions can you suggest? Thanks!
The latest QEMU already has qemu-pr-helper in order to support this.
libvirt will start the helper and tell QEMU to redirect reservations there.
You need to add "<reservations managed='yes'/>" inside the <source>
element of the disk.
Thanks,
Paolo
>>
>>
>> reproduction:
>> libvirt version: lastest
>> qemu version: lastest
>> selinux mode: Permissive
>> service auditd status: active(running)
>>
>> step 1. Configure scsi disk for vm in xml.
>> <controller type='scsi' index='0' model='virtio-scsi'>
>> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
>> </controller>
>> <disk type='block' device='lun' rawio='yes'>
>> <driver name='qemu' type='raw' cache='none' io='native'/>
>> <source dev='/dev/sdo'/>
>> <target dev='sda' bus='scsi'/>
>> <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>> </disk>
>>
>> step 2. Define and start vm.
>> The type of guest OS is not the key. here is centos-7.4
>>
>> step 3. Perform SCSI reservation command inside the guest.
>> # sg_persist -o -n -I -K 123abc -S 0 -d /dev/sda
>> # sg_persist -n -o -L -K 123abc -T 5 -d /dev/sda
>> # sg_persist -o -n -I -K 123abc -S 0 -d /dev/sda
>> # sg_persist -o -n -I -S 123abc -d /dev/sda
>> # sg_persist -i -n -k -d /dev/sda
>> # sg_persist -n -o -R -T 5 -K 123abc -d /dev/sda
>> # sg_persist -n -i -r -d /dev/sda
>> # sg_persist -n -o -L -K 123abc -T 5 -d /dev/sda
>>
>> Then we can read 'sys_rawio' SElinux Denied in /var/log/audit/audit.log
>> type=AVC msg=audit(1548231520.416:8086): avc: denied { sys_rawio } for pid=30357 comm="worker" capability=17 scontext=system_u:system_r:svirt_t:s0:c72,c348 tcontext=system_u:system_r:svirt_t:s0:c72,c348 tclass=capability
>>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2019-01-24 10:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-24 1:32 [Qemu-devel] 'sys_rawio' selinux alarm triggered while doing SCSI reservation inside the guest Zhangbo (Oscar)
2019-01-24 10:26 ` Stefan Hajnoczi
2019-01-24 10:48 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4e8bf907-f8db-96e4-551e-a332b42de3ec@redhat.com \
--to=pbonzini@redhat.com \
--cc=dengkai1@huawei.com \
--cc=jsnow@redhat.com \
--cc=oscar.zhangbo@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=weidong.huang@huawei.com \
--cc=yanzheng759@huawei.com \
--cc=yinyipeng1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).