Bug 1033732

Summary: SELinux prevents ovirt-guest-agent from reading /sys/devices/system/cpu/online file
Product: Red Hat Enterprise Linux 6 Reporter: Renê Rinco <renerinco>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED CURRENTRELEASE QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.5CC: dwalsh, howey.vernon, mmalik, sgaikwad, ssekidde
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-10 14:57:29 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:

Description Renê Rinco 2013-11-22 18:03:54 UTC
Description of problem:

After update to RHEL 6.5 I found this AVC's related to rhev-guest-agent:
type=AVC msg=audit(1385142166.199:258): avc:  denied  { read } for  pid=6666 comm="ovirt-guest-age" name="online" dev=sysfs ino=23 scontext=unconfined_u:system_r:rhev_agentd_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file
type=AVC msg=audit(1385142166.199:259): avc:  denied  { open } for  pid=6666 comm="ovirt-guest-age" name="online" dev=sysfs ino=23 scontext=unconfined_u:system_r:rhev_agentd_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file

type=AVC msg=audit(1385142825.200:270): avc:  denied  { write } for  pid=10145 comm="ovirt-guest-age" name="ovirt-guest-agent.pid" dev=dm-2 ino=3924535 scontext=unconfined_u:system_r:rhev_agentd_t:s0 tcontext=unconfined_u:object_r:initrc_var_run_t:s0 tclass=file
type=SYSCALL msg=audit(1385142825.200:270): arch=c000003e syscall=2 success=yes exit=6 a0=160d080 a1=241 a2=1b6 a3=0 items=0 ppid=1 pid=10145 auid=1637 uid=175 gid=175 euid=175 suid=175 fsuid=175 egid=175 sgid=175 fsgid=175 tty=(none) ses=33 comm="ovirt-guest-age" exe="/usr/bin/python" subj=unconfined_u:system_r:rhev_agentd_t:s0 key=(null)
type=AVC msg=audit(1385142825.201:271): avc:  denied  { setattr } for  pid=10145 comm="ovirt-guest-age" name="ovirt-guest-agent.pid" dev=dm-2 ino=3924535 scontext=unconfined_u:system_r:rhev_agentd_t:s0 tcontext=unconfined_u:object_r:initrc_var_run_t:s0 tclass=file
type=SYSCALL msg=audit(1385142825.201:271): arch=c000003e syscall=90 success=yes exit=0 a0=160d080 a1=1b4 a2=7fb4c90aba08 a3=7fffadffa800 items=0 ppid=1 pid=10145 auid=1637 uid=175 gid=175 euid=175 suid=175 fsuid=175 egid=175 sgid=175 fsgid=175 tty=(none) ses=33 comm="ovirt-guest-age" exe="/usr/bin/python" subj=unconfined_u:system_r:rhev_agentd_t:s0 key=(null)


audit2allow rule:
#============= rhev_agentd_t ==============
allow rhev_agentd_t initrc_var_run_t:file { write setattr };
allow rhev_agentd_t sysfs_t:file { read open };

/sbin/restorecon -v /var/run/ovirt-guest-agent.pid that change /var/run/ovirt-guest-agent.pid context from unconfined_u:object_r:initrc_var_run_t:s0 to unconfined_u:object_r:rhev_agentd_var_run_t:s0 does not solve because every time ovirt-guest-agent restarts the file is created with initrc_var_run_t context again. 

Version-Release number of selected component (if applicable):

selinux-policy-3.7.19-231.el6.noarch
selinux-policy-targeted-3.7.19-231.el6.noarch
rhevm-guest-agent-common-1.0.7-13.el6ev.noarch

How reproducible:
Start ovirt-guest-agent

Steps to Reproduce:
1. service ovirt-guest-agent start
2. tail /var/log/audit/audit.log


Actual results:

The AVC's mencioned.

Expected results:

None AVC

Additional info:

Comment 2 Daniel Walsh 2013-11-22 18:36:13 UTC
Is the pid file created in the init script?  If yes then the init script should be doing the restorecon.

The other issue will require a local policy until we fixes it in RHEL6.6

Comment 3 Renê Rinco 2013-11-25 11:25:59 UTC
Yes, the pid file is created by init script, but that is not doing restorecon:

    # Create as root an empty pidfile for the agent.
    if [ ! -f ${pidfile} ]; then
        /bin/touch ${pidfile}
        /bin/chown ovirtagent:ovirtagent ${pidfile}
    fi

Comment 4 Miroslav Grepl 2013-11-25 13:32:26 UTC
Then only

allow rhev_agentd_t sysfs_t:file { read open };

is selinux-policy bug.

Comment 5 Milos Malik 2013-11-25 15:10:05 UTC
My guess is that the agent wants to read /sys/devices/system/cpu/online file.

Comment 6 Miroslav Grepl 2013-11-25 15:19:39 UTC
Yes.

Comment 7 Simon Sekidde 2014-06-10 14:57:29 UTC
This should be fixed in selinux-policy-3.7.19-231.el6_5.3.noarch

#============= rhev_agentd_t ==============

#!!!! This avc is allowed in the current policy
allow rhev_agentd_t sysfs_t:file { read open };