Skip to content

Fix/cgroup2 bind mount shared cgroupns#5267

Open
xujihui1985 wants to merge 2 commits intoopencontainers:mainfrom
xujihui1985:fix/cgroup2-bind-mount-shared-cgroupns
Open

Fix/cgroup2 bind mount shared cgroupns#5267
xujihui1985 wants to merge 2 commits intoopencontainers:mainfrom
xujihui1985:fix/cgroup2-bind-mount-shared-cgroupns

Conversation

@xujihui1985
Copy link
Copy Markdown
Contributor

When cgroup namespaces is host, mounting a new cgroup2 fs instance for /sys/fs/cgroup can affect the host-visible cgroupfs mount state, including options such as nsdelegate.

Avoid that by preferring a bind mount of the existing cgroup v2 hierarchy when cgroupns is host. Keep the existing cgroup2 mount-first logic for private cgroup namespaces, including the EPERM/EBUSY fallback to a bind mount and the rootless ENOENT masking behavior.

this PR fix issue #5258

@xujihui1985 xujihui1985 force-pushed the fix/cgroup2-bind-mount-shared-cgroupns branch 2 times, most recently from ecc4ae8 to 9a08cc5 Compare May 3, 2026 06:55
When cgroup namespaces is host, mounting a new cgroup2 fs instance for
/sys/fs/cgroup can affect the host-visible cgroupfs mount state, including
options such as nsdelegate.

Avoid that by preferring a bind mount of the existing cgroup v2 hierarchy
when cgroupns is host. Keep the existing cgroup2 mount-first logic
for private cgroup namespaces, including the EPERM/EBUSY fallback to a
bind mount and the rootless ENOENT masking behavior.

Signed-off-by: sean <xujihui1985@gmail.com>
in host cgroupns, mount cgroupfs should not mutate the global superblock
mount options, the test is to check when create container with host
cgroupns, it should not mutate the global superblock options of host
cgroupfs

Signed-off-by: sean <xujihui1985@gmail.com>
@xujihui1985 xujihui1985 force-pushed the fix/cgroup2-bind-mount-shared-cgroupns branch from 9a08cc5 to 922bd42 Compare May 3, 2026 07:21
@xujihui1985
Copy link
Copy Markdown
Contributor Author

@lifubang Hi fubang, This PR fixes #5258. I’ve checked the failing CI and it doesn’t seem related to these changes. Please review it when you have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant