Skip to content

[release/2.1] Preserve cgroup mount options for privileged containers#13119

Merged
mxpv merged 4 commits intocontainerd:release/2.1from
k8s-infra-cherrypick-robot:cherry-pick-12952-to-release/2.1
Mar 25, 2026
Merged

[release/2.1] Preserve cgroup mount options for privileged containers#13119
mxpv merged 4 commits intocontainerd:release/2.1from
k8s-infra-cherrypick-robot:cherry-pick-12952-to-release/2.1

Conversation

@k8s-infra-cherrypick-robot
Copy link
Copy Markdown

@k8s-infra-cherrypick-robot k8s-infra-cherrypick-robot commented Mar 25, 2026

This is an automated cherry-pick of #12952

/assign chrishenzie

Preserve host cgroup mount options for privileged containers

Moves cgroup namespace addition logic higher in buildLinuxSpec so it
runs before any custom spec adjusters (such as WithMounts).

This is necessary because subsequent spec adjusters may want to inspect
the set of namespaces to make decisions (e.g., configuring mount options
based on whether or not they are shared with the host).

Signed-off-by: Chris Henzie <[email protected]>
Privileged containers don't have a cgroup namespace and share the host's
cgroup namespace. Mounting cgroup2 inside these containers can
inadvertently alter the host's cgroup2 VFS superblock mount options
because they are shared.

To prevent this, update WithMounts to read the host's /sys/fs/cgroup
mount options and explicitly propagate nsdelegate and
memory_recursiveprot into the container's mount spec. This avoids
stripping them on the host when they are not in the hardcoded default
set.

Signed-off-by: Chris Henzie <[email protected]>
Update Vagrantfile and cri-integration test runner to forward
RUNC_FLAVOR to the test environment.

Allows integration tests to conditionally skip testing certain cgroup
mount setups when running against other runtimes that may not support
them yet.

Signed-off-by: Chris Henzie <[email protected]>
Verifies that running a privileged container does not alter host cgroup
mount options (specifically nsdelegate and memory_recursiveprot).

Creates a privileged sandbox and container, starts it, and compares the
host's /sys/fs/cgroup mount options before and after execution to
guarantee safety.

Signed-off-by: Chris Henzie <[email protected]>
@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Mar 25, 2026
@mxpv mxpv merged commit 47c68df into containerd:release/2.1 Mar 25, 2026
50 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cri Container Runtime Interface (CRI) impact/changelog size/L

Projects

Development

Successfully merging this pull request may close these issues.

5 participants