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 1941464 - SELinux is preventing /usr/sbin/virtlockd from create access on the directory lockd
Summary: SELinux is preventing /usr/sbin/virtlockd from create access on the directory...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.4
Hardware: Unspecified
OS: Linux
medium
medium
Target Milestone: rc
: 8.5
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks: 1974875
TreeView+ depends on / blocked
 
Reported: 2021-03-22 08:16 UTC by yafu
Modified: 2021-11-10 08:33 UTC (History)
6 users (show)

Fixed In Version: selinux-policy-3.14.3-68.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
: 1974875 (view as bug list)
Environment:
Last Closed: 2021-11-09 19:42:58 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:4420 0 None None None 2021-11-09 19:43:20 UTC

Description yafu 2021-03-22 08:16:32 UTC
Description of problem:
SELinux is preventing /usr/sbin/virtlockd from create access on the directory lockd

Version-Release number of selected component (if applicable):
selinux-policy-3.14.3-67.el8.noarch
libvirt-daemon-7.0.0-10.module+el8.4.0+10417+37f6984d.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Set qemu.conf:
lock_manager = "lockd"

2.Set qemu-lockd.conf
file_lockspace_dir = "/var/lib/libvirt/lockd/files"

3.Restart libvirtd service
#systemctl restart libvirtd

4.Connect to libvirtd:
#virsh list
error: failed to connect to the hypervisor
error: Cannot recv data: Connection reset by peer

5.Check the audit log:
#ausearch -m avc
type=PROCTITLE msg=audit(1616400460.250:5235): proctitle="/usr/sbin/virtlockd"
type=SYSCALL msg=audit(1616400460.250:5235): arch=c000003e syscall=83 success=no exit=-13 a0=5596e327c930 a1=1c0 a2=7ffda5151600 a3=0 items=0 ppid=1 pid=123826 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="virtlockd" exe="/usr/sbin/virtlockd" subj=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 key=(null)
type=AVC msg=audit(1616400460.250:5235): avc:  denied  { create } for  pid=123826 comm="virtlockd" name="lockd" scontext=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:virt_var_lib_t:s0 tclass=dir permissive=0

Actual results:
SELinux is preventing /usr/sbin/virtlockd from create access on the directory lockd

Expected results:


Additional info:

Comment 1 Zdenek Pytela 2021-03-22 08:42:08 UTC
Nikola,

Can you assess if this permission request is expected, given the current state of the libvirt policy in RHEL 8?

Comment 2 Nikola Knazekova 2021-04-27 12:52:24 UTC
Hi Zdenko

the new libvirt policy for new virt drivers is not developed for RHEL8.

In the libvirt policy for RHEL8 and also in new libvirt policy, filecontext for /var/lib/libvirt/lockd should be virt_var_lockd_t, instead of virt_var_lib_t.

Comment 3 Zdenek Pytela 2021-04-27 19:58:29 UTC
Merged in rawhide:
commit f83261b20273c167520949c5a9e8b38ac9a18f93 (HEAD -> rawhide, upstream/rawhide)
Author: Nikola Knazekova <nknazeko>
Date:   Tue Apr 27 15:04:44 2021 +0200

    Allow virtlogd_t to create virt_var_lockd_t dir

    Allow virtlogd_t to create dir named "lockd"
    with label virt_var_lockd_t in parent directory
    labeled as virt_var_lib_t.

    Make the virt_var_lockd_t type usable for files
    in a filesystem.

    Fixed BZ1941464.

    Tested on RHEL8.4.

    Signed-off-by: Nikola Knazekova <nknazeko>

Comment 10 Milos Malik 2021-05-20 16:19:57 UTC
When old selinux-policy is installed, the following SELinux denial appears in enforcing mode:
----
type=PROCTITLE msg=audit(05/20/2021 12:15:04.945:439) : proctitle=/usr/sbin/virtlockd 
type=PATH msg=audit(05/20/2021 12:15:04.945:439) : item=1 name=/var/lib/libvirt/lockd nametype=CREATE cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=PATH msg=audit(05/20/2021 12:15:04.945:439) : item=0 name=/var/lib/libvirt/ inode=529464 dev=fd:01 mode=dir,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:virt_var_lib_t:s0 nametype=PARENT cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=CWD msg=audit(05/20/2021 12:15:04.945:439) : cwd=/ 
type=SYSCALL msg=audit(05/20/2021 12:15:04.945:439) : arch=x86_64 syscall=mkdir success=no exit=EACCES(Permission denied) a0=0x56307fcdec00 a1=0700 a2=0x7ffed3f76950 a3=0x7f59ccce78ff items=2 ppid=1 pid=6654 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=virtlockd exe=/usr/sbin/virtlockd subj=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 key=(null) 
type=AVC msg=audit(05/20/2021 12:15:04.945:439) : avc:  denied  { create } for  pid=6654 comm=virtlockd name=lockd scontext=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:virt_var_lib_t:s0 tclass=dir permissive=0 
----

When old selinux-policy is installed, the following SELinux denial appears in permissive mode:
----
type=PROCTITLE msg=audit(05/20/2021 12:16:59.367:444) : proctitle=/usr/sbin/virtlockd 
type=PATH msg=audit(05/20/2021 12:16:59.367:444) : item=1 name=/var/lib/libvirt/lockd inode=18874568 dev=fd:01 mode=dir,700 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:virt_var_lib_t:s0 nametype=CREATE cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=PATH msg=audit(05/20/2021 12:16:59.367:444) : item=0 name=/var/lib/libvirt/ inode=529464 dev=fd:01 mode=dir,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:virt_var_lib_t:s0 nametype=PARENT cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=CWD msg=audit(05/20/2021 12:16:59.367:444) : cwd=/ 
type=SYSCALL msg=audit(05/20/2021 12:16:59.367:444) : arch=x86_64 syscall=mkdir success=yes exit=0 a0=0x56307fce2590 a1=0700 a2=0x7ffed3f76950 a3=0x7f59ccce78ff items=2 ppid=1 pid=6654 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=virtlockd exe=/usr/sbin/virtlockd subj=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 key=(null) 
type=AVC msg=audit(05/20/2021 12:16:59.367:444) : avc:  denied  { create } for  pid=6654 comm=virtlockd name=lockd scontext=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:virt_var_lib_t:s0 tclass=dir permissive=1 
----

Comment 17 Zdenek Pytela 2021-06-11 10:06:30 UTC
Hi,

Can you please check if the scenario in #c0 is applicable to RHEL 9, too?

Comment 18 yafu 2021-06-16 00:34:20 UTC
(In reply to Zdenek Pytela from comment #17)
> Hi,
> 
> Can you please check if the scenario in #c0 is applicable to RHEL 9, too?

Hi Zdenek,

I tested comment #0 with selinux-policy-34.1.8-1.el9.noarch, the avc deny is different with comment #0:
# ausearch -m avc | grep -i virtlockd
type=AVC msg=audit(1623802355.506:1681): avc:  denied  { read append } for  pid=187608 comm="virtlockd" name="system.token" dev="tmpfs" ino=2505 scontext=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:virt_var_run_t:s0 tclass=file permissive=0

And it seems the same issue with https://bugzilla.redhat.com/show_bug.cgi?id=1966842.

Comment 19 Zdenek Pytela 2021-06-16 07:24:18 UTC
(In reply to yafu from comment #18)
> (In reply to Zdenek Pytela from comment #17)
> > Hi,
> > 
> > Can you please check if the scenario in #c0 is applicable to RHEL 9, too?
> 
> Hi Zdenek,
> 
> I tested comment #0 with selinux-policy-34.1.8-1.el9.noarch, the avc deny is
> different with comment #0:
> # ausearch -m avc | grep -i virtlockd
> type=AVC msg=audit(1623802355.506:1681): avc:  denied  { read append } for 
> pid=187608 comm="virtlockd" name="system.token" dev="tmpfs" ino=2505
> scontext=system_u:system_r:virtlogd_t:s0-s0:c0.c1023
> tcontext=system_u:object_r:virt_var_run_t:s0 tclass=file permissive=0
> 
> And it seems the same issue with
> https://bugzilla.redhat.com/show_bug.cgi?id=1966842.
Hi,

This issue will be addressed in the RHEL 9 clone bz#1969209, so we probably need to retest the #c0 scenario when the new build is available.

Comment 21 errata-xmlrpc 2021-11-09 19:42:58 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 (selinux-policy bug fix and enhancement update), 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-2021:4420


Note You need to log in before you can comment on or make changes to this bug.