Skip to content

SELinux Denial Triggered by Unused Collectors in cAdvisor #3598

Open

Description

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: container_oom_events_total always returns 0 #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:

  • If a specific collector (e.g., resctrl or OOM) is not being used, cAdvisor should not attempt to initialize or access resources requiring additional permissions.
    For example, the initialization of the resctrl collector happens here

    newManager.resctrlManager, err = resctrl.NewManager(resctrlInterval, resctrl.Setup, machineInfo.CPUVendorID, inHostNamespace)

    Despite the collector being disabled, cAdvisor still attempts a getattr operation on the sysfs directory
    rootResctrl, err = intelrdt.Root()

  • SELinux denials should only occur when a collector is actively being used, and cAdvisor should request the necessary permissions only when the collector is enabled.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions