Documentation/cgroup-v2: warn about cgroup.kill / cgroup.freeze delegation
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): ftvtv7lv6gh6tfzabant74ncmtqjuljr3xfjxn5evaehwzhy56@kuf4jiwchuie
PATCH 1/1 Documentation/cgroup-v2: warn about cgroup.kill / cgroup.freeze delegation
From: Maoyi Xie <[email protected]>
cgroup.kill and cgroup.freeze act on every process in the cgroup or its descendants without checking the writer's signal authority over those processes. Delegating either file (by chown, or by passing an open file descriptor) therefore grants the recipient unconditional kill or freeze authority over whatever ends up in the subtree.
This works as intended: the files are deliberate "delegated control" knobs, and the standard signal-permission rules of kill(2) and SIGSTOP do not apply. The current text in Documentation/admin-guide/cgroup-v2.rst describes the behaviour of cgroup.kill and cgroup.freeze in functional terms but does not flag the delegation footgun, which makes it easy for runtime authors to hand the files to a less-privileged user without realising the implications.
Add a paragraph to each section explicitly calling out the delegation contract and the open-FD equivalence, so runtime authors have a single place to read the rule before deciding whether to chown or pass FDs to these files.
No code change.
--- Documentation/admin-guide/cgroup-v2.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Documentation/admin-guide/cgroup-v2.rst +18 -0
@@ -1048,6 +1048,15 @@ All cgroup core files are prefixed with "cgroup." it's possible to delete a frozen (and empty) cgroup, as well as create new sub-cgroups. + A write to cgroup.freeze affects every process currently in the + cgroup or its descendants regardless of the writer's signal + authority over those processes. The file therefore acts as a + delegated stop knob: chowning it, or passing an open file + descriptor to it, grants the recipient unconditional freeze + authority over whatever lands in the subtree. Runtime authors + should not delegate cgroup.freeze outside of the trust boundary + of the cgroup itself. + cgroup.kill A write-only single value file which exists in non-root cgroups. The only allowed value is "1".
@@ -1063,6 +1072,15 @@ All cgroup core files are prefixed with "cgroup." killing cgroups is a process directed operation, i.e. it affects the whole thread-group. + A write to cgroup.kill sends SIGKILL to every process currently + in the cgroup or its descendants regardless of the writer's + signal authority over those processes. The file therefore acts + as a delegated kill knob: chowning it, or passing an open file + descriptor to it, grants the recipient unconditional kill + authority over whatever lands in the subtree. Runtime authors + should not delegate cgroup.kill outside of the trust boundary + of the cgroup itself. + cgroup.pressure A read-write single value file that allowed values are "0" and "1". The default is "1".
Signature · 1 line
2.34.1
Tejun Heo
maintainerDocumentation/admin-guide/cgroup-v2.rst All cgroup core files are prefixed with "cgroup." · line 1058
Quoted 8 lines · Maoyi Xie
Documentation/admin-guide/cgroup-v2.rst +8
-0+ A write to cgroup.freeze affects every process currently in the + cgroup or its descendants regardless of the writer's signal + authority over those processes. The file therefore acts as a + delegated stop knob: chowning it, or passing an open file + descriptor to it, grants the recipient unconditional freeze + authority over whatever lands in the subtree. Runtime authors + should not delegate cgroup.freeze outside of the trust boundary + of the cgroup itself.
For example, if you delegate a memory control file, whoever can write to it can control memory distribution over everyone in the cgroup too regardless of their UID. Here's an excerpt from "Model of Delegation" section:
Because the resource control interface files in a given directory control the distribution of the parent's resources, the delegatee shouldn't be allowed to write to them.
These threads basically amount to "if I give SUID to bash, I get a root shell". Please stop.
Thanks.
Signature · 1 line
tejun