Bug 720315

Summary: SELinux is preventing /usr/sbin/mcelog from 'create open' accesses on the file /var/log/mcelog.
Product: [Fedora] Fedora Reporter: John Freed <okrh>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 14CC: dominick.grift, dwalsh, mak_s, mgrepl, mishu
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.9.7-44.fc14 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-12 11:01:52 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description John Freed 2011-07-11 11:24:11 UTC
SELinux is preventing /usr/sbin/mcelog from 'create open' accesses on the file /var/log/mcelog.

SELinux is preventing /usr/sbin/mcelog from 'write add_name' accesses on the directory /var/log.

Description of Problem:

This occurs when the mcelog cron job runs. The default cron job reads as follows:
/usr/sbin/mcelog --ignorenodev --filter >>/var/log/mcelog

An alternative (documented) method, avoiding the shell redirect, is:

/usr/sbin/mcelog --ignorenodev --filter --logfile=/var/log/mcelog

The first (redirect) method produces a file with this context:

system_u:object_r:cron_log_t:s0 

(This is also the context produced by restorecon)

The second method produces a file with this context:

system_u:object_r:var_log_t:s0

To get the second one to function, regardless of whether the logfile existed or had been created with a cron_log_t type, I needed to do the following:


#============= start module mcelog.te ==============
module mcelog 1.0;

require {
	type mcelog_t;
	type var_log_t;
	type cron_log_t;
	class file { create open };
	class dir { write add_name };
}

#============= mcelog_t ==============
allow mcelog_t cron_log_t:file open;
allow mcelog_t var_log_t:dir { write add_name };
allow mcelog_t var_log_t:file { create open };

#============= end module mcelog.te ==============

The ONLY other cron job I could find on my system that uses a shell redirect to a logfile is prelink, but that has its own context of prelink_log_t. It seems sensible to me to have mcelog follow that route and have a type of mcelog_log_t, but I leave that to wiser heads.



#============= other info ==============

Source Path                   /usr/sbin/mcelog
Source RPM Packages           mcelog-0.9pre1-0.1.fc13
Policy RPM                    selinux-policy-3.9.7-40.fc14
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Platform                      Linux (removed) 2.6.35.13-92.fc14.x86_64 #1 SMP Sat
                              May 21 17:26:25 UTC 2011 x86_64 x86_64

Comment 1 Daniel Walsh 2011-07-11 18:20:24 UTC
I think it is best if we make the log file labeled mcelog_log_t and add it to policy.

Comment 2 Miroslav Grepl 2011-07-12 10:14:10 UTC
Fixed in selinux-policy-3.9.7-44.fc14

Comment 3 Fedora Update System 2011-08-04 13:58:40 UTC
selinux-policy-3.9.7-44.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/selinux-policy-3.9.7-44.fc14

Comment 4 Fedora Update System 2011-08-05 03:53:49 UTC
Package selinux-policy-3.9.7-44.fc14:
* should fix your issue,
* was pushed to the Fedora 14 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.9.7-44.fc14'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/selinux-policy-3.9.7-44.fc14
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2011-08-12 11:00:48 UTC
selinux-policy-3.9.7-44.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 6 Fedora Update System 2011-08-12 18:25:14 UTC
selinux-policy-3.9.7-44.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.