carlos / platform Public

host: bind the control mount check to one control invocation

Census R1 P1: the MainPID read discarded its error and /proc/<pid> was
opened by path, so a recycled PID (an agent child in carlos-edge's
read-only namespace) could restart a healthy control.

Read MainPID, InvocationID and ControlGroup (any error: unknown), read
cgroup and mountinfo through one /proc/<pid> directory fd, require the
cgroup to be exactly the unit's, and re-read the three unchanged.
Unknown never restarts. Regression tests cover an exited or replaced
PID, a foreign cgroup, a changed invocation and a failed show; the root
witness adds a foreign PID in a strict namespace. Census re-proposed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 84a71123d51130f79a11abe6cff9d2c1f81b51bb parent 656a832
6 files changed, +178 −42
  • docs/superpowers/notes/census-proposal-gvisor-update-dirs.md +2 −2
  • internal/host/execsandboxfloor.go +87 −18
  • internal/host/runsc_update_dirs_linux_test.go +50 −7
  • internal/host/runsc_update_dirs_rootrunner_linux_test.go +35 −11
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-gvisor-update-dirs.tsv +3 −3

CI passed — run details

diff --git a/docs/superpowers/notes/census-proposal-gvisor-update-dirs.md b/docs/superpowers/notes/census-proposal-gvisor-update-dirs.md
index 9b6c7aa91..01ca5dd32 100644
--- a/docs/superpowers/notes/census-proposal-gvisor-update-dirs.md
+++ b/docs/superpowers/notes/census-proposal-gvisor-update-dirs.md
@@ -29,9 +29,9 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/activator/backend_exec.go:ExecBackend.gvisorSiblingNeverLoaded`: reads +file:Lstat, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/activator/control.go:systemctlUnitsListed`: reads +file:CommandContext; written legacy, accepted-legacy, frozen
- new `internal/demobuild/unit.go:gvisorBuildNeverLoaded`: reads +file:Lstat; written legacy, accepted-legacy, frozen
-- new `internal/host/execsandboxfloor.go:var controlMountinfo`: reads +file:ReadFile; written legacy, accepted-legacy, frozen
+- new `internal/host/execsandboxfloor.go:var controlProcess`: reads +file:OpenRoot, +file:ReadFile ×2; written legacy, accepted-legacy, frozen
- new `internal/instancectl/sandboxstop.go:Server.gvisorUnitNeverLoaded`: reads +file:Lstat; written legacy, accepted-legacy, frozen
-Seal: `7ac2bde8301c37c7546e9aa19d375f1468fc8061876a618fa8f93dd4543c5652` → `49ab09604038a0b51683d5978045063e2dafa235abb30b1be12d94d96ff2ee4c`.
+Seal: `7ac2bde8301c37c7546e9aa19d375f1468fc8061876a618fa8f93dd4543c5652` → `1f1b2fdb569b7be42e75e10d1943d7e512708299364f912c2f72dccf1bd5b678`.
Overlay: `internal/provision/testdata/plan14-root-reads-gvisor-update-dirs.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/host/execsandboxfloor.go b/internal/host/execsandboxfloor.go
index 438b5c566..f9168e1c2 100644
--- a/internal/host/execsandboxfloor.go
+++ b/internal/host/execsandboxfloor.go
@@ -133,9 +133,62 @@ func ensureSandboxDirectories(root, optDir string) error {
return bootstrapMakeDir(filepath.Join(optDir, "runsc"), 0755)
}
-// controlMountinfo reads a process's mount table; a seam for tests.
-var controlMountinfo = func(pid string) ([]byte, error) {
- return os.ReadFile(filepath.Join("/proc", pid, "mountinfo"))
+// controlProcess reads one process instance's cgroup and mount table
+// through a single /proc/<pid> directory descriptor: both files come from
+// the process that descriptor was opened on, and if it has exited the
+// reads fail (ESRCH) even when the PID has been reused since. A seam for
+// tests.
+var controlProcess = func(pid string) (cgroup, mountinfo []byte, err error) {
+ dir, err := os.OpenRoot(filepath.Join("/proc", pid))
+ if err != nil {
+ return nil, nil, err
+ }
+ defer dir.Close()
+ if cgroup, err = dir.ReadFile("cgroup"); err != nil {
+ return nil, nil, err
+ }
+ if mountinfo, err = dir.ReadFile("mountinfo"); err != nil {
+ return nil, nil, err
+ }
+ return cgroup, mountinfo, nil
+}
+
+// controlInvocation is what systemd says runs a unit now.
+type controlInvocation struct{ pid, invocation, group string }
+
+// readControlInvocation asks systemd for unit's MainPID, InvocationID and
+// ControlGroup. Any error, a stopped service, or a value out of shape is
+// not an answer.
+func readControlInvocation(probe func(args ...string) (string, error), unit string) (controlInvocation, bool) {
+ out, err := probe("show", "-p", "MainPID,InvocationID,ControlGroup", unit)
+ if err != nil {
+ return controlInvocation{}, false
+ }
+ var c controlInvocation
+ seen := map[string]bool{}
+ for _, line := range strings.Split(out, "\n") {
+ k, v, ok := strings.Cut(strings.TrimSpace(line), "=")
+ if !ok {
+ continue
+ }
+ if seen[k] {
+ return controlInvocation{}, false
+ }
+ seen[k] = true
+ switch k {
+ case "MainPID":
+ c.pid = v
+ case "InvocationID":
+ c.invocation = v
+ case "ControlGroup":
+ c.group = v
+ }
+ }
+ if c.pid == "" || c.pid == "0" || strings.Trim(c.pid, "0123456789") != "" || c.invocation == "" ||
+ !strings.HasPrefix(c.group, "/") || !strings.HasSuffix(c.group, "/"+unit) {
+ return controlInvocation{}, false
+ }
+ return c, true
}
// refreshControlSandboxRootfs restarts instance-control once when it runs
@@ -144,12 +197,21 @@ var controlMountinfo = func(pid string) ([]byte, error) {
// it before anything has created it), and systemd skips a missing optional
// path when it builds the service's namespace. Created later, the
// directory shows through ProtectSystem=strict read-only, so every gVisor
-// start would fail writing its rootfs until the next restart. A path
-// systemd made writable is a mount point in the service's mount table, so
-// its absence there is the fact this reads; one try-restart (a stopped
-// service stays stopped) rebuilds the namespace. systemd mode never writes
-// the directory and is left alone, as is anything this cannot read.
+// start would fail writing its rootfs until the next restart.
+//
+// The mount table read must be the service's own (census R1 P1): a PID
+// read from systemd can be reused by any process, an agent child under
+// carlos-edge's read-only namespace among them. So the observation is
+// bound to one invocation: MainPID, InvocationID and ControlGroup from
+// systemd; cgroup and mountinfo through one /proc/<pid> descriptor, the
+// cgroup exactly the unit's; then the same three again, unchanged. Any
+// error, mismatch or exited process is unknown, and unknown never
+// restarts. systemd mode never writes the directory and is left alone.
func refreshControlSandboxRootfs(etcDir string, a *systemApplier, systemctl, probe func(args ...string) (string, error), logf func(string, ...any)) {
+ refreshControlSandboxRootfsUnit(etcDir, claimControlUnit, a, systemctl, probe, logf)
+}
+
+func refreshControlSandboxRootfsUnit(etcDir, unit string, a *systemApplier, systemctl, probe func(args ...string) (string, error), logf func(string, ...any)) {
read := a.sandboxEnvironment
if read == nil {
read = func() (func(string) string, error) {
@@ -163,28 +225,35 @@ func refreshControlSandboxRootfs(etcDir string, a *systemApplier, systemctl, pro
if _, effective, err := execsandbox.ResolveFromEnv(getenv); err != nil || effective != execsandbox.EffectiveGVisor {
return
}
- out, _ := probe("show", "-p", "MainPID", "--value", claimControlUnit)
- pid := strings.TrimSpace(out)
- if pid == "" || pid == "0" || strings.Trim(pid, "0123456789") != "" {
+ before, ok := readControlInvocation(probe, unit)
+ if !ok {
return
}
- rootfs := filepath.Join(filepath.Dir(etcDir), "var/lib/carlos/oci-rootfs")
- raw, err := controlMountinfo(pid)
+ cgroup, raw, err := controlProcess(before.pid)
if err != nil {
- logf("adopt: %s mount table: %v", claimControlUnit, err)
+ logf("adopt: %s process %s: %v; leaving it", unit, before.pid, err)
return
}
+ if strings.TrimSpace(string(cgroup)) != "0::"+before.group {
+ logf("adopt: process %s is not %s's (cgroup %q); leaving it", before.pid, unit, strings.TrimSpace(string(cgroup)))
+ return
+ }
+ if after, ok := readControlInvocation(probe, unit); !ok || after != before {
+ logf("adopt: %s changed while its mount table was read; leaving it", unit)
+ return
+ }
+ rootfs := filepath.Join(filepath.Dir(etcDir), "var/lib/carlos/oci-rootfs")
writable, known := mountWritable(raw, rootfs)
if !known {
- logf("adopt: %s mount table does not settle whether %s is writable; leaving it", claimControlUnit, rootfs)
+ logf("adopt: %s mount table does not settle whether %s is writable; leaving it", unit, rootfs)
return
}
if writable {
return
}
- logf("adopt: %s started before %s existed; restarting it so gVisor can write there", claimControlUnit, rootfs)
- if _, err := systemctl("try-restart", claimControlUnit); err != nil {
- logf("adopt: systemctl try-restart %s: %v", claimControlUnit, err)
+ logf("adopt: %s started before %s existed; restarting it so gVisor can write there", unit, rootfs)
+ if _, err := systemctl("try-restart", unit); err != nil {
+ logf("adopt: systemctl try-restart %s: %v", unit, err)
}
}
diff --git a/internal/host/runsc_update_dirs_linux_test.go b/internal/host/runsc_update_dirs_linux_test.go
index f7407ece6..1184569e3 100644
--- a/internal/host/runsc_update_dirs_linux_test.go
+++ b/internal/host/runsc_update_dirs_linux_test.go
@@ -4,7 +4,9 @@ import (
"context"
"errors"
"os"
+ "os/exec"
"path/filepath"
+ "strconv"
"strings"
"syscall"
"testing"
@@ -262,6 +264,8 @@ func TestSandboxUpdateControlRestartForNewRootfs(t *testing.T) {
name, mode, pid string
mounted, want bool
parent, garbled bool
+ // Census R1 P1: the observation is bound to one control invocation.
+ exited, wrongCgroup, newInvocation, probeErr bool
}{
{name: "gvisor, started before the directory", mode: "gvisor", pid: "4242", want: true},
{name: "gvisor, path mounted", mode: "gvisor", pid: "4242", mounted: true},
@@ -269,16 +273,30 @@ func TestSandboxUpdateControlRestartForNewRootfs(t *testing.T) {
{name: "gvisor, writable parent", mode: "gvisor", pid: "4242", parent: true},
{name: "gvisor, malformed table", mode: "gvisor", pid: "4242", garbled: true},
{name: "gvisor, not running", mode: "gvisor", pid: "0"},
+ {name: "gvisor, PID gone or replaced before the read", mode: "gvisor", pid: "4242", exited: true},
+ {name: "gvisor, PID belongs to another cgroup", mode: "gvisor", pid: "4242", wrongCgroup: true},
+ {name: "gvisor, invocation changed during the read", mode: "gvisor", pid: "4242", newInvocation: true},
+ {name: "gvisor, show fails", mode: "gvisor", pid: "4242", probeErr: true},
{name: "systemd", mode: "systemd", pid: "4242"},
} {
t.Run(tc.name, func(t *testing.T) {
etc, opt, _ := oldSandboxBox(t, "CARLOS_EXEC_SANDBOX="+tc.mode+"\n")
rootfs := filepath.Join(filepath.Dir(etc), "var/lib/carlos/oci-rootfs")
- old := controlMountinfo
- t.Cleanup(func() { controlMountinfo = old })
- controlMountinfo = func(pid string) ([]byte, error) {
+ group := "/system.slice/" + claimControlUnit
+ old := controlProcess
+ t.Cleanup(func() { controlProcess = old })
+ controlProcess = func(pid string) ([]byte, []byte, error) {
if pid != tc.pid {
- t.Errorf("mount table of %q, want %q", pid, tc.pid)
+ t.Errorf("process %q, want %q", pid, tc.pid)
+ }
+ if tc.exited {
+ // The descriptor's process is gone: what ESRCH looks like.
+ return nil, nil, syscall.ESRCH
+ }
+ cgroup := "0::" + group + "\n"
+ if tc.wrongCgroup {
+ // A recycled PID: an agent child in carlos-edge's namespace.
+ cgroup = "0::/carlos.slice/carlos-edge.service\n"
}
table := "22 1 259:1 / / ro,relatime shared:1 - ext4 /dev/root rw\n31 22 259:1 /run/carlos-control /run/carlos-control rw,relatime shared:9 - tmpfs tmpfs rw\n"
if tc.mounted {
@@ -291,14 +309,23 @@ func TestSandboxUpdateControlRestartForNewRootfs(t *testing.T) {
if tc.garbled {
table += "42 22 259:1 " + rootfs + "\n"
}
- return []byte(table), nil
+ return []byte(cgroup), []byte(table), nil
}
+ shows := 0
probe := func(args ...string) (string, error) {
if args[0] == "show" {
- if strings.Join(args, " ") != "show -p MainPID --value "+claimControlUnit {
+ if strings.Join(args, " ") != "show -p MainPID,InvocationID,ControlGroup "+claimControlUnit {
t.Errorf("probe %v", args)
}
- return tc.pid + "\n", nil
+ if tc.probeErr {
+ return "MainPID=" + tc.pid + "\nInvocationID=aa\nControlGroup=" + group + "\n", errors.New("bus")
+ }
+ shows++
+ inv := "aa"
+ if tc.newInvocation && shows%2 == 0 {
+ inv = "bb"
+ }
+ return "MainPID=" + tc.pid + "\nInvocationID=" + inv + "\nControlGroup=" + group + "\n", nil
}
return armedUnitsProbe(args...)
}
@@ -406,3 +433,19 @@ func TestMountWritableJudgesTheContainingMount(t *testing.T) {
})
}
}
+
+// The production seam reads both files of one live process, and refuses a
+// process that has gone (census R1 P1).
+func TestControlProcessReadsOneLiveProcess(t *testing.T) {
+ cgroup, mountinfo, err := controlProcess(strconv.Itoa(os.Getpid()))
+ if err != nil || !strings.HasPrefix(string(cgroup), "0::") || !strings.Contains(string(mountinfo), " / ") {
+ t.Fatalf("own process: %q %q %v", cgroup, mountinfo, err)
+ }
+ child := exec.Command("true")
+ if err := child.Run(); err != nil {
+ t.Fatal(err)
+ }
+ if _, _, err := controlProcess(strconv.Itoa(child.Process.Pid)); err == nil {
+ t.Skip("the exited child's PID was reused already")
+ }
+}
diff --git a/internal/host/runsc_update_dirs_rootrunner_linux_test.go b/internal/host/runsc_update_dirs_rootrunner_linux_test.go
index e280f2cdf..3a2e44a81 100644
--- a/internal/host/runsc_update_dirs_rootrunner_linux_test.go
+++ b/internal/host/runsc_update_dirs_rootrunner_linux_test.go
@@ -177,7 +177,8 @@ func udwUnit(t *testing.T, embedded, execStart string, drop []string, extra ...s
// (ensureSystemUnits on /etc, systemctl seams faked so nothing is armed)
// creates both directories root:root 0700/0755 although it ends early; the
// running control cannot write oci-rootfs until refreshControlSandboxRootfs
-// restarts it once, and a second refresh does nothing. (c) a production
+// restarts it once, and a second refresh does nothing; a foreign PID in a
+// read-only namespace (a recycled PID) never restarts it. (c) a production
// /stop over a never-started gVisor sibling, with the shipped commandless
// gVisor template installed, logs no "Refusing"; a direct show of the same
// name afterwards does (positive control). (d) an edge-shaped unit whose
@@ -204,9 +205,10 @@ func TestRootSandboxUpdateFromOldBox(t *testing.T) {
runscGVisor = "carlos-udw-runsc-gvisor.service"
runscOld = "carlos-udw-runsc-old.service"
edge = "carlos-udw-edge.service"
+ impostor = "carlos-udw-impostor.service"
template = instancectl.UnitPrefixGVisor + ".service"
)
- units := []string{control, runsc, runscGVisor, runscOld, edge, native, template}
+ units := []string{control, runsc, runscGVisor, runscOld, edge, native, template, impostor}
for _, path := range []string{"/var/lib/carlos", "/opt/carlos", udwBinDir, "/run/carlos-control", "/run/carlos", "/data", "/etc/carlos/host.env", "/etc/carlos/group.json"} {
if _, err := os.Lstat(path); !errors.Is(err, os.ErrNotExist) {
t.Fatalf("this witness runs only on a fresh runner: %s: %v", path, err)
@@ -245,7 +247,7 @@ func TestRootSandboxUpdateFromOldBox(t *testing.T) {
}
var installed, made []string
t.Cleanup(func() {
- for _, unit := range []string{edge, native, control, runsc, runscGVisor, runscOld} {
+ for _, unit := range []string{edge, native, control, runsc, runscGVisor, runscOld, impostor} {
_, _ = ctl("stop", unit)
}
for _, path := range installed {
@@ -303,6 +305,7 @@ func TestRootSandboxUpdateFromOldBox(t *testing.T) {
// The edge runs as root here: no carlos user on the runner, and root's
// socket is 0700 under /run/carlos-control. Every other directive stays.
install(edge, udwUnit(t, "carlos-edge.service", udwBin+" "+udwEdgeArg+" "+udwSock+" "+host+" "+udwReady, []string{"User=", "Group=", "AmbientCapabilities=", "CapabilityBoundingSet="}))
+ install(impostor, "[Unit]\nDescription=update witness: a foreign process in a strict namespace\n[Service]\nType=exec\nExecStart=/bin/sleep infinity\nProtectSystem=strict\n")
must("daemon-reload")
absent := func(when string) {
@@ -406,16 +409,16 @@ func TestRootSandboxUpdateFromOldBox(t *testing.T) {
var calls []string
mapped := func(args ...string) (string, error) {
calls = append(calls, strings.Join(args, " "))
- if strings.Join(args, " ") != "try-restart "+claimControlUnit {
+ if strings.Join(args, " ") != "try-restart "+control {
return "", fmt.Errorf("witness: unexpected systemctl %v", args)
}
- return ctl("try-restart", control)
+ return ctl(args...)
}
probe := func(args ...string) (string, error) {
- if strings.Join(args, " ") != "show -p MainPID --value "+claimControlUnit {
+ if strings.Join(args, " ") != "show -p MainPID,InvocationID,ControlGroup "+control {
return "", fmt.Errorf("witness: unexpected probe %v", args)
}
- return ctl("show", "-p", "MainPID", "--value", control)
+ return ctl(args...)
}
gvisorEnv := &systemApplier{sandboxEnvironment: func() (func(string) string, error) {
return func(k string) string {
@@ -425,8 +428,29 @@ func TestRootSandboxUpdateFromOldBox(t *testing.T) {
return ""
}, nil
}}
- refreshControlSandboxRootfs("/etc", gvisorEnv, mapped, probe, t.Logf)
- if strings.Join(calls, "|") != "try-restart "+claimControlUnit {
+ // Census R1 P1: a PID that is not control's, here a process in another
+ // ProtectSystem=strict namespace with oci-rootfs read-only, as an agent
+ // child holding a recycled PID would be, must not restart control.
+ must("start", impostor)
+ impostorPID := show(impostor, "MainPID")["MainPID"]
+ recycled := func(args ...string) (string, error) {
+ out, err := probe(args...)
+ var lines []string
+ for _, line := range strings.Split(out, "\n") {
+ if strings.HasPrefix(line, "MainPID=") {
+ line = "MainPID=" + impostorPID
+ }
+ lines = append(lines, line)
+ }
+ return strings.Join(lines, "\n"), err
+ }
+ refreshControlSandboxRootfsUnit("/etc", control, gvisorEnv, mapped, recycled, t.Logf)
+ if len(calls) != 0 || mainPID() != before {
+ t.Fatalf("a foreign PID's read-only namespace restarted control: %q", calls)
+ }
+ must("stop", impostor)
+ refreshControlSandboxRootfsUnit("/etc", control, gvisorEnv, mapped, probe, t.Logf)
+ if strings.Join(calls, "|") != "try-restart "+control {
t.Fatalf("refresh calls %q, want one try-restart", calls)
}
waitControl()
@@ -438,11 +462,11 @@ func TestRootSandboxUpdateFromOldBox(t *testing.T) {
t.Fatalf("restarted control still cannot write %s: %d %s", udwRootfs, code, body)
}
calls = nil
- refreshControlSandboxRootfs("/etc", gvisorEnv, mapped, probe, t.Logf)
+ refreshControlSandboxRootfsUnit("/etc", control, gvisorEnv, mapped, probe, t.Logf)
if len(calls) != 0 || mainPID() != after {
t.Fatalf("a second refresh restarted a control that has the path: %q", calls)
}
- t.Log("(b) PASS: first pass creates root:root 0700/0755; one refresh makes oci-rootfs writable; no restart loop")
+ t.Log("(b) PASS: first pass creates root:root 0700/0755; a foreign PID restarts nothing; one refresh makes oci-rootfs writable; no restart loop")
// (c) A production /stop over a never-started gVisor sibling.
tb, err := unitsFS.ReadFile("units/" + template)
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 2d86b49c1..844035f36 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -136,4 +136,4 @@ plan14-root-reads-edge-page-cache-1.tsv 2774b43ac5970e4340339b859204bce5eb9f83d4
plan14-root-reads-cli-default-console-carloku.tsv 2774b43ac5970e4340339b859204bce5eb9f83d4c2551f0984e919a2853d0216
plan14-root-reads-gvisor-demos.tsv f05716181a82721b38cba9b2d89c47925dc2ca426e5c4876ebf1df7b45895ee3
plan14-root-reads-dns-fresh-lookup-724.tsv 7ac2bde8301c37c7546e9aa19d375f1468fc8061876a618fa8f93dd4543c5652
-plan14-root-reads-gvisor-update-dirs.tsv 49ab09604038a0b51683d5978045063e2dafa235abb30b1be12d94d96ff2ee4c
+plan14-root-reads-gvisor-update-dirs.tsv 1f1b2fdb569b7be42e75e10d1943d7e512708299364f912c2f72dccf1bd5b678
diff --git a/internal/provision/testdata/plan14-root-reads-gvisor-update-dirs.tsv b/internal/provision/testdata/plan14-root-reads-gvisor-update-dirs.tsv
index d00f1adaf..ca9326dd2 100644
--- a/internal/provision/testdata/plan14-root-reads-gvisor-update-dirs.tsv
+++ b/internal/provision/testdata/plan14-root-reads-gvisor-update-dirs.tsv
@@ -8,7 +8,7 @@
@legacy 796be076f07a5138618981ef1c0b304f4cd1eed6d4eaf84796f184255dd9fb46 internal/activator/backend_exec.go ExecBackend.gvisorSiblingNeverLoaded legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=New, agent side: Lstat of /run/systemd/system/<sibling>.d, the existing unitEvents cgroup read, and the read-only list-units family glob via UnitsListed. All must say absent; any error returns false so the full proof runs. No root decision. file:Lstat@322,whole:Route@455 70df41b956a2c1b4ce6d0c769a36f81f3facb6943229e9a744ce62fe3a5fda20
@legacy f5399a6f15da500e625eac9cfd36448779ea1051b7f7b9e5f3fe54dcba973114 internal/activator/control.go systemctlUnitsListed legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=New, agent side: `systemctl list-units --all --plain --no-legend --no-pager <glob>`, read-only; the spawn guard's read-only verb list gains list-units. file:CommandContext@91 52c36953bba90fadc4ff0684877f8efe0b9d951d97693077faded8b1123ab373
@legacy 4f5cf0afb2c8cc2bb2d6bb2435d2db17c49b5cc4ca2fe5b0c1bfcbecc86cb73e internal/demobuild/unit.go gvisorBuildNeverLoaded legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=New: Lstat of the build cgroup dir (emptyBuildCgroup's path) and of the job drop-in dir under unitRoot, then list-units with the fixed carlos-demo-build-gvisor@*.service glob and an exact match. Only when all say absent does stopBuildContext skip show/stop of the gVisor build unit; any error keeps the full proof. R1 P2-3: a listing at the wrapper's 128 KiB capture limit may be truncated and also returns false (full proof). file:Lstat@191 bce764f50a586475761b49c47c4c001fde1bc1f6117bf41f5502e02f248f1ae8
-@legacy 10541080f448c9a0092472990d4d844931c7f9d27d6a4e3b8f4e95e805707913 internal/host/execsandboxfloor.go var controlMountinfo legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=New seam: reads /proc/<pid>/mountinfo of instance-control's MainPID (digits only, from systemctl show -p MainPID --value carlos-instance-control.service) to see whether systemd mounted /var/lib/carlos/oci-rootfs writable in its namespace. Kernel-owned file; the only effect is one try-restart of carlos-instance-control.service in effective gVisor mode (host.env read through the existing sandboxHostEnvironmentAt) when the mount is absent. Unreadable or anything unexpected: no restart. file:ReadFile@66 5cc66076a36cf77ea5add013814e51d7231576e3e07482965f6907032c30ce6d
+@legacy 0b0003a02e3adb3a95986824e49b0fc87cce21343287ad602ac03306f069d9e4 internal/host/execsandboxfloor.go var controlProcess legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=Replaces var controlMountinfo (census R1 P1). Opens /proc/<pid> once (os.OpenRoot, a directory fd) and reads cgroup and mountinfo through it with openat, so both come from one process instance and fail with ESRCH once it has exited, even if the PID is reused. The caller (refreshControlSandboxRootfsUnit) takes MainPID,InvocationID,ControlGroup from systemctl show (any error: no answer), requires the cgroup file to be exactly 0::<ControlGroup> with ControlGroup ending in /carlos-instance-control.service, re-reads the three values and requires them unchanged; any error, mismatch or exited process is unknown and never restarts. The only effect remains one try-restart of carlos-instance-control.service in effective gVisor mode when the containing mount of /var/lib/carlos/oci-rootfs is read-only. file:OpenRoot@91,file:ReadFile@212,file:ReadFile@296 5d7b01ee4d8afbf6e33eb717f5504d1c5368ca6271b748268561d2def7fb4f0d
@legacy 5ef56f0c8f8c9f406f11356586c550e8d64d2f0f08c492138c3a78204c3730fb internal/instancectl/sandboxstop.go Server.gvisorUnitNeverLoaded legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=New: Lstat of the host-derived cgroup directory under the configured cgroup root and of <DropInDir>/<unit>.d (both must be absent), then `systemctl list-units --all --plain --no-legend --no-pager carlos-instance-gvisor@*.service` (fixed family glob) and an exact-name match in Go. Any error or presence returns false so the full proof runs. file:Lstat@379 6c51d378fd35d05545483615163fc5a28431b97359a4de8b4c2437c6d5a4b06c
@legacy 1c1fe1e038d3f677379ebd06d48c81c9cdb7b02a658529b51eeb21b3a010225e internal/activator/backend_exec.go ExecBackend.LegacyRunGone legacy accepted-legacy accepted-legacy;rev3=census-ruling-292;basis=Census ruling 292: new unit; stops the host's original run unit through instance-control's existing /stop and proves it gone from systemctl show state and cgroup.events, as the exit observer reads. The termination proof only decides release-or-keep, and never starts, wakes or admits anything; unknown or error means keep. Boundary: agent-side shutdown gates running as carlos; they refuse or stop new work once shutdown begins, and a cancelled wake releases its lease; no new read and no root decision; plus the legacy run unit's termination proof (systemctl show state and cgroup.events, as the exit observer reads), and a retried conditional lease delete of the same record.;rev3=census-ruling-rootfs-apps-2;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=a rootfs row's original run unit is the rootfs template's: it is named by unitNameFor and stopped through stopRole (the rootfs verb), and its cgroup proven by unitEvents, which for a rootfs row also reads the control group systemd reports; the Host sites became Route sites (the route passed to those three); the proof's rule is unchanged: unknown or error keeps the lease; no root decision;rev3=census-ruling-gvisor-demos;basis=Task 5: after root fenced Stop succeeds, check both native and gVisor original siblings using the existing systemd/cgroup readers; rootfs retains its existing path. A failed root proof returns immediately and keeps the lease. No mode-dependent cleanup.;rev3=census-ruling-gvisor-update-dirs;basis=Agent side (carlos user): skip the gVisor sibling's show-based proof only when gvisorSiblingNeverLoaded holds; the native unit's proof is unchanged and any doubt keeps the lease as before. registry:Host@174,registry:Host@606,whole:Route@393,whole:Route@448,whole:Route@665,whole:Route@783 036ffb949da93314622f0e15d128e5e8db794971c2546a96ddbac217209a4415
internal/host/systemunits.go ensureSystemUnitsWithGuard legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move unit-repair body here with existing lock/unit/host.env reads; under lock require operator repair permit on groups before writes and each systemctl effect, preserve root masks/drop-in and omit automatic update/recovery units. New indirect protected marker/permit reads, never agent receipt; fixed repair unchanged.;rev3=census-ruling-gvisor-demos;basis=Create runtime/rootfs directories and repair installer plus three measured workload templates without arming them. Existing unit/host.env reads unchanged.;rev3=census-ruling-gvisor-update-dirs;basis=Create the two live sandbox directories (the same fixed ensureSandboxDirectories paths) before the apply lock and the early returns on non-group boxes; group members still create them only after the maintenance permit. A creation error still ends the pass at the original point. Then call refreshControlSandboxRootfs. No new path, input or systemctl verb beyond the try-restart below. file:OpenFile@985,file:ReadFile@5626,file:ReadFile@5759,file:ReadFile@7163,file:Stat@5535 6965ff178aa9e83348531a6efde9079afb5b854fedd7f3ef7c583ddd85b7ab53
@@ -19,11 +19,11 @@ internal/instancectl/sandboxstop.go Server.proveRunGone legacy accepted-legacy a
internal/activator/backend_exec.go ExecBackend.gvisorSiblingNeverLoaded legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=New, agent side: Lstat of /run/systemd/system/<sibling>.d, the existing unitEvents cgroup read, and the read-only list-units family glob via UnitsListed. All must say absent; any error returns false so the full proof runs. No root decision. file:Lstat@322,whole:Route@455 70df41b956a2c1b4ce6d0c769a36f81f3facb6943229e9a744ce62fe3a5fda20
internal/activator/control.go systemctlUnitsListed legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=New, agent side: `systemctl list-units --all --plain --no-legend --no-pager <glob>`, read-only; the spawn guard's read-only verb list gains list-units. file:CommandContext@91 52c36953bba90fadc4ff0684877f8efe0b9d951d97693077faded8b1123ab373
internal/demobuild/unit.go gvisorBuildNeverLoaded legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=New: Lstat of the build cgroup dir (emptyBuildCgroup's path) and of the job drop-in dir under unitRoot, then list-units with the fixed carlos-demo-build-gvisor@*.service glob and an exact match. Only when all say absent does stopBuildContext skip show/stop of the gVisor build unit; any error keeps the full proof. R1 P2-3: a listing at the wrapper's 128 KiB capture limit may be truncated and also returns false (full proof). file:Lstat@191 bce764f50a586475761b49c47c4c001fde1bc1f6117bf41f5502e02f248f1ae8
-internal/host/execsandboxfloor.go var controlMountinfo legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=New seam: reads /proc/<pid>/mountinfo of instance-control's MainPID (digits only, from systemctl show -p MainPID --value carlos-instance-control.service) to see whether systemd mounted /var/lib/carlos/oci-rootfs writable in its namespace. Kernel-owned file; the only effect is one try-restart of carlos-instance-control.service in effective gVisor mode (host.env read through the existing sandboxHostEnvironmentAt) when the mount is absent. Unreadable or anything unexpected: no restart. file:ReadFile@66 5cc66076a36cf77ea5add013814e51d7231576e3e07482965f6907032c30ce6d
+internal/host/execsandboxfloor.go var controlProcess legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=Replaces var controlMountinfo (census R1 P1). Opens /proc/<pid> once (os.OpenRoot, a directory fd) and reads cgroup and mountinfo through it with openat, so both come from one process instance and fail with ESRCH once it has exited, even if the PID is reused. The caller (refreshControlSandboxRootfsUnit) takes MainPID,InvocationID,ControlGroup from systemctl show (any error: no answer), requires the cgroup file to be exactly 0::<ControlGroup> with ControlGroup ending in /carlos-instance-control.service, re-reads the three values and requires them unchanged; any error, mismatch or exited process is unknown and never restarts. The only effect remains one try-restart of carlos-instance-control.service in effective gVisor mode when the containing mount of /var/lib/carlos/oci-rootfs is read-only. file:OpenRoot@91,file:ReadFile@212,file:ReadFile@296 5d7b01ee4d8afbf6e33eb717f5504d1c5368ca6271b748268561d2def7fb4f0d
internal/instancectl/sandboxstop.go Server.gvisorUnitNeverLoaded legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-update-dirs;basis=New: Lstat of the host-derived cgroup directory under the configured cgroup root and of <DropInDir>/<unit>.d (both must be absent), then `systemctl list-units --all --plain --no-legend --no-pager carlos-instance-gvisor@*.service` (fixed family glob) and an exact-name match in Go. Any error or presence returns false so the full proof runs. file:Lstat@379 6c51d378fd35d05545483615163fc5a28431b97359a4de8b4c2437c6d5a4b06c
internal/activator/backend_exec.go ExecBackend.LegacyRunGone legacy accepted-legacy accepted-legacy;rev3=census-ruling-292;basis=Census ruling 292: new unit; stops the host's original run unit through instance-control's existing /stop and proves it gone from systemctl show state and cgroup.events, as the exit observer reads. The termination proof only decides release-or-keep, and never starts, wakes or admits anything; unknown or error means keep. Boundary: agent-side shutdown gates running as carlos; they refuse or stop new work once shutdown begins, and a cancelled wake releases its lease; no new read and no root decision; plus the legacy run unit's termination proof (systemctl show state and cgroup.events, as the exit observer reads), and a retried conditional lease delete of the same record.;rev3=census-ruling-rootfs-apps-2;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=a rootfs row's original run unit is the rootfs template's: it is named by unitNameFor and stopped through stopRole (the rootfs verb), and its cgroup proven by unitEvents, which for a rootfs row also reads the control group systemd reports; the Host sites became Route sites (the route passed to those three); the proof's rule is unchanged: unknown or error keeps the lease; no root decision;rev3=census-ruling-gvisor-demos;basis=Task 5: after root fenced Stop succeeds, check both native and gVisor original siblings using the existing systemd/cgroup readers; rootfs retains its existing path. A failed root proof returns immediately and keeps the lease. No mode-dependent cleanup.;rev3=census-ruling-gvisor-update-dirs;basis=Agent side (carlos user): skip the gVisor sibling's show-based proof only when gvisorSiblingNeverLoaded holds; the native unit's proof is unchanged and any doubt keeps the lease as before. registry:Host@174,registry:Host@606,whole:Route@393,whole:Route@448,whole:Route@665,whole:Route@783 036ffb949da93314622f0e15d128e5e8db794971c2546a96ddbac217209a4415
@coverage internal/activator 10892f693ca6b72fa9cac7ec90ed25edb3cff03888f2a7365ce3d3e4d8f57ca4
@coverage internal/demobuild ec946d406609b27ff6bd70ac463163a3831656f9f3e972f92831dbc54e77406f
-@coverage internal/host cab4a90906f3fc5d8fc514321d483b8c0dce68d1369e79a11de1f418d69c510f
+@coverage internal/host 80777f8a695cacefef63316a89cfa55d73f32d6a13d6f190d4b757d21e4865b3
@coverage internal/host/units da7a1e3e835538ee4b56d31d0e19d671aa2b80d40d4ac3e5341806aaab13cf19
@coverage internal/instancectl 3b705c0428138f9cb85849fc917b964e4de3576d4499ce8c382ab45ae690822e