Skip to content

packaging(systemd): add cgroup to RestrictNamespaces (closes #163)#184

Merged
WaylandYang merged 1 commit into
mainfrom
fix/163-systemd-cgroup-namespace
May 28, 2026
Merged

packaging(systemd): add cgroup to RestrictNamespaces (closes #163)#184
WaylandYang merged 1 commit into
mainfrom
fix/163-systemd-cgroup-namespace

Conversation

@WaylandYang
Copy link
Copy Markdown
Contributor

Closes #163. Thanks @mrvellang for catching the latent trap.

`RestrictNamespaces` is an allowlist — anything not enumerated returns `EPERM` on `unshare`/`clone`. Two changes to `packaging/systemd/forkd-controller.service`:

  1. Add `cgroup` to the allowlist. Without it, the moment we wire up per-child cgroup-v2 namespaces (the natural next step for fork-out isolation, and one we're sketching for v0.4 — see `DESIGN-v0.4-USER-API.md`), `unshare(CLONE_NEWCGROUP)` silently returns `EPERM` from inside the service. The kind of trap that costs an afternoon to debug, exactly as systemd unit: RestrictNamespaces=net mnt user pid blocks cgroup namespace #163 warned.

  2. Inline-comment each token (net / mnt / user / pid / cgroup) explaining why it's there. The previous one-line directive made each token equally easy to remove on a future hardening pass; now a reviewer can see what gates what.

No behaviour change today — the controller doesn't yet `unshare(CLONE_NEWCGROUP)`. This unblocks future per-child cgroup namespacing without surfacing the EPERM at the worst moment.

…oken

Closes #163. Thanks to @mrvellang for catching the latent trap.

RestrictNamespaces is an allowlist — anything not enumerated returns
EPERM on unshare/clone. Two changes:

1. Add `cgroup` to the allowlist. Without it, the moment we wire up
   per-child cgroup-v2 namespaces (the natural next step for fork-out
   isolation), `unshare(CLONE_NEWCGROUP)` silently returns EPERM. As
   #163 notes, the kind of trap that costs an afternoon to debug.

2. Inline-comment each token (net / mnt / user / pid / cgroup) so a
   future well-intentioned hardening pass doesn't quietly remove one
   without noticing what it gates.
@WaylandYang WaylandYang merged commit f3df87d into main May 28, 2026
2 checks passed
@WaylandYang WaylandYang deleted the fix/163-systemd-cgroup-namespace branch May 28, 2026 17:14
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.

systemd unit: RestrictNamespaces=net mnt user pid blocks cgroup namespace

1 participant