Skip to content

Cgroups

Linux has two cgroup implementations. rustbox supports both and auto-detects:

  1. /sys/fs/cgroup/cgroup.controllers exists → v2
  2. /sys/fs/cgroup/memory exists → v1
  3. Neither → no cgroup support (permissive mode only)

The selection is logged so you always know which backend is active.

Inside Docker, cgroup access is restricted:

  • Probe before use. We test writability, never assume.
  • Permissive fallback. Can’t create a cgroup? Warn and continue. Seccomp and namespaces still work.
  • Strict mode fails. No cgroups + strict mode = rejected execution.
Resourcev2v1
Memorymemory.maxmemory.limit_in_bytes
CPUcpu.max (quota/period)cpu.cfs_quota_us
Processespids.maxpids.max
OOM detectionmemory.eventsmemory.oom_control
CPU usagecpu.stat (usage_usec)cpuacct.usage
Memory peakmemory.peakmemory.max_usage_in_bytes

Each sandbox gets its own cgroup with a sanitised instance ID. Path traversal characters in instance IDs are rejected. On cleanup, all processes in the cgroup are killed before removal.