carlos / platform Public

host: the fd probe allows the child runtime's own cgroup CPU file

TestRegistryChildPinnedExecutableAndMinimalFDs failed on every CI run
with exit 22, now named: fd 4 -> /sys/fs/cgroup/.../cpu.max. Since Go
1.25 the runtime holds its cgroup's CPU limit file open (quotaFD in
internal/runtime/cgroup) to keep GOMAXPROCS in step with the limit.
The child opens that itself, close-on-exec, so it isn't anything the
parent leaked. Every CI job's cgroup sets a CPU limit; DOCS-T1's
session does not, which is why it passed there. The probe now accepts
cpu.max (and v1's cpu.cfs_quota_us/period_us) under /sys/fs/cgroup.

Reproduced by running the test in systemd-run --user --scope -p
CPUQuota=400%: it fails before and passes after. It still catches a
real leak: without registryChildCloseExec the probe reports the
must-not-inherit file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 526c35cbfaa0d45fc2b89a6b9136f098269f7fcc parent 14a92c2
1 file changed, +18 −1
  • internal/host/registrychild_exec_linux_test.go +18 −1
diff --git a/internal/host/registrychild_exec_linux_test.go b/internal/host/registrychild_exec_linux_test.go
index e05eb389d..ce59fd757 100644
--- a/internal/host/registrychild_exec_linux_test.go
+++ b/internal/host/registrychild_exec_linux_test.go
@@ -137,7 +137,7 @@ func TestRegistryChildFDHelper(t *testing.T) {
if err != nil {
os.Exit(21)
}
- if target != "anon_inode:[eventpoll]" && target != "anon_inode:[eventfd]" {
+ if target != "anon_inode:[eventpoll]" && target != "anon_inode:[eventfd]" && !goRuntimeCgroupFD(target) {
// Name the descriptor, so a failure says what leaked.
fmt.Fprintf(os.Stderr, "unexpected fd %d -> %s\n", fd, target)
os.Exit(22)
@@ -146,6 +146,23 @@ func TestRegistryChildFDHelper(t *testing.T) {
os.Exit(0)
}
+// goRuntimeCgroupFD reports whether target is the CPU limit file the
+// child's own Go runtime holds open (internal/runtime/cgroup's quotaFD,
+// since Go 1.25) to follow its cgroup's limit for GOMAXPROCS. The child
+// opens it itself, close-on-exec, at startup, so it says nothing about
+// what the parent let through. It exists only where the cgroup sets a
+// CPU limit: every CI job's does, a desktop session's usually not.
+func goRuntimeCgroupFD(target string) bool {
+ if !strings.HasPrefix(target, "/sys/fs/cgroup/") {
+ return false
+ }
+ switch filepath.Base(target) {
+ case "cpu.max", "cpu.cfs_quota_us", "cpu.cfs_period_us":
+ return true
+ }
+ return false
+}
+
func TestRegistryChildPinnedExecutableAndMinimalFDs(t *testing.T) {
dir := t.TempDir()
original, err := os.Open("/proc/self/exe")