carlos / platform Public

instancectl: the probe fixtures' check is exported; the isolation witness uses it (#328)

Task 14 review finding 3: the witness carried a copy of probeFixturesOK.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 9022a4941ec73b4cfce82416c2501244e006a1f6 parent 2d9cf69
4 files changed, +6 −39
  • internal/host/egress_fixtures_rootrunner_linux_test.go +1 −35
  • internal/instancectl/peer_linux.go +3 −2
  • internal/instancectl/peer_other.go +1 −1
  • internal/instancectl/server.go +1 −1

CI failed — run details

diff --git a/internal/host/egress_fixtures_rootrunner_linux_test.go b/internal/host/egress_fixtures_rootrunner_linux_test.go
index 66e7f2989..ef79d0e8d 100644
--- a/internal/host/egress_fixtures_rootrunner_linux_test.go
+++ b/internal/host/egress_fixtures_rootrunner_linux_test.go
@@ -18,7 +18,6 @@ import (
"net/url"
"os"
"os/exec"
- "os/user"
"path/filepath"
"runtime"
"slices"
@@ -26,7 +25,6 @@ import (
"strings"
"sync"
"sync/atomic"
- "syscall"
"testing"
"time"
@@ -1039,7 +1037,7 @@ func newEgressPreClaimBoxWith(t *testing.T, o egressBoxOptions) *egressBox {
if o.probe {
egressProbeFixture(t, uid, gid)
srv.ProbeOut = egressProbeOut
- srv.FixtureOK = egressProbeFixturesOK
+ srv.FixtureOK = instancectl.ProbeFixturesOK
srv.ResolvConf = "/etc/resolv.conf"
srv.ResolvedConf = instancectl.ResolvedConf
}
@@ -1234,38 +1232,6 @@ func egressProbeFixture(t *testing.T, uid, gid int) {
egressMustCtl(t, "daemon-reload")
}
-// egressProbeFixturesOK is the control service's FixtureOK, made here as
-// instancectl's probeFixturesOK makes it (unexported there): both probe
-// fixtures present, the secret root:carlos 0640 and the shm file a
-// root-owned regular file. Either one missing would make its probe line
-// pass vacuously.
-func egressProbeFixturesOK() error {
- shm, err := os.Lstat("/dev/shm/carlos-probe")
- if err != nil {
- return fmt.Errorf("probe shm fixture absent: %v", err)
- }
- if st, ok := shm.Sys().(*syscall.Stat_t); !ok || st.Uid != 0 || !shm.Mode().IsRegular() {
- return errors.New("probe shm fixture: not a root-owned regular file")
- }
- fi, err := os.Stat("/etc/carlos/probe-secret")
- if err != nil {
- return fmt.Errorf("probe fixture absent: %v", err)
- }
- st, ok := fi.Sys().(*syscall.Stat_t)
- if !ok {
- return errors.New("probe fixture: no stat")
- }
- g, err := user.LookupGroup("carlos")
- if err != nil {
- return err
- }
- gid, _ := strconv.Atoi(g.Gid)
- if st.Uid != 0 || int(st.Gid) != gid || fi.Mode().Perm() != 0o640 {
- return fmt.Errorf("probe fixture is uid %d gid %d mode %o, want root:carlos 0640", st.Uid, st.Gid, fi.Mode().Perm())
- }
- return nil
-}
-
// egressParentSliceProperties refuses a carlos-instances.slice that
// already carries set-property drop-ins or an allow, and on cleanup resets
// its allow and removes the runtime drop-ins the test's writes leave (the
diff --git a/internal/instancectl/peer_linux.go b/internal/instancectl/peer_linux.go
index 8d3cc1e5f..11ee0e45f 100644
--- a/internal/instancectl/peer_linux.go
+++ b/internal/instancectl/peer_linux.go
@@ -159,10 +159,11 @@ func bindControlSocket(path string) (net.Listener, error) {
return ln, nil
}
-// probeFixturesOK checks the two probe fixtures tmpfiles stages: the
+// ProbeFixturesOK checks the two probe fixtures tmpfiles stages (the
+// control service's FixtureOK, and the root-runner witnesses'): the
// secret the probe must not read, and the host /dev/shm file it must not
// see. Either one missing would make its check pass vacuously.
-func probeFixturesOK() error {
+func ProbeFixturesOK() error {
shm, err := os.Lstat("/dev/shm/carlos-probe")
if err != nil {
return fmt.Errorf("probe shm fixture absent: %v", err)
diff --git a/internal/instancectl/peer_other.go b/internal/instancectl/peer_other.go
index 6c82e3409..bcc138844 100644
--- a/internal/instancectl/peer_other.go
+++ b/internal/instancectl/peer_other.go
@@ -12,5 +12,5 @@ func productionPeerOK() func(net.Conn) error {
}
func activatedListener() (net.Listener, bool, error) { return nil, false, errors.ErrUnsupported }
func bindControlSocket(string) (net.Listener, error) { return nil, errors.ErrUnsupported }
-func probeFixturesOK() error { return errors.ErrUnsupported }
+func ProbeFixturesOK() error { return errors.ErrUnsupported }
func statfsBytes(string) (uint64, uint64, error) { return 0, 0, errors.ErrUnsupported }
diff --git a/internal/instancectl/server.go b/internal/instancectl/server.go
index 0af174bb8..ccb9fabb3 100644
--- a/internal/instancectl/server.go
+++ b/internal/instancectl/server.go
@@ -194,7 +194,7 @@ func runWithClaim(args []string, claim, heldRelease http.Handler, hostApp func(s
PeerOK: productionPeerOK(),
CgroupRoot: "/sys/fs/cgroup",
ProbeOut: filepath.Join(controlsock.Dir, "probe.out"),
- FixtureOK: probeFixturesOK,
+ FixtureOK: ProbeFixturesOK,
ProbeEvery: 5 * time.Minute,
Logf: log.Printf,
ExeRoot: filepath.Join(controlsock.Dir, "exe"),