fix: reuse cgroup2 superblock options when mount cgroupfs #692
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
the cgroup2 mount in __cg_mount_direct() previously ignored the superblock options applied on the existing cgroup2 mountpoint. This caused the newly created cgroup2 mount to miss important options such as nsdelegate, memory_localevents, and memory_recursiveprot, which may affect controller behavior and result in inconsistent semantics across mount points.
This patch introduces extract_cgroup2_super_opts() to locate the first relevant cgroup2 superblock option in the existing mount options string, and get_mount_opts() to retrieve the mount options for a given target and filesystem type from /proc/self/mounts. These helpers allow the new mount to inherit the same superblock configuration as the system's primary cgroup2 mount.