Bug 1415715 - SELinux is preventing systemctl from write access on the chr_file kmsg.
Summary: SELinux is preventing systemctl from write access on the chr_file kmsg.
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy
Version: 7.3
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Lukas Vrabec
QA Contact: Milos Malik
Depends On:
TreeView+ depends on / blocked
Reported: 2017-01-23 14:12 UTC by Paul Stauffer
Modified: 2017-08-01 15:20 UTC (History)
8 users (show)

Fixed In Version: selinux-policy-3.13.1-125.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2017-08-01 15:20:12 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1372755 0 unspecified CLOSED SELinux is preventing systemctl from 'write' accesses on the chr_file kmsg. 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHBA-2017:1861 0 normal SHIPPED_LIVE selinux-policy bug fix update 2017-08-01 17:50:24 UTC

Internal Links: 1372755

Description Paul Stauffer 2017-01-23 14:12:32 UTC
SELinux is preventing systemctl from write access on the chr_file kmsg.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that systemctl should be allowed write access on the kmsg chr_file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
allow this access for now by executing:
# ausearch -c 'systemctl' --raw | audit2allow -M my-systemctl
# semodule -i my-systemctl.pp

Additional Information:
Source Context                system_u:system_r:logrotate_t:s0-s0:c0.c1023
Target Context                system_u:object_r:kmsg_device_t:s0
Target Objects                kmsg [ chr_file ]
Source                        systemctl
Source Path                   systemctl
Port                          <Unknown>
Host                          redacted.example.com
Source RPM Packages           systemd-219-30.el7_3.6.x86_64
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-102.el7_3.13.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     redacted.example.com
Platform                      Linux redacted.example.com 3.10.0-514.6.1.el7.x86_64 #1 SMP
                              Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64
Alert Count                   2
First Seen                    2017-01-22 04:07:02 EST
Last Seen                     2017-01-23 03:06:02 EST
Local ID                      935b4524-e165-488d-960e-f7164a945cab

Raw Audit Messages
type=AVC msg=audit(1485158762.113:3136): avc:  denied  { write } for  pid=16459 comm="systemctl" name="kmsg" dev="devtmpfs" ino=1034 scontext=system_u:system_r:logrotate_t:s0-s0:c0.c1023 tcontext=system_u:object_r:kmsg_device_t:s0 tclass=chr_file

type=SYSCALL msg=audit(1485158762.113:3136): arch=x86_64 syscall=open success=no exit=EACCES a0=7fd9ec6dc17f a1=80101 a2=ffffffff a3=7fd9eb7357b8 items=0 ppid=16458 pid=16459 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=414 comm=systemctl exe=/usr/bin/systemctl subj=system_u:system_r:logrotate_t:s0-s0:c0.c1023 key=(null)

Hash: systemctl,logrotate_t,kmsg_device_t,chr_file,write

In case it's relevant:
$ rpm -q logrotate

Comment 1 Milos Malik 2017-01-23 15:58:48 UTC
Was the kernel executed with some special logging parameters?

# cat /proc/cmdline

Comment 2 Paul Stauffer 2017-01-23 16:42:44 UTC
Yes indeed:

# cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz-3.10.0-514.6.1.el7.x86_64 root=/dev/mapper/vg1-lv1 ro rd.lvm.lv=vg1/lv1 rd.shell=0 rd.lvm.lv=vg1/lv3 crashkernel=auto printk.time=0 biosdevname=0 rhgb quiet LANG=en_US.UTF-8 systemd.log_level=debug systemd.log_target=kmsg

We were previously running kernel 3.10.0-327.36.3.el7.x86_64, and those last two parameters appear to be new additions since upgrading to 3.10.0-514.6.1.el7.x86_64.  It's not clear to me if those are now the intended defaults for RHEL 7.3?  We certainly didn't intentionally add them.

Comment 3 Paul Stauffer 2017-01-23 17:10:38 UTC
Ah ok, looks like that happened because we got hit (again) with Bug 1285601, which resulted in the "...with debugging" kernel incorrectly being made the default boot target in the grub menu.  So ok, we know how to work around that.

But that's actually a little beside the point for the current bug report; this logging configuration SHOULD work without an SELinux denial, correct?  Which implies that selinux-policy may need to be adjusted to allow this.

Comment 4 Milos Malik 2017-01-24 09:13:51 UTC
I can imagine that a lot of SELinux domains will try to write to /dev/kmsg. Could we solve that problem via a new boolean?

Comment 5 Lukas Vrabec 2017-02-01 13:53:28 UTC
You mean some boolean that all domains can write to /dev/kmsg ? 


Comment 6 Milos Malik 2017-02-01 14:01:16 UTC

Comment 7 Lukas Vrabec 2017-03-03 13:50:58 UTC
Agree with Milos. 

Adding new boolean.

Comment 10 errata-xmlrpc 2017-08-01 15:20:12 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.


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