google / cadvisor

Analyzes resource usage and performance characteristics of running containers.
Other
17.25k stars 2.33k forks source link

SELinux Denial Triggered by Unused Collectors in cAdvisor #3598

Open rushilenekar20 opened 2 months ago

rushilenekar20 commented 2 months ago

System:

[root@machine /]# hostnamectl Static hostname: machine Icon name: computer-server Chassis: server Machine ID: 3342db489c014533b01ac7ebf64a59e0 Boot ID: cffcc4cf0a9141dd871335c015f0650a Operating System: Red Hat Enterprise Linux 8.8 (Ootpa) CPE OS Name: cpe:/o:redhat:enterprise_linux:8::baseos Kernel: Linux 4.18.0-477.55.1.el8_8.x86_64 Architecture: x86-64

[root@machine /]# cadvisor --version cAdvisor version v0.49.1

Description: We are encountering SELinux denial messages when cAdvisor attempts to perform certain operations, such as getattr on /sys/fs/resctrl and attempting to access /dev/kmsg for reading OOM events, even though the relevant collectors are not being used. Specifically:

  1. getattr on /sys/fs/resctrl: This occurs during the initialization of the resource_control manager, which checks whether Intel RDT (Resource Director Technology) is supported. However, we do not use the resctrl collector, nor do we wish to grant the required permissions. For example audit log avc: denied { getattr } for pid=383168 comm="cadvisor" name="/" dev="sysfs" ino=1 scontext=system_u:system_r:cadvisor_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=filesystem permissive=0

  2. Capability on syslog (/dev/kmsg): This happens when cAdvisor attempts to read OOM events for containers, even though the container_oom_events_total metric is known to always return 0 (related defect: https://github.com/google/cadvisor/issues/3015). For example audit log avc: denied { syslog } for pid=383951 comm="cadvisor" capability=34 scontext=system_u:system_r:cadvisor_t:s0 tcontext=system_u:system_r:cadvisor_t:s0 tclass=capability2 permissive=0 avc: denied { sys_admin } for pid=383951 comm="cadvisor" capability=21 scontext=system_u:system_r:cadvisor_t:s0 tcontext=system_u:system_r:cadvisor_t:s0 tclass=capability

Expected Behavior:

This will help avoid unnecessary SELinux denials and ensure that permission issues arise only when relevant features are in use.