Bug 1255948 - SELinux is preventing nagios check_disk plugin getattr on /sys/kernel/config
Summary: SELinux is preventing nagios check_disk plugin getattr on /sys/kernel/config
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 23
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lukas Vrabec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-08-22 08:06 UTC by Joonas Sarajärvi
Modified: 2017-09-09 04:16 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-20 14:27:12 UTC


Attachments (Terms of Use)

Description Joonas Sarajärvi 2015-08-22 08:06:23 UTC
Description of problem:
SELinux policy seems to default to being strict enough that
nagios check_disk plugin is not able to function when run under nrpe.

Version-Release number of selected component (if applicable):
selinux-policy-3.13.1-141.fc23.noarch
nrpe-2.15-4.fc22.armv7hl
nagios-plugins-disk-2.0.3-1.fc23.armv7hl
nagios-plugins-nrpe-2.15-4.fc22.armv7hl

How reproducible:
Always

Steps to Reproduce:

(Replace /usr/lib with /usr/lib64 on x86_64)

1. Install these: nrpe nagios-plugins-disk nagios-plugins-nrpe
2. Write the following line to /etc/nrpe.d/commands.cfg:
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 25% -c 10% -e
3. (re)start nrpe service
4. Run /usr/lib/nagios/plugins/check_nrpe -H localhost -c check_disk


Actual results:
DISK CRITICAL - /sys/kernel/config is not accessible: Permission denied

Also I get an entry like this in /var/log/audit/audit.log:

type=AVC msg=audit(1440228929.866:5264): avc:  denied  { getattr } for  pid=15274 comm="check_disk" path="/sys/kernel/config" dev="configfs" ino=11893 scontext=system_u:system_r:nagios_checkdisk_plugin_t:s0 tcontext=system_u:object_r:configfs_t:s0 tclass=dir permissive=0

Expected results:
(Stuff I get when SELinux is set to permissive mode)
DISK WARNING - free space: /boot 40 MB (15% inode=99%);| /dev=0MB;742;891;0;990 /dev/shm=0MB;754;905;0;1006 /run=0MB;754;905;0;1006 /sys/fs/cgroup=0MB;754;905;0;1006 /=5567MB;227397;272876;0;303196 /boot=217MB;195;234;0;261 /run/user/1100=0MB;150;180;0;201

Additional info:
The check_nrpe process would typically run on a different host than where the nrpe service is run. The steps to reproduce are for running in single host, but the issue affects also the case with separate hosts.

Comment 1 Joonas Sarajärvi 2015-08-24 18:43:03 UTC
Some extra notes:

With the document at [1], I learned about a workaround that allows one to use the check_disk plugin without entirely crippling SELinux:

semanage fcontext -a -t nagios_unconfined_plugin_exec_t /usr/lib64/nagios/plugins/check_disk
restorecon -v /usr/lib64/nagios/plugins/check_disk

It is quite surprising that SELinux even in RHEL and CentOS seem to confine nagios plugins, despite those distros not shipping them. At least in CentOS 7, I have to enable e.g. the EPEL repository in order to get nagios.

References:
[1] http://edvoncken.net/2012/01/workaround-for-nagios-check_disk-failure-in-rhel-centos-6-2/

Comment 2 Need Real Name 2016-04-28 17:33:49 UTC
Another workaround is to exclude the offending filesystems in your check_disk probe definition.  Include flags like these to get rid of the absurd flood of psuedo filesystems:

-X configfs -X cgroup -X tmpfs -X selinuxfs -X sysfs -X proc -X mqueue -X binfmt_misc -X devtmpfs

With the exception perhaps of tmpfs, I don't think there is much actionable information in reporting any of those anyway.

Comment 3 Fedora Admin XMLRPC Client 2016-09-27 14:59:11 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 4 Fedora End Of Life 2016-11-24 12:21:39 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Fedora End Of Life 2016-12-20 14:27:12 UTC
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 6 Chris Herdt 2017-09-09 04:16:53 UTC
In case anyone runs across this closed bug report, this is not actually a bug. There is no reason for the Nagios check_disk plugin to be checking the configfs virtual filesystem, so SELinux blocks it.

The comment by Need Real Name is correct: the solution is to correct the check_disk definition to include only the filesystems you want to check, or exclude the filesystems you don't want to check. There is no reason to change the SELinux context.


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