Bug 1753292 - SELinux prevents webalizer from reading the content of /sys/devices/system/cpu directory
Summary: SELinux prevents webalizer from reading the content of /sys/devices/system/cp...
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 29
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Lukas Vrabec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-09-18 14:27 UTC by Milos Malik
Modified: 2019-11-27 23:27 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2019-11-27 23:27:14 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Milos Malik 2019-09-18 14:27:41 UTC
Description of problem:

Version-Release number of selected component (if applicable):
httpd-2.4.41-1.fc31.x86_64
httpd-filesystem-2.4.41-1.fc31.noarch
httpd-manual-2.4.41-1.fc31.noarch
httpd-tools-2.4.41-1.fc31.x86_64
selinux-policy-3.14.4-31.fc31.noarch
selinux-policy-devel-3.14.4-31.fc31.noarch
selinux-policy-minimum-3.14.4-31.fc31.noarch
selinux-policy-mls-3.14.4-31.fc31.noarch
selinux-policy-targeted-3.14.4-31.fc31.noarch
webalizer-2.23_08-13.fc31.x86_64

How reproducible:
 * always

Steps to Reproduce:
1. get a Fedora 31 machine (targeted policy is active)
# cp -f ./minutely /etc/cron.d/
# systemctl restart crond
# rm -f /var/www/usage/*
# curl http://localhost:80/manual/ > /dev/null
# sleep 90
# ls -Z /var/www/usage
3. search for SELinux denials

Actual results:
----
type=PROCTITLE msg=audit(09/18/2019 10:19:01.023:431) : proctitle=/usr/bin/webalizer -v 
type=PATH msg=audit(09/18/2019 10:19:01.023:431) : item=0 name=/sys/devices/system/cpu inode=33 dev=00:16 mode=dir,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:sysfs_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=CWD msg=audit(09/18/2019 10:19:01.023:431) : cwd=/root 
type=SYSCALL msg=audit(09/18/2019 10:19:01.023:431) : arch=x86_64 syscall=openat success=no exit=EACCES(Permission denied) a0=0xffffff9c a1=0x7fe159e72c3c a2=O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC a3=0x0 items=1 ppid=121578 pid=121579 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=webalizer exe=/usr/bin/webalizer subj=system_u:system_r:webalizer_t:s0-s0:c0.c1023 key=(null) 
type=AVC msg=audit(09/18/2019 10:19:01.023:431) : avc:  denied  { read } for  pid=121579 comm=webalizer name=cpu dev="sysfs" ino=33 scontext=system_u:system_r:webalizer_t:s0-s0:c0.c1023 tcontext=system_u:object_r:sysfs_t:s0 tclass=dir permissive=0 
----

Expected results:
 * no SELinux denials

Additional info:
# cat ./minutely 
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

* * * * * root /usr/bin/webalizer -v
#

Comment 1 Milos Malik 2019-09-18 14:35:54 UTC
Following SELinux denials appeared in permissive mode:
----
type=PROCTITLE msg=audit(09/18/2019 10:31:01.046:438) : proctitle=/usr/bin/webalizer -v 
type=PATH msg=audit(09/18/2019 10:31:01.046:438) : item=0 name=/sys/devices/system/cpu inode=33 dev=00:16 mode=dir,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:sysfs_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=CWD msg=audit(09/18/2019 10:31:01.046:438) : cwd=/root 
type=SYSCALL msg=audit(09/18/2019 10:31:01.046:438) : arch=x86_64 syscall=openat success=yes exit=3 a0=0xffffff9c a1=0x7f7294f29c3c a2=O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC a3=0x0 items=1 ppid=126216 pid=126217 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=webalizer exe=/usr/bin/webalizer subj=system_u:system_r:webalizer_t:s0-s0:c0.c1023 key=(null) 
type=AVC msg=audit(09/18/2019 10:31:01.046:438) : avc:  denied  { read } for  pid=126217 comm=webalizer path=/sys/devices/system/cpu dev="sysfs" ino=33 scontext=system_u:system_r:webalizer_t:s0-s0:c0.c1023 tcontext=system_u:object_r:sysfs_t:s0 tclass=dir permissive=1 
type=AVC msg=audit(09/18/2019 10:31:01.046:438) : avc:  denied  { read } for  pid=126217 comm=webalizer name=cpu dev="sysfs" ino=33 scontext=system_u:system_r:webalizer_t:s0-s0:c0.c1023 tcontext=system_u:object_r:sysfs_t:s0 tclass=dir permissive=1 
----
type=PROCTITLE msg=audit(09/18/2019 10:31:01.051:439) : proctitle=/usr/bin/webalizer -v 
type=PATH msg=audit(09/18/2019 10:31:01.051:439) : item=1 name=/var/lib/webalizer/__db.dns_cache.db inode=403046 dev=fc:01 mode=file,644 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:webalizer_var_lib_t:s0 nametype=CREATE cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=PATH msg=audit(09/18/2019 10:31:01.051:439) : item=0 name=/var/lib/webalizer/ inode=403024 dev=fc:01 mode=dir,755 ouid=webalizer ogid=root rdev=00:00 obj=system_u:object_r:webalizer_var_lib_t:s0 nametype=PARENT cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=CWD msg=audit(09/18/2019 10:31:01.051:439) : cwd=/var/www/usage 
type=SYSCALL msg=audit(09/18/2019 10:31:01.051:439) : arch=x86_64 syscall=openat success=yes exit=4 a0=0xffffff9c a1=0x5592dac77310 a2=O_RDWR|O_CREAT|O_EXCL a3=0x1a4 items=2 ppid=126216 pid=126217 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=webalizer exe=/usr/bin/webalizer subj=system_u:system_r:webalizer_t:s0-s0:c0.c1023 key=(null) 
type=AVC msg=audit(09/18/2019 10:31:01.051:439) : avc:  denied  { dac_override } for  pid=126217 comm=webalizer capability=dac_override  scontext=system_u:system_r:webalizer_t:s0-s0:c0.c1023 tcontext=system_u:system_r:webalizer_t:s0-s0:c0.c1023 tclass=capability permissive=1 
----
type=PROCTITLE msg=audit(09/18/2019 10:31:01.106:440) : proctitle=/usr/bin/webalizer -v 
type=PATH msg=audit(09/18/2019 10:31:01.106:440) : item=1 name=daily_usage_201909.png inode=277596 dev=fc:01 mode=file,644 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:webalizer_rw_content_t:s0 nametype=CREATE cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=PATH msg=audit(09/18/2019 10:31:01.106:440) : item=0 name=/var/www/usage inode=277554 dev=fc:01 mode=dir,755 ouid=webalizer ogid=root rdev=00:00 obj=system_u:object_r:webalizer_rw_content_t:s0 nametype=PARENT cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=CWD msg=audit(09/18/2019 10:31:01.106:440) : cwd=/var/www/usage 
type=SYSCALL msg=audit(09/18/2019 10:31:01.106:440) : arch=x86_64 syscall=openat success=yes exit=3 a0=0xffffff9c a1=0x7ffd50795ff0 a2=O_WRONLY|O_CREAT|O_TRUNC a3=0x1b6 items=2 ppid=126216 pid=126217 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=webalizer exe=/usr/bin/webalizer subj=system_u:system_r:webalizer_t:s0-s0:c0.c1023 key=(null) 
type=AVC msg=audit(09/18/2019 10:31:01.106:440) : avc:  denied  { write open } for  pid=126217 comm=webalizer path=/var/www/usage/daily_usage_201909.png dev="vda1" ino=277596 scontext=system_u:system_r:webalizer_t:s0-s0:c0.c1023 tcontext=system_u:object_r:webalizer_rw_content_t:s0 tclass=file permissive=1 
type=AVC msg=audit(09/18/2019 10:31:01.106:440) : avc:  denied  { create } for  pid=126217 comm=webalizer name=daily_usage_201909.png scontext=system_u:system_r:webalizer_t:s0-s0:c0.c1023 tcontext=system_u:object_r:webalizer_rw_content_t:s0 tclass=file permissive=1 
type=AVC msg=audit(09/18/2019 10:31:01.106:440) : avc:  denied  { add_name } for  pid=126217 comm=webalizer name=daily_usage_201909.png scontext=system_u:system_r:webalizer_t:s0-s0:c0.c1023 tcontext=system_u:object_r:webalizer_rw_content_t:s0 tclass=dir permissive=1 
type=AVC msg=audit(09/18/2019 10:31:01.106:440) : avc:  denied  { write } for  pid=126217 comm=webalizer name=usage dev="vda1" ino=277554 scontext=system_u:system_r:webalizer_t:s0-s0:c0.c1023 tcontext=system_u:object_r:webalizer_rw_content_t:s0 tclass=dir permissive=1 
----
type=PROCTITLE msg=audit(09/18/2019 10:31:01.108:441) : proctitle=/usr/bin/webalizer -v 
type=SYSCALL msg=audit(09/18/2019 10:31:01.108:441) : arch=x86_64 syscall=fstat success=yes exit=0 a0=0x3 a1=0x7ffd50795390 a2=0x7ffd50795390 a3=0x310 items=0 ppid=126216 pid=126217 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=webalizer exe=/usr/bin/webalizer subj=system_u:system_r:webalizer_t:s0-s0:c0.c1023 key=(null) 
type=AVC msg=audit(09/18/2019 10:31:01.108:441) : avc:  denied  { getattr } for  pid=126217 comm=webalizer path=/var/www/usage/daily_usage_201909.png dev="vda1" ino=277596 scontext=system_u:system_r:webalizer_t:s0-s0:c0.c1023 tcontext=system_u:object_r:webalizer_rw_content_t:s0 tclass=file permissive=1 
----

Comment 2 Richard Fiľo 2019-09-18 15:58:38 UTC
# cat mymodule.te

policy_module(mymodule, 1.0)

require {
	type webalizer_t;
	class capability dac_override;
}

allow webalizer_t self:capability dac_override;
dev_list_sysfs(webalizer_t)
#

I propose this fix.

Comment 3 Lukas Vrabec 2019-09-20 10:40:25 UTC
commit 0236d5402bf5751128a347043b68a6dc959d7f0a (HEAD -> rawhide, origin/rawhide, origin/HEAD)
Author: Richard Filo <rfilo>
Date:   Thu Sep 19 15:47:08 2019 +0200

    Update webalizer_t SELinux policy
    
    Allow processes labeled as webalizer_t to list sysfs_t files.
    Allow processes labeled as webalizer_t to read/write webalizer_rw_content_t  files.

Comment 4 Ben Cotton 2019-10-31 18:49:33 UTC
This message is a reminder that Fedora 29 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 29 on 2019-11-26.
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 '29'.

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 29 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 Ben Cotton 2019-11-27 23:27:14 UTC
Fedora 29 changed to end-of-life (EOL) status on 2019-11-26. Fedora 29 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.


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