Bug 1598593

Summary: SELinux is preventing "virtlogd" from read access to virt_etc_t symlink
Product: Red Hat Enterprise Linux 7 Reporter: g.danti
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: g.danti, lvrabec, mgrepl, mmalik, plautrba, ssekidde
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 10:06:08 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:

Description g.danti 2018-07-05 23:43:49 UTC
Description of problem:
When /etc/libvirt is moved to another location (ie: /mnt/volume/etc/libvirt) and a symlink to the new destination is placed on /etc (ie: ln -s /mnt/volume/etc/libvirt /etc/) SELinux denies access by "virtlogd" to /etc/libvirt, preventing libvirt from running correctly. 

This is true even if symlink is labeled with the correct, original virt_etc_t context. On the other hand, if symlink is marked with the more generic etc_t, "virtlogd" (and libvirtd) correctly works; it even survive restorecon.

Problem is, every libvirt-daemon updates will reset the context of the symlink to virt_etc_t, causing a failure to start libvirtd.

When "virtlogd" is blocked, the following entries are logged on /var/log/audit/audit.log:
type=SERVICE_START msg=audit(1530832860.093:278): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=virtlogd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=AVC msg=audit(1530832860.127:279): avc:  denied  { read } for  pid=3965 comm="virtlogd" name="libvirt" dev="dm-0" ino=5060861 scontext=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:virt_etc_t:s0 tclass=lnk_file
type=SYSCALL msg=audit(1530832860.127:279): arch=c000003e syscall=21 success=no exit=-13 a0=55fdf118ec90 a1=4 a2=1 a3=3 items=0 ppid=1 pid=3965 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="virtlogd" exe="/usr/sbin/virtlogd" subj=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 key=(null)
type=PROCTITLE msg=audit(1530832860.127:279): proctitle="/usr/sbin/virtlogd"
type=AVC msg=audit(1530832860.129:280): avc:  denied  { read } for  pid=3965 comm="virtlogd" name="libvirt" dev="dm-0" ino=5060861 scontext=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:virt_etc_t:s0 tclass=lnk_file
type=SYSCALL msg=audit(1530832860.129:280): arch=c000003e syscall=2 success=no exit=-13 a0=55fdf118ec90 a1=0 a2=7ffffb6d7b30 a3=1 items=0 ppid=1 pid=3965 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="virtlogd" exe="/usr/sbin/virtlogd" subj=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 key=(null)
type=PROCTITLE msg=audit(1530832860.129:280): proctitle="/usr/sbin/virtlogd"
type=SERVICE_STOP msg=audit(1530832860.145:281): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=virtlogd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'

audit2allow shows the following:
#============= virtlogd_t ==============
allow virtlogd_t virt_etc_t:lnk_file read;

Version-Release number of selected component (if applicable):
libvirt-daemon-3.9.0-14.el7_5.6.x86_64

How reproducible:
Move /etc/libvirt to another location and leave a symlink in the original location, assigning it context virt_etc_t. Then restart virtlogd while watching /var/log/audit/audit.log

Steps to Reproduce:
1. move /etc/libvirt to another location
2. ln -s <newloc> /etc/libvirtd
3. chcon -h -t virt_etc_v /etc/libvirt (or: yum reinstall libvirtd)
4. restart virtlogd
5. see the errors in audit.log

Actual results:
Virtual machine configuration is not completely loaded (ie: autostarting VMs does not work).

Expected results:
If virtlogd can read symlinks of etc_t, it should read virt_etc_t also. Please also note that virtlogd is permitted to read the real directory /etc/libvirt with virt_etc_t context.

Additional info:
OS RHEL7 x86-64

Comment 5 errata-xmlrpc 2018-10-30 10:06:08 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-2018:3111