Skip to contentSkip to conversation

Has anyone ever looked into adding labeling support for the cgroup file system

DISCUSSION Daniel J Walsh 3 participants 4 messages Jan 17, 2017 – Jan 18, 2017 SELinux security module

lore
Share & tools
lore
#0 lore raw

In order to allow processes to modify the cgroup hierarchy in a container from an SELinux point of view, we need to allow read/write access to cgroup_t, which means that a container process could break out and modify all cgroups, we want to allow them to only modify the portion of the hierarchy handed to them.

Would be a nice security improvement for docker.

#1 lore raw
Quoted 9 lines · Daniel J Walsh

In order to allow processes to modify the cgroup hierarchy in a container from an SELinux point of view, we need to allow read/write access to cgroup_t, which means that a container process could break out
and modify all cgroups, we want to allow them to only modify the portion
of the hierarchy handed to them.

Would be a nice security improvement for docker.

Probably as easy as adding cgroup to the list of filesystem types that use genfscon but also support setxattr (like sysfs) in selinux_is_sblabel_mnt() in security/selinux/hooks.c.  sysfs and cgroup are both implemented on top of kernfs in modern kernels, so they should both support proper setting of security labels.

maintainer
#2 lore raw
Quoted 9 lines · Stephen Smalley
Quoted 8 lines · Daniel J Walsh

In order to allow processes to modify the cgroup hierarchy in a container from an SELinux point of view, we need to allow read/write access to cgroup_t, which means that a container process could break out
and modify all cgroups, we want to allow them to only modify the portion
of the hierarchy handed to them.

Quoted 7 lines
Quoted 1 line

Would be a nice security improvement for docker.

Probably as easy as adding cgroup to the list of filesystem types that use genfscon but also support setxattr (like sysfs) in selinux_is_sblabel_mnt() in security/selinux/hooks.c. sysfs and cgroup are both implemented on top of kernfs in modern kernels, so they should both support proper setting of security labels.

... and a test should be added to the selinux-testsuite.

Come on Dan, you know you want to write some more kernel code ;)

Signature · 2 lines
paul moore
www.paul-moore.com
#3 lore raw

I believe in the Tom Sawyer method of writing code. Suggest a neat idea and wait for some else to "Whitewash the fence" ie write the patches.

Quoted 20 lines · Paul Moore
Quoted 9 lines · Stephen Smalley
Quoted 8 lines · Daniel J Walsh

In order to allow processes to modify the cgroup hierarchy in a container from an SELinux point of view, we need to allow read/write access to cgroup_t, which means that a container process could break out
and modify all cgroups, we want to allow them to only modify the portion
of the hierarchy handed to them.

Quoted 6 lines
Quoted 1 line

Would be a nice security improvement for docker.

Probably as easy as adding cgroup to the list of filesystem types that use genfscon but also support setxattr (like sysfs) in selinux_is_sblabel_mnt() in security/selinux/hooks.c. sysfs and cgroup are both implemented on top of kernfs in modern kernels, so they should both support proper setting of security labels.

.. and a test should be added to the selinux-testsuite.

Come on Dan, you know you want to write some more kernel code ;)