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 1822522

Summary: avc: denied { read write } for pid=3449 comm="qemu-kvm" path="/dev/mapper/control"
Product: Red Hat Enterprise Linux 8 Reporter: Fangge Jin <fjin>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED DUPLICATE QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: low    
Version: 8.2CC: berrange, chhu, cjeanner, hhan, jsuchane, lmen, lvrabec, mmalik, mprivozn, plautrba, ssekidde, virt-maint, xuzhang, yafu
Target Milestone: rcKeywords: Triaged
Target Release: 8.3Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-07-29 17:32:04 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:
Embargoed:
Attachments:
Description Flags
vm xml configuration none

Description Fangge Jin 2020-04-09 09:07:56 UTC
Description of problem:
Start a vm, vm starts successfully, but there is AVC denied error in audit.log:
# ausearch -c qemu-kvm -m avc
----
time->Thu Apr  9 04:55:29 2020
type=AVC msg=audit(1586422529.809:350): avc:  denied  { read write } for  pid=3449 comm="qemu-kvm" path="/dev/mapper/control" dev="devtmpfs" ino=25607 scontext=system_u:system_r:svirt_t:s0:c116,c867 tcontext=system_u:object_r:lvm_control_t:s0 tclass=chr_file permissive=0


Version-Release number of selected component:
qemu-kvm-4.2.0-17.module+el8.2.0+6141+0f540f16.x86_64
selinux-policy-3.14.3-41.el8.noarch
libvirt-6.0.0-17.module+el8.2.0+6257+0d066c28.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Start a vm
2. Check audit.log by "ausearch -c qemu-kvm -m avc"

Actual results:
As above

Expected results:
There should be no AVC denied error when vm starts.

Additional info:

Comment 1 Peter Krempa 2020-04-09 11:56:21 UTC
Please attach the VM config XML you've used.

Comment 2 Fangge Jin 2020-04-09 12:53:18 UTC
Created attachment 1677533 [details]
vm xml configuration

Comment 4 Michal Privoznik 2020-05-07 13:07:55 UTC
Here are my debugging findings. Firstly, I've noticed that this does not happen if I disable namespaces. That lead me to a patch that I have in a local branch for bug 1823976 where I'm waiting for confirming that the approach I've chosen is the right one. Basically, what is happening is: when libvirt is setting up the private /dev for the domain, it consults devmapper to rebuild the targets table (for instance for a multipath device qemu might open all its targets). And the AVC message we are seeing is SELinux denying the following ioctl:

stat("/dev/mapper/control", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xa, 0xec), ...}) = 0
openat(AT_FDCWD, "/dev/mapper/control", O_RDWR) = 3</dev/mapper/control<char 10:236>>
ioctl(3</dev/mapper/control<char 10:236>>, DM_VERSION, {version=4.0.0, data_size=16384, flags=DM_EXISTS_FLAG} => {version=4.42.0, data_size=16384, flags=DM_EXISTS_FLAG}) = 0

What is interesting is that execve() happens only after the ioctl(), so why would auditd report comm="qemu-kvm" is beyond me.
However, my fix only suppresses querying devmapper for *every* path created in the private /dev. If the path is a devmapper target then the ioctl() will be run and I guess the AVC message will appear again. So maybe we need to add a rule to the SELinux policy?

Comment 5 Zdenek Pytela 2020-07-07 06:50:40 UTC
*** Bug 1854040 has been marked as a duplicate of this bug. ***

Comment 15 Zdenek Pytela 2020-07-29 17:32:04 UTC
Per previous agreement, closing as a dup of bz#1858260.

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