Skip to content

docker.sock mislabeling #375

@mielas

Description

@mielas

After upgrading the container-selinux package on RHEL/OL9 from version 2.229.0 to 2.232.1, the SELinux context of /var/run/docker.sock changes from container_var_run_t to var_run_t. The change in behavior appears to be caused by the following modification in the file context policy:

- /var/run/docker\.sock    -s  gen_context(system_u:object_r:container_var_run_t,s0)
+ /run/docker\.sock        -s  gen_context(system_u:object_r:container_var_run_t,s0)

Although there is a path equivalency rule (/run = /var/run), this change does not work as intended. It looks like SELinux expects file context rules to use /var/run and not /run path. As a result, matchpathcon reports:

matchpathcon /var/run/docker.sock /run/docker.sock

/run/docker.sock          system_u:object_r:var_run_t:s0
/var/run/docker.sock      system_u:object_r:var_run_t:s0

At the same time, adding a rule:

/var/run/docker2\.sock                             socket             system_u:object_r:container_var_run_t:s0 

makes matchpathcon choosing the SELinux context properly:

matchpathcon /var/run/docker2.sock /run/docker2.sock

/var/run/docker2.sock	system_u:object_r:container_var_run_t:s0
/run/docker2.sock	system_u:object_r:container_var_run_t:s0

Metadata

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