RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2098130 - SELinux prevents the keepalived process from reading the /sys/devices/system/cpu/ directory
Summary: SELinux prevents the keepalived process from reading the /sys/devices/system/...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: selinux-policy
Version: 9.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 9.1
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-06-17 11:13 UTC by Phil Randal
Modified: 2022-11-15 12:58 UTC (History)
6 users (show)

Fixed In Version: selinux-policy-34.1.38-1.el9
Doc Type: No Doc Update
Doc Text:
Clone Of:
: 2098189 (view as bug list)
Environment:
Last Closed: 2022-11-15 11:13:54 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github fedora-selinux selinux-policy pull 1261 0 None open Allow keepalived read the contents of the sysfs filesystem 2022-06-27 11:32:06 UTC
Red Hat Issue Tracker RHELPLAN-125582 0 None None None 2022-06-17 11:22:09 UTC
Red Hat Product Errata RHBA-2022:8283 0 None None None 2022-11-15 11:14:02 UTC

Description Phil Randal 2022-06-17 11:13:44 UTC
Description of problem:

When keepalived is configured with vrrp_track_process it blocks:

"SELinux is preventing /usr/sbin/keepalived from read access on the directory cpu"

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

selinux-policy-targeted-34.1.29-1.el9_0.noarch

How reproducible:

Always with vrrp_track_process specified

Steps to Reproduce:
1. Include the following in /etc/keepalived.conf and start/restart keepalived

vrrp_track_process track_haproxy {
   process haproxy
   quorum 1
   delay 2
   weight 2
}



Actual results:
Audit message:

type=AVC msg=audit(1655463371.358:560): avc:  denied  { read } for  pid=49217 comm="keepalived" name="cpu" dev="sysfs" ino=39 scontext=system_u:system_r:keepalived_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=dir permissive=0


Expected results:

Access to be allowed

Additional info:

$ sealert -l 39724f30-9243-4b87-98c7-7cbab2fb8745
SELinux is preventing /usr/sbin/keepalived from read access on the directory cpu.

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

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


Additional Information:
Source Context                system_u:system_r:keepalived_t:s0
Target Context                system_u:object_r:sysfs_t:s0
Target Objects                cpu [ dir ]
Source                        keepalived
Source Path                   /usr/sbin/keepalived
Port                          <Unknown>
Host                          xxxx
Source RPM Packages           keepalived-2.2.4-2.el9.x86_64
Target RPM Packages
SELinux Policy RPM            selinux-policy-targeted-34.1.29-1.el9_0.noarch
Local Policy RPM              selinux-policy-targeted-34.1.29-1.el9_0.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing


Raw Audit Messages

type=AVC msg=audit(1655463371.358:560): avc:  denied  { read } for  pid=49217 comm="keepalived" name="cpu" dev="sysfs" ino=39 scontext=system_u:system_r:keepalived_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=dir permissive=0


type=SYSCALL msg=audit(1655463371.358:560): arch=x86_64 syscall=openat success=no exit=EACCES a0=ffffff9c a1=7f688a001c3f a2=90800 a3=0 items=0 ppid=49216 pid=49217 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=keepalived exe=/usr/sbin/keepalived subj=system_u:system_r:keepalived_t:s0 key=(null)

Hash: keepalived,keepalived_t,sysfs_t,dir,read

Comment 1 Milos Malik 2022-06-17 12:19:47 UTC
The following SELinux denial appears in enforcing mode:
----
type=PROCTITLE msg=audit(06/17/2022 08:17:29.609:334) : proctitle=/usr/sbin/keepalived --dont-fork -D 
type=PATH msg=audit(06/17/2022 08:17:29.609:334) : item=0 name=/sys/devices/system/cpu inode=39 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(06/17/2022 08:17:29.609:334) : cwd=/ 
type=SYSCALL msg=audit(06/17/2022 08:17:29.609:334) : arch=x86_64 syscall=openat success=no exit=EACCES(Permission denied) a0=AT_FDCWD a1=0x7f9af5bf9c3f a2=O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC a3=0x0 items=1 ppid=4413 pid=4415 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=keepalived exe=/usr/sbin/keepalived subj=system_u:system_r:keepalived_t:s0 key=(null) 
type=AVC msg=audit(06/17/2022 08:17:29.609:334) : avc:  denied  { read } for  pid=4415 comm=keepalived name=cpu dev="sysfs" ino=39 scontext=system_u:system_r:keepalived_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=dir permissive=0 
----

# rpm -qa selinux\* keepalived\* | sort
keepalived-2.2.4-2.el9.x86_64
selinux-policy-34.1.34-1.el9.noarch
selinux-policy-targeted-34.1.34-1.el9.noarch
#

Comment 2 Milos Malik 2022-06-17 12:22:05 UTC
The following SELinux denial appears in permissive mode:
----
type=PROCTITLE msg=audit(06/17/2022 08:19:59.448:341) : proctitle=/usr/sbin/keepalived --dont-fork -D 
type=PATH msg=audit(06/17/2022 08:19:59.448:341) : item=0 name=/sys/devices/system/cpu inode=39 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(06/17/2022 08:19:59.448:341) : cwd=/ 
type=SYSCALL msg=audit(06/17/2022 08:19:59.448:341) : arch=x86_64 syscall=openat success=yes exit=12 a0=AT_FDCWD a1=0x7ff4be2afc3f a2=O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC a3=0x0 items=1 ppid=4449 pid=4451 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=keepalived exe=/usr/sbin/keepalived subj=system_u:system_r:keepalived_t:s0 key=(null) 
type=AVC msg=audit(06/17/2022 08:19:59.448:341) : avc:  denied  { read } for  pid=4451 comm=keepalived name=cpu dev="sysfs" ino=39 scontext=system_u:system_r:keepalived_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=dir permissive=1 
----

# ls -ldZ /sys/devices/system/cpu
drwxr-xr-x. 9 root root system_u:object_r:sysfs_t:s0 0 Jun 17 04:18 /sys/devices/system/cpu
# ls -lZ /sys/devices/system/cpu
total 0
drwxr-xr-x. 6 root root system_u:object_r:sysfs_t:s0         0 Jun 17 04:18 cpu0
drwxr-xr-x. 2 root root system_u:object_r:sysfs_t:s0         0 Jun 17 04:18 cpufreq
drwxr-xr-x. 2 root root system_u:object_r:sysfs_t:s0         0 Jun 17 04:18 cpuidle
drwxr-xr-x. 2 root root system_u:object_r:sysfs_t:s0         0 Jun 17 04:18 hotplug
-r--r--r--. 1 root root system_u:object_r:sysfs_t:s0      4096 Jun 17 04:18 isolated
-r--r--r--. 1 root root system_u:object_r:sysfs_t:s0      4096 Jun 17 04:18 kernel_max
-r--r--r--. 1 root root system_u:object_r:sysfs_t:s0      4096 Jun 17 04:18 modalias
-r--r--r--. 1 root root system_u:object_r:sysfs_t:s0      4096 Jun 17 04:18 nohz_full
-r--r--r--. 1 root root system_u:object_r:sysfs_t:s0      4096 Jun 17 04:18 offline
-r--r--r--. 1 root root system_u:object_r:cpu_online_t:s0 4096 Jun 17 04:18 online
-r--r--r--. 1 root root system_u:object_r:sysfs_t:s0      4096 Jun 17 04:18 possible
drwxr-xr-x. 2 root root system_u:object_r:sysfs_t:s0         0 Jun 17 04:18 power
-r--r--r--. 1 root root system_u:object_r:sysfs_t:s0      4096 Jun 17 04:18 present
drwxr-xr-x. 2 root root system_u:object_r:sysfs_t:s0         0 Jun 17 04:18 smt
-rw-r--r--. 1 root root system_u:object_r:sysfs_t:s0      4096 Jun 17 04:18 uevent
drwxr-xr-x. 2 root root system_u:object_r:sysfs_t:s0         0 Jun 17 04:18 vulnerabilities
#

Comment 3 Milos Malik 2022-06-17 12:29:01 UTC
The same issue is reproducible on RHEL-8.

Comment 4 Milos Malik 2022-06-17 14:20:36 UTC
Here is the RHEL-8 clone of this BZ:
 * https://bugzilla.redhat.com/show_bug.cgi?id=2098189

Comment 16 errata-xmlrpc 2022-11-15 11:13:54 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 (selinux-policy bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:8283


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