Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e1d1e87

Browse files
specify cgroup ownership semantics
cgroups v2 supports secure delegation of cgroups. Accordingly, control over a cgroup (that is, creation of new child cgroups and movement of processes and threads among the cgroup subtree exposed to a container) can be safely delegated to a container. Adjusting the ownership enables real-world use cases like systemd-based containers fully isolated in user namespaces. To encourage adoption of this feature, and secure implementation, define the semantics of cgroup ownership. Changing/setting the cgroup ownership should only be performed when using cgroups v2 and when the cgroupfs will be mounted read/write. The specific files whose ownership should be change are mentioned. In terms of current practice, this is already the behaviour of crun (which also chown's the memory.oom.group file), and there is a pull request for runc: opencontainers/runc#3057. Signed-off-by: Fraser Tweedale <[email protected]>
1 parent 0d6cc58 commit e1d1e87

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

config-linux.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,39 @@ For example, to run a new process in an existing container without updating limi
196196

197197
Runtimes MAY attach the container process to additional cgroup controllers beyond those necessary to fulfill the `resources` settings.
198198

199+
### Cgroup ownership
200+
201+
Runtimes MAY change (or cause to be changed) the owner of the
202+
container's cgroup to the host uid that maps to uid 0 in the
203+
container's user namespace, according to the following rules.
204+
205+
Runtimes SHOULD NOT change the ownership of container cgroups when
206+
cgroups v1 is in use. Cgroup delegation is not secure in cgroups
207+
v1.
208+
209+
Runtimes SHOULD change the cgroup ownership if and only if the
210+
cgroup filesystem is to be mounted read/write; that is, when the
211+
configuration's `mounts` array contains an object where:
212+
213+
- The `source` field is equal to `"cgroup"`
214+
- The `destination` field is equal to `"/sys/fs/cgroup"`
215+
- The `options` field does not contain the value `"ro"`
216+
217+
If the configuration does not specify such a mount, the runtime
218+
SHOULD NOT change the cgroup ownership.
219+
220+
A runtime that changes the cgroup ownership SHOULD only change the
221+
ownership of the container's cgroup directory and the following
222+
files within that directory:
223+
224+
- `cgroup.procs`
225+
- `cgroup.subtree_control`
226+
- `cgroup.threads`
227+
228+
The runtime SHOULD NOT change the ownership of any other files.
229+
Changing other files may allow the container to elevate its own
230+
resource limits or perform other unwanted behaviour.
231+
199232
### Example
200233

201234
```json

0 commit comments

Comments
 (0)