Skip to content

cgroup2: fail loudly when cgroup_net_cls_classid is set under cgroup v2 - #403

Open
Nexory wants to merge 1 commit into
google:masterfrom
Nexory:fix/cgroup2-fail-loudly-when-cgroup-net-cls-classid
Open

Nexory wants to merge 1 commit into
google:masterfrom
Nexory:fix/cgroup2-fail-loudly-when-cgroup-net-cls-classid

Conversation

@Nexory

@Nexory Nexory commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

With --use_cgroupv2 (or --detect_cgroupv2 on a v2 host) and --cgroup_net_cls_classid set, nsjail starts the jail without an error or a warning and never applies the class id, because net_cls is a cgroup v1 controller and cgroup2.cc has no handling for it.

This refuses to start in that case, right after the cgroup version is known, and corrects the README line that listed net_cls under v1 and v2. If you would rather have a warning, I am happy to switch.

The new run_test cases use an empty stub cgroup root; the one with a class id exits 255 with this change and 0 without it.

net_cls is a cgroup v1 controller and cgroup2.cc has no net_cls handling.
With use_cgroupv2 (or detect_cgroupv2 on a v2 host) and
cgroup_net_cls_classid set, nsjail started the jail without any error or
warning and never applied the class id.

Refuse to start instead, right after the cgroup version is known. The
README listed net_cls under "v1 and v2"; correct that. The new run_test
cases use tests/cgroupv2, an empty stub cgroup root, so they do not depend
on the host's cgroups.

Before: nsjail -Mo --use_cgroupv2 --cgroup_net_cls_classid 5 -- /bin/true
exits 0 with no message about the class id. After: it exits 255 with
"cgroup_net_cls_classid is not supported with cgroup v2". The v1 path and
cgroup v2 without a class id behave as before.

This branch has not been deployed

No deployments
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