renderer: sandbox fix round 1 (descriptors at fork, verified tree, Close)
Astra's task 5 review, round 1: three findings, all fixed.
F1, descriptor race at fork. The runner no longer marks its own
descriptors close-on-exec before forking. It starts its own binary
(the pinned /runner descriptor, as /proc/self/fd/8) as the new
render-exec subcommand, which closes every descriptor above 11 with
close_range (or /proc/self/fd) and executes bubblewrap with the policy
itself. render-sandbox now closes everything above 5 at its start and
marks 3-5 close-on-exec, instead of only marking. containment's
terminal Dup and CloseOnExec now run under syscall.ForkLock.
F2, verified tree is the mounted tree. verifiedTree opens the tree's
parent once (no symlinks; owned by this user or root, not group or
world writable), opens the tree, usr and etc/fonts from it, verifies
the tree through that descriptor (/proc/self/fd/<parent>/<name>), then
reopens all three from the parent and requires the same device and
file number. The descriptors opened before verification are the ones
bound. Threat model in the comment: this user and root are trusted.
F3, Close and Wait prove the end. bubblewrap gets --info-fd 11; the
launcher reads the init's PID, opens a pidfd and checks the process's
parent is the unreaped bubblewrap. Kill sends SIGKILL to the init
through the pidfd and to bubblewrap. Wait and Close return only once
the pidfd is readable: the init's exit completes after the kernel has
killed and reaped its whole PID namespace. Past 10 s it is killed again;
past 20 s ErrNotEnded is returned. exec.CommandContext is replaced by
a watcher that kills only once the pidfd is held.
Tests (CGO_ENABLED=0, sandbox off):
go test ./internal/runner/render/ -count=1 22 pass, 1 skip
EQUIPO_RENDERER_TREE=<built tree> go test ./internal/runner/render/ \
-run TestLaunchRealBrowser pass (rebuilt tree)
go test ./internal/headless/ -run TestHeadlessSignInContained pass
New: TestSandboxSeesNothingOpenedAtFork (a hook opens an inheritable
fd 30 just before the fork), TestSandboxDescriptors (render-sandbox's
first step and the /proc fallback, in a child started with fds 3-7),
TestLaunchRefusesATreeReplacedAfterVerification (tree, usr, etc,
etc/fonts replaced after verification), TestLaunchVerifiesTheTreeItMounts
(an ancestor renamed and a good tree put at the old path during
verification; the tampered original is still the one checked),
TestLaunchRefusesATreeOthersCanMove, TestCloseReturnsOnlyWhenEverythingEnded
(a writer with its own session, no pipes and 256 threads appends to
/out every ms; when Close returns every process is gone and /out stops
changing; three rounds). TestCloseKillsTheSandbox now needs Close
within 5 s.
RED (each new test with its new guard removed, which is the round-0
behaviour, applied as a mutation):
the at-fork fd 30 was seen inside; render-sandbox left fds 6 and 7
open; a replaced tree, usr, etc or fonts was mounted; Close returned
with the writer still running (20 of 20 runs of the three-round test).
Mutations (scripted, each applied once and restored by checksum):
- render-exec closes nothing; bubblewrap started directly; fdKeep +30:
SeesNothingOpenedAtFork, SeesNoParentDescriptor (and the rest)
- render-sandbox only marks close-on-exec; 3-5 left inheritable;
closeEach closes nothing: TestSandboxDescriptors (+StartsTheBrowser)
- identity check off: RefusesATreeReplacedAfterVerification
- verified by path, not the parent descriptor: VerifiesTheTreeItMounts
- writable parent allowed: RefusesATreeOthersCanMove
- VerifyRenderer skipped: RefusesAnUnverifiedTree, VerifiesTheTreeItMounts
- Close does not wait for the pidfd: CloseReturnsOnlyWhenEverythingEnded
- no --info-fd: TestBwrapArgs, SeesNoParentDescriptor
- kill spares the init: survived, layered by --die-with-parent;
no --die-with-parent alone: TestBwrapArgs; both: CloseKillsTheSandbox
- parent-is-bubblewrap check off: survived (guards PID reuse only; no
deterministic test)
- runner env or render-exec env passed on: each survived alone, layered
by --clearenv and the other; all three: EnvironmentIsEmpty
- round 0 guards still killed: share-net, clearenv, ro binds, remount,
host /usr, out and owner checks, status, browser env, resolver rules,
--no-sandbox
containment ForkLock: no deterministic test (an atomicity fix).
Gates: darwin/arm64 build and vet; linux arm64 vet; staticcheck on
render, containment and cmd/equipo-runner; budget size; lanes check;
dead-reference scan shows only the known doc lines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 files changed,
+801
−187
cmd/equipo-runner/main.go+5 −0internal/runner/containment/linux.go+6 −0internal/runner/render/descriptors_linux.go+119 −0internal/runner/render/helpers_linux_test.go+81 −26internal/runner/render/launch_linux.go+211 −115internal/runner/render/launch_linux_test.go+191 −21internal/runner/render/launch_other.go+3 −0internal/runner/render/render.go+30 −14internal/runner/render/sandbox_linux.go+7 −11internal/runner/render/tree_linux.go+148 −0
CI failed — run details
CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/specialists-slice-1: Type Size Avail | ext4 96G 84G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type Size Avail | ext4 96G 84G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 1.4s
ci-box: codex: fetched and verified in 3.5s
ci-box: codex-code-mode-host: fetched and verified in 2.9s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.3s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 9.9s
ci-box: pi: installed and verified in 7.2s
ci-box: opencode: installed and verified in 1.9s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 9.3s
ci-box: clone deepened in 5.9s
ci-box: file times set from content: 3308 files, 214 directories
ci-box: ready in 18.8s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
ok amadan.net/oficina/equipo/internal/equipotest 0.150s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile
+ go build -tags testbuild ./...
5.5s
+ go list -export -test -tags testbuild -f ./...
5.4s
+ go list -export -test -tags browser,testbuild -f ./internal/equipo ./internal/equipotest ./internal/headless ./internal/idtest ./internal/plan3test ./internal/thintest
3.6s
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -version
staticcheck 2026.1 (v0.7.0)
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 -version
Go: go1.26.11
Scanner: govulncheck@v1.8.0
DB: https://vuln.go.dev
DB updated: 2026-11-24 15:56:00 +0000 UTC
go run github.com/zricethezav/gitleaks/v8@v8.30.1 version
version is set by build process
=== check ===
--- shard 0 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-work: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$' ./internal/headless
rastrillo: budget test: go test failed
--- FAIL amadan.net/oficina/equipo/internal/headless TestHeadless
=== RUN TestHeadless
--- FAIL: TestHeadless (69.49s)
--- FAIL amadan.net/oficina/equipo/internal/headless TestHeadless/4c_rebase
=== RUN TestHeadless/4c_rebase
time=2026-11-28T18:30:37.532Z level=INFO msg="startup phase" phase=state_lock
time=2026-11-28T18:30:37.532Z level=INFO msg="startup phase done" phase=state_lock took=82µs
time=2026-11-28T18:30:37.532Z level=INFO msg="startup phase" phase=claim_roots
time=2026-11-28T18:30:37.532Z level=INFO msg="startup phase done" phase=claim_roots took=80µs
time=2026-11-28T18:30:37.532Z level=INFO msg="startup phase" phase=sweep
time=2026-11-28T18:30:37.573Z level=INFO msg="startup phase done" phase=sweep took=40.188ms
time=2026-11-28T18:30:37.573Z level=INFO msg="startup phase" phase=credentials
time=2026-11-28T18:30:37.573Z level=INFO msg="startup phase done" phase=credentials took=202µs
time=2026-11-28T18:30:37.573Z level=INFO msg="startup phase" phase=open_state
time=2026-11-28T18:30:37.620Z level=INFO msg="startup phase done" phase=open_state took=46.849ms
time=2026-11-28T18:30:37.620Z level=WARN msg="no seal key: token connections cannot be added" err=*fs.PathError
time=2026-11-28T18:30:37.621Z level=INFO msg=connecting host=127.0.0.1:44679 protocol=35
time=2026-11-28T18:30:37.624Z level=INFO msg=connected host=127.0.0.1:44679 took=2.541ms
time=2026-11-28T18:30:37.624Z level=INFO msg="capabilities gathering"
time=2026-11-28T18:30:37.624Z level=INFO msg="capabilities gathered" took=560µs tags=linux,claude,go
time=2026-11-28T18:30:37.626Z level=INFO msg="hello sent" protocol=35
time=2026-11-28T18:30:37.634Z level=INFO msg=welcome protocol=35 role=primary generation=1
time=2026-11-28T18:30:38.441Z level=INFO msg="connection checked" connection=claude-1 state=healthy
time=2026-11-28T18:30:42.419Z level=INFO msg="kept sessions" kept=1 bytes=2939 expired=0
time=2026-11-28T18:30:47.941Z level=INFO msg="kept sessions" kept=2 bytes=5145 expired=0
merge_test.go:245: steps [engineering:done checks:passed review:approve merge:merge_conflict engineering:queued], want [engineering:done checks:passed review:approve merge:merge_conflict engineering:done checks:passed review:approve merge:done] (in_progress )
time=2026-11-28T18:30:48.037Z level=WARN msg="step clone" err="signal: killed"
--- FAIL: TestHeadless/4c_rebase (10.98s)
--- FAIL amadan.net/oficina/equipo/internal/headless (package output)
FAIL
rastrillo-budget/v1 ran 1m9.495s
FAIL amadan.net/oficina/equipo/internal/headless 69.786s
receipt: test step 1m11.633s against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 0 cached, 0 without tests, 1 failed
receipt: slow package 1m9.495s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m9.49s amadan.net/oficina/equipo/internal/headless TestHeadless
exit status 1
+ go test -tags testbuild -timeout 15m -run '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$' -v -run '^TestHeadless$/^4c_rebase$' -count=1 ./internal/headless (retry, once)
##############################################################################
FLAKE ./internal/headless:TestHeadless/4c_rebase headless-work 537a4e0912fac4b27ed9da5e53993268911bfdda 10.98s 68.36
##############################################################################
failed, then passed on its one retry: the step stays green and the flake is on record
machine: 32 CPUs, load 62.33, cpu waiting 38.64%, memory waiting 0.00%, io waiting 0.40%
--- shard 1 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-review: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadless$/^4_review$|^TestHeadless$/^2b_access$|^TestHeadless$/^runner_crash$|^TestHeadless$/^2b_first_message$|^TestHeadless$/^4_checks_honest$|^TestHeadless$/^7_stream_resume$|^TestHeadless$/^2b_notebook$|^TestHeadless$/^2b_move_in$|^TestHeadless$/^2b_desk_failure$|^TestHeadless$/^cancel$' ./internal/headless
receipt: test step 1m20.006s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m17.493s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m17.49s amadan.net/oficina/equipo/internal/headless TestHeadless
machine: 32 CPUs, load 66.73, cpu waiting 39.36%, memory waiting 0.00%, io waiting 0.50%
--- shard 2 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-connections: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$' ./internal/headless
receipt: test step 1m21.32s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m18.836s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m9.11s amadan.net/oficina/equipo/internal/headless TestHeadlessConnections
receipt: slow test 5.1s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenPasteEndToEnd
receipt: slow test 4.63s amadan.net/oficina/equipo/internal/headless TestHeadlessTokenConnection
machine: 32 CPUs, load 64.19, cpu waiting 39.36%, memory waiting 0.00%, io waiting 0.50%
--- shard 3 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-mac: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$' ./internal/headless
receipt: test step 1m18.559s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m16.106s amadan.net/oficina/equipo/internal/headless
receipt: slow test 38.65s amadan.net/oficina/equipo/internal/headless TestMacWorker
receipt: slow test 19.13s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.22s amadan.net/oficina/equipo/internal/headless TestHeadlessAttachments
receipt: slow test 9.11s amadan.net/oficina/equipo/internal/headless TestHeadlessPrewarm
machine: 32 CPUs, load 66.73, cpu waiting 39.50%, memory waiting 0.00%, io waiting 0.51%
--- shard 4 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-guards: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestHeadlessCopyRotation$|^TestHeadlessPolicyGuards$|^TestHeadlessRunnerKillLeavesNoCopies$|^TestHeadlessNewHouseRuleStartsFresh$|^TestHeadless$/^3_engineering$|^TestHeadless$/^3_step_cancel$|^TestHeadless$/^3_step_contained$|^TestHeadless$/^3_step_refused$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless
receipt: test step 1m35.929s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m33.792s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m3.49s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.68s amadan.net/oficina/equipo/internal/headless TestHeadlessRunnerKillLeavesNoCopies
receipt: slow test 8.55s amadan.net/oficina/equipo/internal/headless TestHeadlessCopyRotation
receipt: slow test 7.31s amadan.net/oficina/equipo/internal/headless TestHeadlessPolicyGuards
receipt: slow test 4.76s amadan.net/oficina/equipo/internal/headless TestHeadlessNewHouseRuleStartsFresh
machine: 32 CPUs, load 59.18, cpu waiting 37.91%, memory waiting 0.00%, io waiting 0.38%
--- shard 5 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane headless-rest: ./internal/headless
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestHeadless$/^4c_rebase$|^TestHeadless$/^4b_ask$|^TestHeadless$/^4c_checks_card$|^TestHeadless$/^4_step_crash$|^TestHeadless$/^4_review$|^TestHeadless$/^2b_access$|^TestHeadless$/^runner_crash$|^TestHeadless$/^2b_first_message$|^TestHeadless$/^4_checks_honest$|^TestHeadless$/^7_stream_resume$|^TestHeadless$/^2b_notebook$|^TestHeadless$/^2b_move_in$|^TestHeadless$/^2b_desk_failure$|^TestHeadless$/^cancel$|^TestHeadlessConnections$|^TestHeadlessTokenPasteEndToEnd$|^TestHeadlessTokenConnection$|^TestMacWorker$|^TestHeadlessAttachments$|^TestHeadlessPrewarm$|^TestHeadless$/^1_first_token$|^TestHeadless$/^6_quick_messages$|^TestHeadless$/^8_instance_restart$|^TestHeadless$/^3_runner_offline$|^TestHeadlessCopyRotation$|^TestHeadlessPolicyGuards$|^TestHeadlessRunnerKillLeavesNoCopies$|^TestHeadlessNewHouseRuleStartsFresh$|^TestHeadless$/^3_engineering$|^TestHeadless$/^3_step_cancel$|^TestHeadless$/^3_step_contained$|^TestHeadless$/^3_step_refused$|^TestHeadless$/^3_empty_repo$|^TestHeadless$/^3_empty_engineering$|^TestHeadless$/^3_empty_merge$|^TestHeadless$/^3_empty_merge_rebuilt$|^TestHeadless$/^3_empty_fix_round$' ./internal/headless
receipt: test step 2m58.495s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2m56.529s amadan.net/oficina/equipo/internal/headless
receipt: slow test 1m40.1s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistant
receipt: slow test 20.22s amadan.net/oficina/equipo/internal/headless TestHeadless
receipt: slow test 9.21s amadan.net/oficina/equipo/internal/headless TestHeadlessResearchHandoff
receipt: slow test 7.04s amadan.net/oficina/equipo/internal/headless TestHeadlessAssistantAttachments
receipt: slow test 6.76s amadan.net/oficina/equipo/internal/headless TestHeadlessTurnBatching
machine: 32 CPUs, load 22.01, cpu waiting 10.29%, memory waiting 0.00%, io waiting 0.09%
--- shard 6 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane thintest: ./internal/thintest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test([^C]|C[^o]|Co[^n]|Con[^t])|^TestContract(Assistant|Outcome|Team|Handoff|HostAllowlist|HostIsPerPerson|Look|Use[A-Z]|RemoteCall|LanesRunAtOnce|NoMergeQuestionWhenGateMerges|PreviewHeldUntilPublishAnswer|PreviewNotHeldBelow19|PublishNeedsOwnerAnswer)' ./internal/thintest
receipt: test step 2m16.403s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2m14.074s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 10.08s amadan.net/oficina/equipo/internal/thintest TestContractTeamJobSettledStates
receipt: slow test 6.73s amadan.net/oficina/equipo/internal/thintest TestExplorePreviewsOff
receipt: slow test 4.13s amadan.net/oficina/equipo/internal/thintest TestContractTeamNudgePersonNeeds
receipt: slow test 4.05s amadan.net/oficina/equipo/internal/thintest TestContractPreviewHeldUntilPublishAnswer
receipt: slow test 3.68s amadan.net/oficina/equipo/internal/thintest TestContractTeamUpdatePersonNeeds
machine: 32 CPUs, load 36.89, cpu waiting 20.63%, memory waiting 0.00%, io waiting 0.19%
--- shard 7 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane thintest-contract: ./internal/thintest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^Test([^C]|C[^o]|Co[^n]|Con[^t])|^TestContract(Assistant|Outcome|Team|Handoff|HostAllowlist|HostIsPerPerson|Look|Use[A-Z]|RemoteCall|LanesRunAtOnce|NoMergeQuestionWhenGateMerges|PreviewHeldUntilPublishAnswer|PreviewNotHeldBelow19|PublishNeedsOwnerAnswer)' ./internal/thintest
receipt: test step 1m58.347s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m55.951s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 9.5s amadan.net/oficina/equipo/internal/thintest TestContractRetryPreviewUnverifiedMerge
receipt: slow test 9.15s amadan.net/oficina/equipo/internal/thintest TestContractPreviewNotScheduled
receipt: slow test 5.04s amadan.net/oficina/equipo/internal/thintest TestContractPublishNotOffered
receipt: slow test 4.51s amadan.net/oficina/equipo/internal/thintest TestContractMacRecheckMergeAuthority
receipt: slow test 3.02s amadan.net/oficina/equipo/internal/thintest TestContractPausedJob
machine: 32 CPUs, load 47.37, cpu waiting 27.68%, memory waiting 0.00%, io waiting 0.26%
--- shard 8 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-thin: ./internal/runner/thin
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./internal/runner/thin
budget note: internal/runner/thin took 5m13.57s, over the 45s its record on line 44 allows; reported only, timing fails on CI
receipt: test step 5m19.348s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 5m13.57s amadan.net/oficina/equipo/internal/runner/thin
receipt: slow test 37.04s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeAnsweredByAnotherModel
receipt: slow test 36.9s amadan.net/oficina/equipo/internal/runner/thin TestModelsEngineeringProbesThenRunsTheStrongest
receipt: slow test 36.82s amadan.net/oficina/equipo/internal/runner/thin TestModelsUnhealthyRetriedOnDemand
receipt: slow test 18.49s amadan.net/oficina/equipo/internal/runner/thin TestModelsProbeRunsInsideTheAdmission
receipt: slow test 9.93s amadan.net/oficina/equipo/internal/runner/thin TestTimeoutKeepsNothingForAnOlderInstance
machine: 32 CPUs, load 3.90, cpu waiting 0.96%, memory waiting 0.00%, io waiting 0.01%
--- shard 9 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-bug: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$' ./internal/runner
receipt: test step 50.924s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 49.985s amadan.net/oficina/equipo/internal/runner
receipt: slow test 29.95s amadan.net/oficina/equipo/internal/runner TestDirectBugWorkflow
receipt: slow test 20.03s amadan.net/oficina/equipo/internal/runner TestEnrolKeepsTheRole
machine: 32 CPUs, load 65.45, cpu waiting 34.33%, memory waiting 0.00%, io waiting 0.80%
--- shard 10 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-plans: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
receipt: test step 1m0.657s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 59.398s amadan.net/oficina/equipo/internal/runner
receipt: slow test 49.37s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowCandidateOrder
receipt: slow test 43.05s amadan.net/oficina/equipo/internal/runner TestPlanWorkflowFeature
receipt: slow test 8.41s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryCallRefusalKeepsServing
receipt: slow test 1.6s amadan.net/oficina/equipo/internal/runner TestCoordinatorRefusalMatrix
machine: 32 CPUs, load 66.22, cpu waiting 38.10%, memory waiting 0.00%, io waiting 0.70%
--- shard 11 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
test lane runner-rest: ./internal/runner
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^TestDirectBugWorkflow$|^TestEnrolKeepsTheRole$|^TestPlanWorkflowCandidateOrder$|^TestPlanWorkflowFeature$|^TestCoordinatorRecoveryCallRefusalKeepsServing$|^TestCoordinatorRefusalMatrix$' ./internal/runner
receipt: test step 36.04s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 35.197s amadan.net/oficina/equipo/internal/runner
receipt: slow test 5.14s amadan.net/oficina/equipo/internal/runner TestDirectFaultIsolation
receipt: slow test 3.34s amadan.net/oficina/equipo/internal/runner TestClaimRefusalsBackOff
receipt: slow test 3.12s amadan.net/oficina/equipo/internal/runner TestCoordinatorRecoveryRefusedKeepsServing
receipt: slow test 2.86s amadan.net/oficina/equipo/internal/runner TestToolVerbUnderFakeHarness
receipt: slow test 1.61s amadan.net/oficina/equipo/internal/runner TestReportPostsRetryExactRequest
machine: 32 CPUs, load 42.12, cpu waiting 21.69%, memory waiting 0.00%, io waiting 1.04%
--- shard 12 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-a started 30s late; cpu waiting 38.9%, load 31.03
test lane equipotest-a: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[A-D]|^TestQ' ./internal/equipotest
--- FAIL amadan.net/oficina/equipo/internal/equipotest TestDirectDeadReferencesRepository
=== RUN TestDirectDeadReferencesRepository
direct_cutover_test.go:221: repository reference inventory: exit status 1
docs/superpowers/plans/2026-11-28-dynamic-specialists-slice-1.md:109:5: unclassified equipo-runner
docs/superpowers/plans/CONTROLLER-BRIEF-specialists-slice-1.md:84:25: unclassified Paseo
docs/superpowers/specs/2026-11-28-dynamic-specialists.md:224:15: unclassified equipo-runner
reference scan: 3020 text files, 3232 matches, 3 failures
--- FAIL: TestDirectDeadReferencesRepository (2.37s)
--- FAIL amadan.net/oficina/equipo/internal/equipotest (package output)
FAIL
rastrillo-budget/v1 ran 1m7.366s
FAIL amadan.net/oficina/equipo/internal/equipotest 67.709s
receipt: test step 1m9.823s against a 60s target (the gate's other steps are not in this figure)
receipt: 0 packages ran, 0 cached, 0 without tests, 1 failed
receipt: slow package 1m7.366s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 28.45s amadan.net/oficina/equipo/internal/equipotest TestAuthorityCoreIntegration
receipt: slow test 28.34s amadan.net/oficina/equipo/internal/equipotest TestBootstrapNamesOwnersSetting
receipt: slow test 26.17s amadan.net/oficina/equipo/internal/equipotest TestAccountLabelMigration
receipt: slow test 23.49s amadan.net/oficina/equipo/internal/equipotest TestBudgetConfigurationFailuresAreAtomic
receipt: slow test 23.29s amadan.net/oficina/equipo/internal/equipotest TestAuthProductionConfig
rastrillo: budget test: go test failed
exit status 1
+ go test -tags testbuild -timeout 15m -run '^Test[A-D]|^TestQ' -v -run '^TestDirectDeadReferencesRepository$' -count=1 ./internal/equipotest (retry, once)
FAILED TWICE ./internal/equipotest:TestDirectDeadReferencesRepository equipotest-a
=== RUN TestDirectDeadReferencesRepository
direct_cutover_test.go:221: repository reference inventory: exit status 1
docs/superpowers/plans/2026-11-28-dynamic-specialists-slice-1.md:109:5: unclassified equipo-runner
docs/superpowers/plans/CONTROLLER-BRIEF-specialists-slice-1.md:84:25: unclassified Paseo
docs/superpowers/specs/2026-11-28-dynamic-specialists.md:224:15: unclassified equipo-runner
reference scan: 3020 text files, 3232 matches, 3 failures
--- FAIL: TestDirectDeadReferencesRepository (2.26s)
FAIL
rastrillo-budget/v1 ran 2.259s
FAIL amadan.net/oficina/equipo/internal/equipotest 2.420s
FAIL
machine: 32 CPUs, load 55.24, cpu waiting 34.13%, memory waiting 0.00%, io waiting 0.33%
make: *** [Makefile:113: ci-shard] Error 1
amadan: step check shard 12 of 29 failed: exit status 2
--- shard 13 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-e started 30s late; cpu waiting 38.9%, load 36.47
test lane equipotest-e: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^Test[E-P]' ./internal/equipotest
receipt: test step 2m14.165s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2m11.877s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 20.72s amadan.net/oficina/equipo/internal/equipotest TestProjectWritesRequireCurrentOwner
receipt: slow test 20.7s amadan.net/oficina/equipo/internal/equipotest TestProjectsFailuresRollBack
receipt: slow test 20.69s amadan.net/oficina/equipo/internal/equipotest TestProjectsReopen
receipt: slow test 20.64s amadan.net/oficina/equipo/internal/equipotest TestProjectsSharedAndGrouped
receipt: slow test 20.64s amadan.net/oficina/equipo/internal/equipotest TestProjectRejectsUnsafeBinding
machine: 32 CPUs, load 27.32, cpu waiting 12.99%, memory waiting 0.00%, io waiting 0.11%
--- shard 14 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-r started 30s late; cpu waiting 38.9%, load 36.47
test lane equipotest-r: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -run '^TestR' ./internal/equipotest
budget note: internal/equipotest took 5m38.124s, over the 5m0s its record on line 15 allows; reported only, timing fails on CI
receipt: test step 5m43.975s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 5m38.124s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 4m46.37s amadan.net/oficina/equipo/internal/equipotest TestReleaseStampContract
receipt: slow test 13.23s amadan.net/oficina/equipo/internal/equipotest TestRosterChangesAffectExistingSession
receipt: slow test 10.19s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalWhileAssigned
receipt: slow test 10.17s amadan.net/oficina/equipo/internal/equipotest TestRosterRemovalRollsBack
receipt: slow test 7.13s amadan.net/oficina/equipo/internal/equipotest TestRosterBootstrapOnce
machine: 32 CPUs, load 2.08, cpu waiting 0.38%, memory waiting 0.00%, io waiting 0.00%
--- shard 15 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: equipotest-rest started 30s late; cpu waiting 38.9%, load 36.47
test lane equipotest-rest: ./internal/equipotest
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m -skip '^Test[A-D]|^TestQ|^Test[E-P]|^TestR' ./internal/equipotest
receipt: test step 1m10.668s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m8.211s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 26.72s amadan.net/oficina/equipo/internal/equipotest TestSigninNoProof
receipt: slow test 26.33s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedExistingTeam
receipt: slow test 26.25s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedRollback
receipt: slow test 24.43s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsSeedAuditRollback
receipt: slow test 24.36s amadan.net/oficina/equipo/internal/equipotest TestSpecialistsUpgrade
machine: 32 CPUs, load 55.24, cpu waiting 35.18%, memory waiting 0.00%, io waiting 0.34%
--- shard 16 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: plan3test started 30s late; cpu waiting 38.9%, load 31.03
test lane plan3test: ./internal/plan3test
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./internal/plan3test
receipt: test step 56.441s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 53.763s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 3.86s amadan.net/oficina/equipo/internal/plan3test TestPlan3Upgrade
receipt: slow test 3.49s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3B
receipt: slow test 1.71s amadan.net/oficina/equipo/internal/plan3test TestConversationQuestionRace
receipt: slow test 1.52s amadan.net/oficina/equipo/internal/plan3test TestCoordinatorAcceptance3A
receipt: slow test 1.37s amadan.net/oficina/equipo/internal/plan3test TestInviteMigration
machine: 32 CPUs, load 62.97, cpu waiting 39.14%, memory waiting 0.00%, io waiting 0.45%
--- shard 17 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: rest started 30s late; cpu waiting 38.9%, load 31.03
test lane rest: ./cmd/equipo ./cmd/equipo-runner ./cmd/equipo-tool-proxy ./internal/advice ./internal/attach ./internal/attach/attachtest ./internal/chatmarkdown ./internal/chatsend ./internal/chatstream ./internal/coordinator ./internal/coordinatorcontract ./internal/coordinatormail ./internal/copydesk ./internal/diffscan ./internal/equipo ./internal/equipo/activity ./internal/equipo/assist ./internal/equipo/chat ./internal/equipo/conversation ./internal/equipo/conversation/chatstate ./internal/equipo/door ./internal/equipo/github ./internal/equipo/housekeeping ./internal/equipo/icons ./internal/equipo/identity ./internal/equipo/kernel ./internal/equipo/library ./internal/equipo/mergegate ./internal/equipo/notifications ./internal/equipo/oficina ./internal/equipo/oficina/oficinatest ./internal/equipo/oficinaid ./internal/equipo/ownermode ./internal/equipo/pause ./internal/equipo/personapi ./internal/equipo/planning ./internal/equipo/push ./internal/equipo/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/idtest ./internal/ownermodetest ./internal/release ./internal/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/claude/realcli ./internal/runner/provider/codex ./internal/runner/provider/gotoolchain ./internal/runner/provider/opencode ./internal/runner/provider/pi ./internal/runner/render ./internal/runner/setup ./internal/runner/transporttest ./internal/runner/webread ./internal/runner/workspace ./internal/runnerproto ./internal/schedule ./internal/sealbox ./internal/specialist ./internal/stagingtest ./internal/taskplan ./internal/testci ./internal/toolproxy ./internal/websource ./internal/wire ./internal/wire/forgekey ./internal/wire/wireschema ./internal/wire/wiretest ./tools/drive
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags testbuild -timeout 15m ./cmd/equipo ./cmd/equipo-runner ./cmd/equipo-tool-proxy ./internal/advice ./internal/attach ./internal/attach/attachtest ./internal/chatmarkdown ./internal/chatsend ./internal/chatstream ./internal/coordinator ./internal/coordinatorcontract ./internal/coordinatormail ./internal/copydesk ./internal/diffscan ./internal/equipo ./internal/equipo/activity ./internal/equipo/assist ./internal/equipo/chat ./internal/equipo/conversation ./internal/equipo/conversation/chatstate ./internal/equipo/door ./internal/equipo/github ./internal/equipo/housekeeping ./internal/equipo/icons ./internal/equipo/identity ./internal/equipo/kernel ./internal/equipo/library ./internal/equipo/mergegate ./internal/equipo/notifications ./internal/equipo/oficina ./internal/equipo/oficina/oficinatest ./internal/equipo/oficinaid ./internal/equipo/ownermode ./internal/equipo/pause ./internal/equipo/personapi ./internal/equipo/planning ./internal/equipo/push ./internal/equipo/setup ./internal/equipo/team ./internal/equipo/teamcontract ./internal/equipo/triage ./internal/fakeclaude ./internal/fakecodex ./internal/fakeopencode ./internal/fakepi ./internal/idtest ./internal/ownermodetest ./internal/release ./internal/runner/checks ./internal/runner/connect ./internal/runner/containment ./internal/runner/containment/sysunix ./internal/runner/egress ./internal/runner/forge ./internal/runner/forge/forgetest ./internal/runner/heartbeat ./internal/runner/mac ./internal/runner/mcpresource ./internal/runner/metered ./internal/runner/planflow ./internal/runner/provider ./internal/runner/provider/claude ./internal/runner/provider/claude/realcli ./internal/runner/provider/codex ./internal/runner/provider/gotoolchain ./internal/runner/provider/opencode ./internal/runner/provider/pi ./internal/runner/render ./internal/runner/setup ./internal/runner/transporttest ./internal/runner/webread ./internal/runner/workspace ./internal/runnerproto ./internal/schedule ./internal/sealbox ./internal/specialist ./internal/stagingtest ./internal/taskplan ./internal/testci ./internal/toolproxy ./internal/websource ./internal/wire ./internal/wire/forgekey ./internal/wire/wireschema ./internal/wire/wiretest ./tools/drive
cache miss: amadan.net/oficina/equipo/internal/runner/provider/claude/realcli: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/copydesk: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/forge: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/webread: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runnerproto: its inputs changed
cache miss: amadan.net/oficina/equipo/internal/runner/workspace: its inputs changed
budget note: internal/equipo took 2m23.274s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/equipo/chat took 25.953s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/equipo/github took 40.581s, over the 10s the default allows (measured on the run this cached result came from); reported only, timing fails on CI
budget note: internal/equipo/setup took 12.494s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/idtest took 1m52.572s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/release took 38.883s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/runner/containment took 1m0.895s, over the 15s its record on line 40 allows; reported only, timing fails on CI
budget note: internal/runner/forge took 24.93s, over the 20s its record on line 35 allows; reported only, timing fails on CI
budget note: internal/runner/provider/claude/realcli took 13.089s, over the 10s the default allows; reported only, timing fails on CI
budget note: internal/runner/provider/pi took 1m24.894s, over the 1m0s its record on line 27 allows; reported only, timing fails on CI
budget note: internal/runner/workspace took 10.103s, over the 10s the default allows; reported only, timing fails on CI
receipt: test step 2m29.553s against a 60s target (the gate's other steps are not in this figure)
receipt: 29 packages ran, 41 cached, 16 without tests, 0 failed
receipt: slow package 2m23.274s amadan.net/oficina/equipo/internal/equipo
receipt: slow package 1m52.572s amadan.net/oficina/equipo/internal/idtest
receipt: slow package 1m24.894s amadan.net/oficina/equipo/internal/runner/provider/pi
receipt: slow package 1m11.418s amadan.net/oficina/equipo/internal/runner/provider/opencode
receipt: slow package 1m0.895s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 55.42s amadan.net/oficina/equipo/internal/idtest TestDoorRemembersOficinaID
receipt: slow test 47.07s amadan.net/oficina/equipo/internal/idtest TestDoorOficinaSettingsUnreadableIsNoLoop
receipt: slow test 46.87s amadan.net/oficina/equipo/internal/idtest TestDoorStepUpIsLocal
receipt: slow test 46.75s amadan.net/oficina/equipo/internal/idtest TestDoorForgetsOficinaIDForARefusedSession
receipt: slow test 46.59s amadan.net/oficina/equipo/internal/idtest TestDoorNeverJudgesANativeSession
machine: 32 CPUs, load 22.01, cpu waiting 9.95%, memory waiting 0.00%, io waiting 0.08%
--- shard 18 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-chat: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$' ./internal/headless
receipt: test step 1m25.754s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m23.89s amadan.net/oficina/equipo/internal/headless
receipt: slow test 38.84s amadan.net/oficina/equipo/internal/headless TestBrowserDraftIsTheMessage
receipt: slow test 14.75s amadan.net/oficina/equipo/internal/headless TestBrowserDraftStreamsFormatted
receipt: slow test 10.68s amadan.net/oficina/equipo/internal/headless TestBrowserChat
receipt: slow test 7.67s amadan.net/oficina/equipo/internal/headless TestBrowserComposer
receipt: slow test 6.54s amadan.net/oficina/equipo/internal/headless TestBrowserChatSendStaysOnPage
machine: 32 CPUs, load 62.97, cpu waiting 39.14%, memory waiting 0.00%, io waiting 0.45%
--- shard 19 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-work: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$' ./internal/headless
receipt: test step 1m32.907s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m31.134s amadan.net/oficina/equipo/internal/headless
receipt: slow test 29.33s amadan.net/oficina/equipo/internal/headless TestBrowserRailFollowsWork
receipt: slow test 21s amadan.net/oficina/equipo/internal/headless TestBrowserTaskThread
receipt: slow test 13.65s amadan.net/oficina/equipo/internal/headless TestBrowserReceiptFollowsReview
receipt: slow test 9.4s amadan.net/oficina/equipo/internal/headless TestBrowserAskAfterMerge
receipt: slow test 8.76s amadan.net/oficina/equipo/internal/headless TestBrowserTaskCard
machine: 32 CPUs, load 62.33, cpu waiting 38.42%, memory waiting 0.00%, io waiting 0.38%
--- shard 20 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-connections: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless
receipt: test step 1m54.024s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m52.179s amadan.net/oficina/equipo/internal/headless
receipt: slow test 14.86s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsConversation
receipt: slow test 13.42s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAddPage
receipt: slow test 12.36s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsAdd
receipt: slow test 11.41s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsMeteredLimitRequired
receipt: slow test 11.29s amadan.net/oficina/equipo/internal/headless TestBrowserConnectionsSignInEmail
machine: 32 CPUs, load 49.23, cpu waiting 28.52%, memory waiting 0.00%, io waiting 0.27%
--- shard 21 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-headless-rest: ./internal/headless
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAskAfterMerge|TestBrowserCardAnswerSettlesAtBottom|TestBrowserChat|TestBrowserChatSendStaysOnPage|TestBrowserComposer|TestBrowserComposerDock|TestBrowserComposerFocus|TestBrowserComposerReconcile|TestBrowserConnectionsAdd|TestBrowserConnectionsAddPage|TestBrowserConnectionsConversation|TestBrowserConnectionsCopyLink|TestBrowserConnectionsEndedNote|TestBrowserConnectionsMeteredLimitRequired|TestBrowserConnectionsOpenCodeGoLimitRequired|TestBrowserConnectionsSignIn|TestBrowserConnectionsSignInEmail|TestBrowserConnectionsSignInSwitch|TestBrowserConnectionsToken|TestBrowserCopyContinue|TestBrowserCopySettingAndFlag|TestBrowserDraftIsTheMessage|TestBrowserDraftStreamsFormatted|TestBrowserEmptyExplore|TestBrowserMoveIn|TestBrowserNotebook|TestBrowserNotebookLook|TestBrowserPasteBox|TestBrowserPasteBoxLook|TestBrowserPasteCopiesItsBox|TestBrowserRailFollowsWork|TestBrowserReceiptFollowsReview|TestBrowserReceiptsDesktop|TestBrowserReceiptsTouch|TestBrowserRefreshRace|TestBrowserStalePageReloads|TestBrowserTaskCard|TestBrowserTaskThread|TestBrowserThinkingAndCards|TestBrowserUsageAndAdvice|TestBrowserWaitingTurns|TestNotebookScreenshots)$' -skip '^TestBrowserChat$|^TestBrowserChatSendStaysOnPage$|^TestBrowserComposer$|^TestBrowserComposerReconcile$|^TestBrowserComposerFocus$|^TestBrowserComposerDock$|^TestBrowserDraftStreamsFormatted$|^TestBrowserDraftIsTheMessage$|^TestBrowserTaskCard$|^TestBrowserReceiptFollowsReview$|^TestBrowserRailFollowsWork$|^TestBrowserTaskThread$|^TestBrowserAskAfterMerge$|^TestBrowserReceiptsDesktop$|^TestBrowserReceiptsTouch$|^TestBrowserConnections|^TestBrowserPasteBox$|^TestBrowserPasteCopiesItsBox$' ./internal/headless
receipt: test step 1m39.143s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 1m37.054s amadan.net/oficina/equipo/internal/headless
receipt: slow test 14.94s amadan.net/oficina/equipo/internal/headless TestBrowserThinkingAndCards
receipt: slow test 13.17s amadan.net/oficina/equipo/internal/headless TestBrowserWaitingTurns
receipt: slow test 10.89s amadan.net/oficina/equipo/internal/headless TestBrowserStalePageReloads
receipt: slow test 9.44s amadan.net/oficina/equipo/internal/headless TestBrowserMoveIn
receipt: slow test 7.44s amadan.net/oficina/equipo/internal/headless TestBrowserRefreshRace
machine: 32 CPUs, load 59.18, cpu waiting 36.27%, memory waiting 0.00%, io waiting 0.35%
--- shard 22 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
timing budgets: reported, not enforced: a shared runner's load is not this change's time (set EQUIPO_CI_DEDICATED=1 on a dedicated runner)
browser: /opt/chromium-156.0.8078.79-1_deb13u1/chrome: Chromium 156.0.8078.79
browser lane browser-rest: ./internal/equipo
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserPreviewBlocksNavigation|TestBrowserPreviewPassExchange)$' ./internal/equipo
receipt: test step 4.134s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2.465s amadan.net/oficina/equipo/internal/equipo
receipt: slow test 1.83s amadan.net/oficina/equipo/internal/equipo TestBrowserPreviewPassExchange
receipt: slow test 630ms amadan.net/oficina/equipo/internal/equipo TestBrowserPreviewBlocksNavigation
browser lane browser-rest: ./internal/equipotest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserGitHubManifestCSP)$' ./internal/equipotest
receipt: test step 7.916s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 6.298s amadan.net/oficina/equipo/internal/equipotest
receipt: slow test 6.3s amadan.net/oficina/equipo/internal/equipotest TestBrowserGitHubManifestCSP
browser lane browser-rest: ./internal/idtest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserOficinaIDDoor|TestBrowserSmartDoor)$' ./internal/idtest
budget note: internal/idtest took 10.692s, over the 10s the default allows; reported only, timing fails on CI
receipt: test step 12.365s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 10.692s amadan.net/oficina/equipo/internal/idtest
receipt: slow test 8.67s amadan.net/oficina/equipo/internal/idtest TestBrowserSmartDoor
receipt: slow test 2.03s amadan.net/oficina/equipo/internal/idtest TestBrowserOficinaIDDoor
browser lane browser-rest: ./internal/plan3test
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestTeamsHierarchyBrowser)$' ./internal/plan3test
receipt: test step 4.008s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 2.275s amadan.net/oficina/equipo/internal/plan3test
receipt: slow test 2.27s amadan.net/oficina/equipo/internal/plan3test TestTeamsHierarchyBrowser
browser lane browser-rest: ./internal/thintest
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -tags browser,testbuild -timeout 15m -run '^(TestBrowserAccessEmojiByline|TestBrowserAccessFinalOutcomes|TestBrowserAccessRequest|TestBrowserAccessReview|TestBrowserActivitySubjects|TestBrowserAutonomySettings|TestBrowserCoordinatorQueue|TestBrowserEmptyConversation|TestBrowserEndedNoteStaysGone|TestBrowserHousekeeping|TestBrowserInnerGallery|TestBrowserInnerScreens|TestBrowserInstantThinking|TestBrowserInstantThinkingQueued|TestBrowserMachines|TestBrowserPausedWork|TestBrowserPhoneIndex|TestBrowserPlacementQuestionAndPending|TestBrowserProjectPlacement|TestBrowserProjectsList|TestBrowserReportActionFeedback|TestBrowserReportNextSteps|TestBrowserReportThread|TestBrowserRhythm|TestBrowserRollup|TestBrowserRosterAlignment|TestBrowserRosterDecisionStates|TestBrowserRosterQuietDay|TestBrowserRosterReports|TestBrowserRosterSetAside|TestBrowserRosterSubchat|TestBrowserRosterThinking|TestBrowserRosterVisual|TestBrowserSettingsHousekeepingGroups|TestBrowserSettingsMenu|TestBrowserSettingsRail|TestBrowserSettingsSaveBar|TestBrowserSettingsShots|TestBrowserSettingsStayOnPage|TestBrowserSettingsTeams|TestBrowserShipsButtons|TestBrowserSpecialistRows|TestBrowserSpendFollowsAnswers|TestBrowserTaskRows|TestBrowserTeamPanel|TestBrowserThinkingCycles|TestBrowserThinkingLinesClear|TestBrowserThinkingSteady|TestBrowserThinkingWords|TestBrowserTokenRowEmail|TestBrowserTrackPulse|TestBrowserTrackStarCentre|TestBrowserTryAgain)$' ./internal/thintest
receipt: test step 3m35.197s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 3m32.451s amadan.net/oficina/equipo/internal/thintest
receipt: slow test 25.95s amadan.net/oficina/equipo/internal/thintest TestBrowserAccessRequest
receipt: slow test 14.41s amadan.net/oficina/equipo/internal/thintest TestBrowserSettingsTeams
receipt: slow test 12.1s amadan.net/oficina/equipo/internal/thintest TestBrowserThinkingCycles
receipt: slow test 10.61s amadan.net/oficina/equipo/internal/thintest TestBrowserPlacementQuestionAndPending
receipt: slow test 9.05s amadan.net/oficina/equipo/internal/thintest TestBrowserRhythm
machine: 32 CPUs, load 8.25, cpu waiting 3.31%, memory waiting 0.00%, io waiting 0.05%
--- shard 23 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 23: make test-quarantine
python3 scripts/ci-test.py quarantine
quarantine: 12 tests from scripts/ci-quarantine.txt; a failure is retried once, and a pass on the retry is reported as a flake
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^A5_cancel_and_sign_out$|^TestHeadlessConnections$/^C4_claude_sign_in$|^TestHeadlessConnections$/^C5_engineering_failover$|^TestHeadlessConnections$/^C5_engineering_to_codex$|^TestHeadlessConnections$/^C5_engineering_waits$' ./internal/headless (52s)
ok ./internal/headless TestHeadlessConnections/A5_cancel_and_sign_out 4.60s
ok ./internal/headless TestHeadlessConnections/C4_claude_sign_in 1.23s
ok ./internal/headless TestHeadlessConnections/C5_engineering_failover 8.63s
ok ./internal/headless TestHeadlessConnections/C5_engineering_to_codex 8.23s
ok ./internal/headless TestHeadlessConnections/C5_engineering_waits 26.90s
+ go test -tags testbuild -timeout 15m -v -run '^TestHeadlessConnections$/^C5_review_auth$|^TestHeadlessConnections$/^C5_review_failover$|^TestHeadlessConnections$/^C5_review_on_codex$|^TestHeadlessConnections$/^C5_review_other_family_first$' ./internal/headless (65s)
ok ./internal/headless TestHeadlessConnections/C5_review_auth 15.57s
ok ./internal/headless TestHeadlessConnections/C5_review_failover 12.74s
ok ./internal/headless TestHeadlessConnections/C5_review_on_codex 19.65s
ok ./internal/headless TestHeadlessConnections/C5_review_other_family_first 14.48s
+ go test -tags testbuild -timeout 15m -v -run '^TestMixedVersions$' ./internal/headless (21s)
ok ./internal/headless TestMixedVersions 18.84s
+ go test -tags testbuild -timeout 15m -v -run '^TestCheckSandboxDeniedPathsTampering$' ./internal/runner/checks (2s)
ok ./internal/runner/checks TestCheckSandboxDeniedPathsTampering 0.78s
+ go test -tags testbuild -timeout 15m -v -run '^TestRunnerCancelAndSupersede$' ./internal/runner/thin (2s)
ok ./internal/runner/thin TestRunnerCancelAndSupersede 0.05s
quarantine: 0 flaked (passed on the retry), 0 failed
machine: 32 CPUs, load 69.52, cpu waiting 39.18%, memory waiting 0.00%, io waiting 0.63%
--- shard 24 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
shard 24: make runner-host
python3 scripts/runner-prerequisites.py
CGO_ENABLED=0 RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py retried runner-host -run 'TestDirect|TestProvider|TestCheckSandbox' -count=1 ./internal/runner/provider/... ./internal/runner/checks
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -run 'TestDirect|TestProvider|TestCheckSandbox' -count=1 ./internal/runner/provider/... ./internal/runner/checks
receipt: test step 13.068s against a 60s target (the gate's other steps are not in this figure)
receipt: 4 packages ran, 0 cached, 4 without tests, 0 failed
receipt: slow package 7.553s amadan.net/oficina/equipo/internal/runner/checks
receipt: slow package 227ms amadan.net/oficina/equipo/internal/runner/provider/claude
receipt: slow package 76ms amadan.net/oficina/equipo/internal/runner/provider/codex
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider
receipt: slow package 1ms amadan.net/oficina/equipo/internal/runner/provider/claude/realcli
receipt: slow test 5.23s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsGoFixture
receipt: slow test 1.79s amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPaths
receipt: slow test 370ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxDeniedPathsCache
receipt: slow test 230ms amadan.net/oficina/equipo/internal/runner/provider/claude TestDirectJournalAdapterBarrier
receipt: slow test 150ms amadan.net/oficina/equipo/internal/runner/checks TestCheckSandboxToolchain
CGO_ENABLED=0 RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py retried runner-host -run '^TestNamespace' -count=1 ./internal/runner/containment
+ go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -no-time -run '^TestNamespace' -count=1 ./internal/runner/containment
receipt: test step 4.301s against a 60s target (the gate's other steps are not in this figure)
receipt: 1 packages ran, 0 cached, 0 without tests, 0 failed
receipt: slow package 3.185s amadan.net/oficina/equipo/internal/runner/containment
receipt: slow test 300ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReadOnlyScratch
receipt: slow test 210ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryUnavailableProof
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceDirectPolicyAdmission
receipt: slow test 120ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceRecoveryCleansScratch
receipt: slow test 110ms amadan.net/oficina/equipo/internal/runner/containment TestNamespaceReapsOrphans
machine: 32 CPUs, load 26.26, cpu waiting 11.18%, memory waiting 0.00%, io waiting 1.41%
--- shard 25 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: runner-dead-references started 30s late; cpu waiting 38.9%, load 31.03
shard 25: make runner-dead-references lanes-check build vet fmt-check spacing budget migration-check
python3 scripts/runner-dead-references.py
docs/superpowers/plans/2026-11-28-dynamic-specialists-slice-1.md:109:5: unclassified equipo-runner
docs/superpowers/plans/CONTROLLER-BRIEF-specialists-slice-1.md:84:25: unclassified Paseo
docs/superpowers/specs/2026-11-28-dynamic-specialists.md:224:15: unclassified equipo-runner
reference scan: 3020 text files, 3232 matches, 3 failures
make[1]: *** [Makefile:238: runner-dead-references] Error 1
machine: 32 CPUs, load 36.47, cpu waiting 17.86%, memory waiting 0.00%, io waiting 1.12%
make: *** [Makefile:113: ci-shard] Error 2
amadan: step check shard 25 of 29 failed: exit status 2
--- shard 26 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: staticcheck started 30s late; cpu waiting 38.9%, load 31.03
shard 26: make staticcheck
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -tags browser,perf,testbuild ./...
machine: 32 CPUs, load 65.45, cpu waiting 34.33%, memory waiting 0.00%, io waiting 0.80%
--- shard 27 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: govulncheck started 30s late; cpu waiting 38.9%, load 31.03
shard 27: make govulncheck
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
=== Symbol Results ===
No vulnerabilities found.
Your code is affected by 0 vulnerabilities.
This scan also found 1 vulnerability in packages you import and 10
vulnerabilities in modules you require, but your code doesn't appear to call
these vulnerabilities.
Use '-show verbose' for more details.
machine: 32 CPUs, load 65.45, cpu waiting 35.46%, memory waiting 0.00%, io waiting 0.77%
--- shard 28 of 29 ---
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py shard
stagger: gitleaks started 30s late; cpu waiting 38.9%, load 31.03
shard 28: make gitleaks
[90m6:30PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net
[90m6:30PM[0m [32mINF[0m [1m1273 commits scanned.[0m
[90m6:30PM[0m [32mINF[0m [1mscanned ~69052429 bytes (69.05 MB) in 25.6s[0m
[90m6:30PM[0m [32mINF[0m [1mno leaks found[0m
machine: 32 CPUs, load 66.22, cpu waiting 36.46%, memory waiting 0.00%, io waiting 0.74%
amadan: job failed at step check shards 12, 25 of 29 — its output is above, not at the tail of this log
diff --git a/cmd/equipo-runner/main.go b/cmd/equipo-runner/main.go| index 19651631..21458d7d 100644 |
| --- a/cmd/equipo-runner/main.go |
| +++ b/cmd/equipo-runner/main.go |
| @@ -40,6 +40,11 @@ func run(ctx context.Context, args []string, input io.Reader, output, errorOutpu |
| if len(args) > 0 && args[0] == render.Subcommand { |
| return render.SandboxMain(args[1:], errorOutput) |
| } |
| + // And the step before it, which closes what the runner's process |
| + // should not pass on and executes bubblewrap. |
| + if len(args) > 0 && args[0] == render.ExecSubcommand { |
| + return render.ExecMain(args[1:]) |
| + } |
| if len(args) > 0 && args[0] == "account" { |
| return accountLogin(ctx, args[1:], input, output, errorOutput, getenv) |
| } |
diff --git a/internal/runner/containment/linux.go b/internal/runner/containment/linux.go| index e5400326..1668390d 100644 |
| --- a/internal/runner/containment/linux.go |
| +++ b/internal/runner/containment/linux.go |
| @@ -383,8 +383,14 @@ func (m *Manager) lifecycle(ctx context.Context, r Record, argv []string, mounts |
| if e == nil { |
| files = append(files, inputW, inputR) |
| var fd int |
| + // Under ForkLock, as os/exec does, so no fork in between |
| + // inherits the duplicate before it is close-on-exec. |
| + syscall.ForkLock.RLock() |
| if fd, e = syscall.Dup(int(inputW.Fd())); e == nil { |
| syscall.CloseOnExec(fd) |
| + } |
| + syscall.ForkLock.RUnlock() |
| + if e == nil { |
| outputR = os.NewFile(uintptr(fd), "terminal") |
| outputW = inputR |
| files = append(files, outputR) |
diff --git a/internal/runner/render/descriptors_linux.go b/internal/runner/render/descriptors_linux.go| new file mode 100644 |
| index 00000000..53cbaff9 |
| --- /dev/null |
| +++ b/internal/runner/render/descriptors_linux.go |
| @@ -0,0 +1,119 @@ |
| +//go:build linux |
| + |
| +package render |
| + |
| +import ( |
| + "math" |
| + "path/filepath" |
| + "slices" |
| + "strconv" |
| + |
| + "golang.org/x/sys/unix" |
| +) |
| + |
| +// fdKeep is the last descriptor bubblewrap is started with: 0, 1 and 2, |
| +// the browser and status pipes (3 to 5), the five binds (6 to 10) and |
| +// bubblewrap's info pipe (11). |
| +const fdKeep = fdInfo |
| + |
| +// ExecMain is the runner's render-exec subcommand: the process the |
| +// launcher starts, which closes every descriptor above fdKeep and |
| +// executes bubblewrap (args[0], an absolute path) with the render policy |
| +// and args[1:] as the sandbox's first process. |
| +// |
| +// Go cannot run code between fork and exec, and a descriptor some other |
| +// goroutine opens without close-on-exec just before the launcher forks is |
| +// inherited by the child. This process is that child: whatever it |
| +// inherited above the launch's own descriptors it closes before |
| +// bubblewrap, which passes inherited descriptors on, ever runs. It |
| +// returns only on failure. |
| +func ExecMain(args []string) int { |
| + if len(args) < 2 || !filepath.IsAbs(args[0]) || filepath.Clean(args[0]) != args[0] || args[1] == "" { |
| + return 2 |
| + } |
| + if closeFrom(fdKeep+1) != nil { |
| + return 2 |
| + } |
| + for fd := 3; fd <= fdKeep; fd++ { |
| + if _, err := unix.FcntlInt(uintptr(fd), unix.F_GETFD, 0); err != nil { |
| + return 2 |
| + } |
| + } |
| + unix.Exec(args[0], append([]string{args[0]}, bwrapArgs(args[1:]...)...), []string{}) |
| + return 2 |
| +} |
| + |
| +// sandboxDescriptors is render-sandbox's first step: descriptors 3, 4 |
| +// and 5 must be open, every other one above 2 is closed, and those three |
| +// are made close-on-exec (the browser gets 3 and 4 back through |
| +// ExtraFiles, never 5). |
| +func sandboxDescriptors() error { |
| + for _, fd := range []int{fdBrowserIn, fdBrowserOut, fdStatus} { |
| + if _, err := unix.FcntlInt(uintptr(fd), unix.F_GETFD, 0); err != nil { |
| + return err |
| + } |
| + } |
| + if err := closeFrom(fdStatus + 1); err != nil { |
| + return err |
| + } |
| + for _, fd := range []int{fdBrowserIn, fdBrowserOut, fdStatus} { |
| + if _, err := unix.FcntlInt(uintptr(fd), unix.F_SETFD, unix.FD_CLOEXEC); err != nil { |
| + return err |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// closeFrom closes every descriptor from first up. |
| +func closeFrom(first int) error { |
| + if unix.CloseRange(uint(first), math.MaxUint32, 0) == nil { |
| + return nil |
| + } |
| + // Kernels before 5.8: one at a time. |
| + return closeEach(first) |
| +} |
| + |
| +// closeEach is closeFrom by /proc/self/fd, one descriptor at a time. |
| +func closeEach(first int) error { |
| + fds, err := openDescriptors() |
| + if err != nil { |
| + return err |
| + } |
| + for _, fd := range fds { |
| + if fd >= first { |
| + unix.Close(fd) |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// openDescriptors lists this process's open descriptors, from |
| +// /proc/self/fd read with raw system calls (os.Open would start Go's |
| +// poller and add its own), without the one used to read it. |
| +func openDescriptors() ([]int, error) { |
| + d, err := unix.Open("/proc/self/fd", unix.O_RDONLY|unix.O_DIRECTORY|unix.O_CLOEXEC, 0) |
| + if err != nil { |
| + return nil, err |
| + } |
| + defer unix.Close(d) |
| + var names []string |
| + buf := make([]byte, 8192) |
| + for { |
| + n, err := unix.ReadDirent(d, buf) |
| + if err != nil { |
| + return nil, err |
| + } |
| + if n == 0 { |
| + break |
| + } |
| + _, _, names = unix.ParseDirent(buf[:n], -1, names) |
| + } |
| + var fds []int |
| + for _, name := range names { |
| + if n, err := strconv.Atoi(name); err == nil && n != d { |
| + fds = append(fds, n) |
| + } |
| + } |
| + slices.Sort(fds) |
| + return fds, nil |
| +} |
diff --git a/internal/runner/render/helpers_linux_test.go b/internal/runner/render/helpers_linux_test.go| index 451db939..224b069d 100644 |
| --- a/internal/runner/render/helpers_linux_test.go |
| +++ b/internal/runner/render/helpers_linux_test.go |
| @@ -13,23 +13,33 @@ import ( |
| "net" |
| "net/http" |
| "os" |
| + "os/exec" |
| + "os/signal" |
| "path/filepath" |
| - "slices" |
| + "runtime" |
| "strconv" |
| "strings" |
| + "syscall" |
| "time" |
| "golang.org/x/sys/unix" |
| ) |
| func helperMain(args []string) (int, bool) { |
| + if len(args) > 1 && filepath.Base(args[0]) == filepath.Base(BrowserPath) && args[1] == "--writer" { |
| + return writerMain(), true |
| + } |
| if len(args) > 0 && filepath.Base(args[0]) == filepath.Base(BrowserPath) { |
| return fakeBrowserMain(args[1:]), true |
| } |
| if len(args) > 1 { |
| switch args[1] { |
| + case ExecSubcommand: |
| + return ExecMain(args[2:]), true |
| case Subcommand: |
| return SandboxMain(args[2:], os.Stderr), true |
| + case "render-fds": |
| + return fdsMain(args[2:]), true |
| case "render-probe": |
| return probeMain(args[2:]), true |
| } |
| @@ -37,34 +47,12 @@ func helperMain(args []string) (int, bool) { |
| return 0, false |
| } |
| -// openFDs lists this process's open descriptors. It reads /proc/self/fd |
| -// with raw system calls: os.Open would start Go's poller, whose own |
| -// descriptors would then be listed. |
| +// openFDs lists this process's open descriptors. |
| func openFDs() []int { |
| - d, err := unix.Open("/proc/self/fd", unix.O_RDONLY|unix.O_DIRECTORY|unix.O_CLOEXEC, 0) |
| + fds, err := openDescriptors() |
| if err != nil { |
| return []int{-1} |
| } |
| - defer unix.Close(d) |
| - var names []string |
| - buf := make([]byte, 8192) |
| - for { |
| - n, err := unix.ReadDirent(d, buf) |
| - if err != nil { |
| - return []int{-1} |
| - } |
| - if n == 0 { |
| - break |
| - } |
| - _, _, names = unix.ParseDirent(buf[:n], -1, names) |
| - } |
| - var fds []int |
| - for _, name := range names { |
| - if n, err := strconv.Atoi(name); err == nil && n != d { |
| - fds = append(fds, n) |
| - } |
| - } |
| - slices.Sort(fds) |
| return fds |
| } |
| @@ -235,7 +223,7 @@ type browserReport struct { |
| // /out/browser.json, then answers NUL-ended messages on its pipe (read |
| // on 3, written on 4): "get <url>" fetches the URL and replies with the |
| // status and body, "post <url>" posts to it and replies with the status, "hang" |
| -// never returns, "exit <n>" exits with n, anything else is echoed. |
| +// never returns, "spawn" starts a writer that outlives every pipe, "exit <n>" exits with n, anything else is echoed. |
| func fakeBrowserMain(args []string) int { |
| r := browserReport{Args: args, Env: os.Environ(), FDs: openFDs()} |
| r.Dir, _ = os.Getwd() |
| @@ -269,6 +257,22 @@ func fakeBrowserMain(args []string) int { |
| reply = strconv.Itoa(resp.StatusCode) |
| } |
| out.WriteString(reply + "\x00") |
| + case msg == "spawn": |
| + // A process that leaves every pipe it was given and keeps |
| + // writing to /out until it is killed. |
| + w := exec.Command(os.Args[0], "--writer") |
| + w.SysProcAttr = &syscall.SysProcAttr{Setsid: true} |
| + reply := "spawned" |
| + if err := w.Start(); err != nil { |
| + reply = "error " + err.Error() |
| + } |
| + for i := 0; i < 500 && reply == "spawned"; i++ { |
| + if st, err := os.Stat(filepath.Join(OutDir, "ticks")); err == nil && st.Size() > 0 { |
| + break |
| + } |
| + time.Sleep(10 * time.Millisecond) |
| + } |
| + out.WriteString(reply + "\x00") |
| case msg == "hang": |
| // A browser that never ends on its own, even when its pipe |
| // closes: only a kill stops it. |
| @@ -284,3 +288,54 @@ func fakeBrowserMain(args []string) int { |
| } |
| } |
| } |
| + |
| +// writerMain is the spawned writer: no pipe of the sandbox's (its 0, 1 |
| +// and 2 are /dev/null), its own session, deaf to the signals a session |
| +// ending sends, appending to /out/ticks every millisecond. |
| +func writerMain() int { |
| + signal.Ignore(syscall.SIGHUP, syscall.SIGTERM, syscall.SIGINT) |
| + // Many threads make its death take a while, so a Close that does not |
| + // wait for the sandbox to end returns while it still runs. |
| + for i := 0; i < 256; i++ { |
| + go func() { |
| + runtime.LockOSThread() |
| + for { |
| + time.Sleep(time.Hour) |
| + } |
| + }() |
| + } |
| + f, err := os.OpenFile(filepath.Join(OutDir, "ticks"), os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600) |
| + if err != nil { |
| + return 1 |
| + } |
| + for { |
| + f.Write([]byte{'.'}) |
| + time.Sleep(time.Millisecond) |
| + } |
| +} |
| + |
| +type fdsReport struct { |
| + Err string |
| + FDs []int |
| + CloExec map[int]bool |
| +} |
| + |
| +// fdsMain runs sandboxDescriptors (or, with "each", closeEach(6), the |
| +// /proc fallback) on the descriptors it was started with and prints what |
| +// is left open and which are close-on-exec. |
| +func fdsMain(args []string) int { |
| + var err error |
| + if len(args) == 1 && args[0] == "each" { |
| + err = closeEach(fdStatus + 1) |
| + } else { |
| + err = sandboxDescriptors() |
| + } |
| + r := fdsReport{Err: errText(err), FDs: openFDs(), CloExec: map[int]bool{}} |
| + for _, fd := range r.FDs { |
| + flags, _ := unix.FcntlInt(uintptr(fd), unix.F_GETFD, 0) |
| + r.CloExec[fd] = flags&unix.FD_CLOEXEC != 0 |
| + } |
| + b, _ := json.Marshal(r) |
| + os.Stdout.Write(b) |
| + return 0 |
| +} |
diff --git a/internal/runner/render/launch_linux.go b/internal/runner/render/launch_linux.go| index 57940060..abea0999 100644 |
| --- a/internal/runner/render/launch_linux.go |
| +++ b/internal/runner/render/launch_linux.go |
| @@ -9,31 +9,34 @@ import ( |
| "encoding/json" |
| "errors" |
| "fmt" |
| - "math" |
| + "io" |
| "os" |
| "os/exec" |
| "path/filepath" |
| "regexp" |
| "runtime" |
| "strconv" |
| + "strings" |
| "syscall" |
| "time" |
| "golang.org/x/sys/unix" |
| - |
| - "amadan.net/oficina/equipo/internal/release" |
| ) |
| // Descriptors bubblewrap receives beyond the three the sandbox keeps |
| -// (fdBrowserIn, fdBrowserOut, fdStatus): each is bound by --ro-bind-fd |
| -// or --bind-fd, and bubblewrap closes it once bound, so the sandbox's |
| -// first process never holds one. |
| +// (fdBrowserIn, fdBrowserOut, fdStatus): each bind's is bound by |
| +// --ro-bind-fd or --bind-fd and closed by bubblewrap once bound, and the |
| +// info pipe is bubblewrap's own, so the sandbox's first process never |
| +// holds one. |
| const ( |
| fdUsr = 6 |
| fdFonts = 7 |
| fdBinary = 8 |
| fdSite = 9 |
| fdOut = 10 |
| + // fdInfo is bubblewrap's --info-fd: it writes the sandbox's first |
| + // process's PID (the PID namespace's init) there. |
| + fdInfo = 11 |
| ) |
| // bwrapArgs is the sandbox's launch policy (task 1's spike, which ran the |
| @@ -48,6 +51,7 @@ func bwrapArgs(argv ...string) []string { |
| return append([]string{ |
| "--unshare-all", "--unshare-user", |
| "--die-with-parent", "--new-session", "--clearenv", "--cap-drop", "ALL", |
| + "--info-fd", fd(fdInfo), |
| "--ro-bind-fd", fd(fdUsr), "/usr", |
| "--symlink", "usr/lib", "/lib", |
| "--symlink", "usr/lib64", "/lib64", |
| @@ -67,19 +71,15 @@ func bwrapArgs(argv ...string) []string { |
| // Launch verifies the renderer tree against the pin, starts the sandbox |
| // and waits until render-sandbox reports the site served and the browser |
| -// started. ctx bounds the sandbox's whole life: when it ends, bubblewrap |
| -// and everything in the sandbox are killed. A tree that does not verify |
| -// is a *release.RendererError and nothing starts. |
| +// started. ctx bounds the sandbox's whole life: when it ends, everything |
| +// in the sandbox is killed. A tree that does not verify is a |
| +// *release.RendererError and nothing starts. |
| func Launch(ctx context.Context, cfg LaunchConfig) (*Sandbox, error) { |
| s, err := start(ctx, cfg, Subcommand) |
| if err != nil { |
| return nil, err |
| } |
| - wait := cfg.StartTimeout |
| - if wait <= 0 { |
| - wait = StartTimeout |
| - } |
| - timer := time.NewTimer(wait) |
| + timer := time.NewTimer(startTimeout(cfg)) |
| defer timer.Stop() |
| select { |
| case st := <-s.ready: |
| @@ -100,67 +100,91 @@ func Launch(ctx context.Context, cfg LaunchConfig) (*Sandbox, error) { |
| case <-ctx.Done(): |
| err = ctx.Err() |
| } |
| - s.Close() |
| + if e := s.Close(); e != nil { |
| + err = fmt.Errorf("%w: %v", err, e) |
| + } |
| if s.err != nil { |
| err = fmt.Errorf("%w: %v", err, s.err) |
| } |
| return nil, fmt.Errorf("%w: %s", err, bytes.TrimSpace(s.stderr.Bytes())) |
| } |
| +func startTimeout(cfg LaunchConfig) time.Duration { |
| + if cfg.StartTimeout > 0 { |
| + return cfg.StartTimeout |
| + } |
| + return StartTimeout |
| +} |
| + |
| // siteURL is the only address render-sandbox may report. |
| var siteURL = regexp.MustCompile(`^http://127\.0\.0\.1:[1-9][0-9]{0,4}/$`) |
| -// start starts bubblewrap with argv as the sandbox's first process (a |
| -// test runs a probe in render-sandbox's place) and returns at once. |
| +// testBeforeFork, when set, runs just before the launcher forks (a test |
| +// opens an inheritable descriptor there). |
| +var testBeforeFork func() |
| + |
| +// endBound is how long the sandbox may take to end once its init is |
| +// killed before Wait and Close report it did not. |
| +const endBound = 10 * time.Second |
| + |
| +// ErrNotEnded is a sandbox whose processes could not be shown to have |
| +// ended within endBound of being killed. |
| +var ErrNotEnded = errors.New("render: the sandbox's processes did not end") |
| + |
| +// start starts the sandbox with argv as its first process (a test runs a |
| +// probe in render-sandbox's place) and returns once it holds a pidfd on |
| +// the sandbox's PID namespace init, or knows that init has ended. |
| +// |
| +// The runner starts its own binary (the descriptor pinned for /runner) |
| +// as render-exec, which closes every descriptor it inherited beyond the |
| +// launch's and executes bubblewrap. |
| func start(ctx context.Context, cfg LaunchConfig, argv ...string) (*Sandbox, error) { |
| for _, p := range []string{cfg.Bwrap, cfg.Binary, cfg.Tree, cfg.Site, cfg.Out} { |
| if !filepath.IsAbs(p) || filepath.Clean(p) != p { |
| return nil, fmt.Errorf("render: launch path %q", p) |
| } |
| } |
| - if err := release.VerifyRenderer(cfg.Tree, cfg.Pin); err != nil { |
| + usr, fonts, err := verifiedTree(cfg.Tree, cfg.Pin) |
| + if err != nil { |
| return nil, err |
| } |
| - var files []*os.File |
| + files := []*os.File{usr, fonts} |
| closeAll := func() { |
| for _, f := range files { |
| f.Close() |
| } |
| + files = nil |
| } |
| defer closeAll() |
| - browserIn, toBrowser, err := os.Pipe() |
| - if err != nil { |
| + var ours []*os.File |
| + fail := func(err error) (*Sandbox, error) { |
| + for _, f := range ours { |
| + f.Close() |
| + } |
| return nil, err |
| } |
| - fromBrowser, browserOut, err := os.Pipe() |
| + pipe := func() (r, w *os.File, err error) { |
| + if r, w, err = os.Pipe(); err == nil { |
| + ours = append(ours, r, w) |
| + } |
| + return |
| + } |
| + browserIn, toBrowser, err := pipe() |
| if err != nil { |
| - toBrowser.Close() |
| - browserIn.Close() |
| - return nil, err |
| + return fail(err) |
| } |
| - statusRead, statusWrite, err := os.Pipe() |
| + fromBrowser, browserOut, err := pipe() |
| if err != nil { |
| - toBrowser.Close() |
| - browserIn.Close() |
| - fromBrowser.Close() |
| - browserOut.Close() |
| - return nil, err |
| + return fail(err) |
| } |
| - // The child's ends, closed here once bubblewrap has them; ExtraFiles |
| - // gives them descriptors 3, 4 and 5 in order. |
| - files = append(files, browserIn, browserOut, statusWrite) |
| - ours := []*os.File{toBrowser, fromBrowser, statusRead} |
| - fail := func(err error) (*Sandbox, error) { |
| - for _, f := range ours { |
| - f.Close() |
| - } |
| - return nil, err |
| + statusRead, statusWrite, err := pipe() |
| + if err != nil { |
| + return fail(err) |
| } |
| - usr, fonts, err := pinTree(cfg.Tree) |
| + infoRead, infoWrite, err := pipe() |
| if err != nil { |
| return fail(err) |
| } |
| - files = append(files, usr, fonts) |
| binary, err := pinFile(cfg.Binary) |
| if err != nil { |
| return fail(err) |
| @@ -177,57 +201,188 @@ func start(ctx context.Context, cfg LaunchConfig, argv ...string) (*Sandbox, err |
| } |
| files = append(files, out) |
| - ctx, cancel := context.WithCancel(ctx) |
| - s := &Sandbox{ToBrowser: toBrowser, FromBrowser: fromBrowser, done: make(chan struct{}), stop: cancel, ready: make(chan status, 1), stderr: &bounded{max: 8192}} |
| - cmd := exec.CommandContext(ctx, cfg.Bwrap, bwrapArgs(argv...)...) |
| + s := &Sandbox{ToBrowser: toBrowser, FromBrowser: fromBrowser, done: make(chan struct{}), ready: make(chan status, 1), stderr: &bounded{max: 8192}, pidfd: -1} |
| + s.stop = s.kill |
| + // ExtraFiles start at 3, in the order the policy numbers them. |
| + cmd := exec.Command(fmt.Sprintf("/proc/self/fd/%d", fdBinary), append([]string{ExecSubcommand, cfg.Bwrap}, argv...)...) |
| + cmd.Args[0] = binaryPath |
| cmd.Env = []string{} |
| cmd.Dir = "/" |
| - cmd.ExtraFiles = files |
| + cmd.ExtraFiles = []*os.File{browserIn, browserOut, statusWrite, usr, fonts, binary, site, out, infoWrite} |
| cmd.Stdout = s.stderr |
| cmd.Stderr = s.stderr |
| cmd.WaitDelay = 5 * time.Second |
| cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGKILL} |
| + s.cmd = cmd |
| statusDone := make(chan struct{}) |
| started := make(chan error, 1) |
| + watched := make(chan struct{}) |
| go func() { |
| // Pdeathsig follows the thread that forked: keep it until the |
| // wait ends. |
| runtime.LockOSThread() |
| defer runtime.UnlockOSThread() |
| - // Every descriptor of this process is close-on-exec, so the |
| - // child gets only 0, 1, 2 and ExtraFiles. Go opens its own that |
| - // way; this catches one left inheritable by anyone else. |
| - if err := closeOnExecFrom(3); err != nil { |
| - started <- err |
| - return |
| + if testBeforeFork != nil { |
| + testBeforeFork() |
| } |
| if err := cmd.Start(); err != nil { |
| started <- err |
| return |
| } |
| - s.pid = cmd.Process.Pid |
| started <- nil |
| + // Reap bubblewrap only once start holds the init's pidfd (or |
| + // knows the init ended): until then its PID stays bubblewrap's |
| + // child, not a number someone else may be given. |
| + <-watched |
| err := cmd.Wait() |
| + ended := s.awaitEnd() |
| select { |
| case <-statusDone: |
| case <-time.After(5 * time.Second): |
| } |
| statusRead.Close() |
| - cancel() |
| if cfg.Stderr != nil { |
| cfg.Stderr.Write(s.stderr.Bytes()) |
| } |
| - s.err = err |
| + s.mu.Lock() |
| + s.err, s.ended = err, ended |
| + s.mu.Unlock() |
| close(s.done) |
| }() |
| if err = <-started; err != nil { |
| - cancel() |
| return fail(fmt.Errorf("render: start bubblewrap: %w", err)) |
| } |
| + // The child's ends belong to the child now. |
| + closeAll() |
| + for _, f := range []*os.File{browserIn, browserOut, statusWrite, infoWrite} { |
| + f.Close() |
| + } |
| + s.watch(infoRead, cmd.Process.Pid, startTimeout(cfg)) |
| + infoRead.Close() |
| + close(watched) |
| go s.readStatus(statusRead, statusDone) |
| + go func() { |
| + select { |
| + case <-ctx.Done(): |
| + s.kill() |
| + case <-s.done: |
| + } |
| + }() |
| return s, nil |
| } |
| +// watch reads the init's PID from bubblewrap's info pipe and opens a |
| +// pidfd on it. bubblewrap, the init's parent, is not reaped yet, so a |
| +// process at that PID whose parent is bubblewrap is the init: no other |
| +// process can have that parent. With no PID (bubblewrap failed before |
| +// the sandbox existed) or no such process (the init has ended, and so |
| +// has every process of its namespace), there is nothing to wait for. |
| +func (s *Sandbox) watch(info *os.File, bwrap int, wait time.Duration) { |
| + info.SetReadDeadline(time.Now().Add(wait)) |
| + var msg struct { |
| + ChildPID int `json:"child-pid"` |
| + } |
| + err := json.NewDecoder(io.LimitReader(info, 4096)).Decode(&msg) |
| + if err != nil || msg.ChildPID <= 1 { |
| + if errors.Is(err, os.ErrDeadlineExceeded) { |
| + // A bubblewrap that neither says nor fails: kill it. An init |
| + // it made dies with it (--die-with-parent), but cannot be |
| + // shown to have, so Wait reports ErrNotEnded. |
| + s.cmd.Process.Kill() |
| + s.mu.Lock() |
| + s.noInit = true |
| + s.mu.Unlock() |
| + } |
| + return |
| + } |
| + fd, err := unix.PidfdOpen(msg.ChildPID, 0) |
| + if err != nil { |
| + return |
| + } |
| + if parentOf(msg.ChildPID) != bwrap { |
| + unix.Close(fd) |
| + return |
| + } |
| + s.mu.Lock() |
| + s.pidfd = fd |
| + s.mu.Unlock() |
| +} |
| + |
| +// parentOf is pid's parent, from /proc, or -1. |
| +func parentOf(pid int) int { |
| + raw, err := os.ReadFile(fmt.Sprintf("/proc/%d/status", pid)) |
| + if err != nil { |
| + return -1 |
| + } |
| + for _, line := range strings.Split(string(raw), "\n") { |
| + if v, ok := strings.CutPrefix(line, "PPid:"); ok { |
| + if n, err := strconv.Atoi(strings.TrimSpace(v)); err == nil { |
| + return n |
| + } |
| + } |
| + } |
| + return -1 |
| +} |
| + |
| +// kill kills the sandbox: its PID namespace's init (the kernel then kills |
| +// every other process in the namespace) and bubblewrap. |
| +func (s *Sandbox) kill() { |
| + s.mu.Lock() |
| + if s.pidfd >= 0 { |
| + unix.PidfdSendSignal(s.pidfd, unix.SIGKILL, nil, 0) |
| + } |
| + s.mu.Unlock() |
| + s.cmd.Process.Kill() |
| +} |
| + |
| +// awaitEnd waits, once bubblewrap has been reaped, for the namespace's |
| +// init to have exited. The init's exit completes only after the kernel |
| +// has killed and reaped every other process in its PID namespace, so |
| +// once its pidfd is readable nothing of the sandbox runs. Past endBound |
| +// it is killed again and given one more endBound; then it is reported. |
| +func (s *Sandbox) awaitEnd() error { |
| + s.mu.Lock() |
| + fd, noInit := s.pidfd, s.noInit |
| + s.mu.Unlock() |
| + if noInit { |
| + return ErrNotEnded |
| + } |
| + if fd < 0 { |
| + return nil |
| + } |
| + defer func() { |
| + s.mu.Lock() |
| + unix.Close(s.pidfd) |
| + s.pidfd = -1 |
| + s.mu.Unlock() |
| + }() |
| + for try := 0; try < 2; try++ { |
| + if pidfdReadable(fd, endBound) { |
| + return nil |
| + } |
| + unix.PidfdSendSignal(fd, unix.SIGKILL, nil, 0) |
| + } |
| + return ErrNotEnded |
| +} |
| + |
| +// pidfdReadable waits up to d for a pidfd's process to exit. |
| +func pidfdReadable(fd int, d time.Duration) bool { |
| + deadline := time.Now().Add(d) |
| + for { |
| + left := time.Until(deadline) |
| + if left < 0 { |
| + left = 0 |
| + } |
| + n, err := unix.Poll([]unix.PollFd{{Fd: int32(fd), Events: unix.POLLIN}}, int(left/time.Millisecond)+1) |
| + if err == nil && n > 0 { |
| + return true |
| + } |
| + if err != nil && !errors.Is(err, unix.EINTR) || time.Now().After(deadline) { |
| + return false |
| + } |
| + } |
| +} |
| + |
| // readStatus reads render-sandbox's status lines: at most 8, each at most |
| // 1 KiB of JSON. The first ready or failed goes to s.ready; an exit is |
| // how the browser ended. Anything else ends the reading. |
| @@ -256,65 +411,6 @@ func (s *Sandbox) readStatus(r *os.File, done chan<- struct{}) { |
| } |
| } |
| -// closeOnExecFrom marks every descriptor from first up close-on-exec. |
| -func closeOnExecFrom(first int) error { |
| - if unix.CloseRange(uint(first), math.MaxUint32, unix.CLOSE_RANGE_CLOEXEC) == nil { |
| - return nil |
| - } |
| - // Kernels before 5.11: one at a time. |
| - return closeOnExecEach(first) |
| -} |
| - |
| -// closeOnExecEach is closeOnExecFrom by /proc/self/fd, one descriptor at |
| -// a time. |
| -func closeOnExecEach(first int) error { |
| - d, err := os.Open("/proc/self/fd") |
| - if err != nil { |
| - return err |
| - } |
| - defer d.Close() |
| - names, err := d.Readdirnames(-1) |
| - if err != nil { |
| - return err |
| - } |
| - for _, name := range names { |
| - n, err := strconv.Atoi(name) |
| - if err != nil || n < first { |
| - continue |
| - } |
| - if _, err = unix.FcntlInt(uintptr(n), unix.F_SETFD, unix.FD_CLOEXEC); err != nil && !errors.Is(err, unix.EBADF) { |
| - return err |
| - } |
| - } |
| - return nil |
| -} |
| - |
| -// pinTree opens the verified tree's usr and etc/fonts with no symlink |
| -// followed and nothing outside the tree reached: these descriptors, not |
| -// paths, are what bubblewrap binds. |
| -func pinTree(tree string) (usr, fonts *os.File, err error) { |
| - root, err := unix.Openat2(unix.AT_FDCWD, tree, &unix.OpenHow{Flags: unix.O_PATH | unix.O_DIRECTORY | unix.O_CLOEXEC, Resolve: unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_MAGICLINKS}) |
| - if err != nil { |
| - return nil, nil, fmt.Errorf("render: renderer tree: %w", err) |
| - } |
| - defer unix.Close(root) |
| - open := func(rel string) (*os.File, error) { |
| - fd, err := unix.Openat2(root, rel, &unix.OpenHow{Flags: unix.O_PATH | unix.O_DIRECTORY | unix.O_CLOEXEC, Resolve: unix.RESOLVE_BENEATH | unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_MAGICLINKS}) |
| - if err != nil { |
| - return nil, fmt.Errorf("render: renderer tree %s: %w", rel, err) |
| - } |
| - return os.NewFile(uintptr(fd), filepath.Join(tree, rel)), nil |
| - } |
| - if usr, err = open("usr"); err != nil { |
| - return nil, nil, err |
| - } |
| - if fonts, err = open("etc/fonts"); err != nil { |
| - usr.Close() |
| - return nil, nil, err |
| - } |
| - return usr, fonts, nil |
| -} |
| - |
| // pinDir opens dir with no symlink anywhere in its path and checks it is |
| // a directory this user owns that nobody else can write. |
| func pinDir(dir string) (*os.File, unix.Stat_t, error) { |
diff --git a/internal/runner/render/launch_linux_test.go b/internal/runner/render/launch_linux_test.go| index 92d23a76..684b1e34 100644 |
| --- a/internal/runner/render/launch_linux_test.go |
| +++ b/internal/runner/render/launch_linux_test.go |
| @@ -67,6 +67,9 @@ func tempDir(t *testing.T) string { |
| if err != nil { |
| t.Fatal(err) |
| } |
| + // t.TempDir's mode follows the umask; the tree's directory must not |
| + // be group writable. |
| + must(t, os.Chmod(dir, 0o700)) |
| return dir |
| } |
| @@ -76,6 +79,12 @@ func tempDir(t *testing.T) string { |
| func testTree(t *testing.T, browser string) (dir, pin string) { |
| t.Helper() |
| dir = filepath.Join(tempDir(t), "tree") |
| + return dir, writeTree(t, dir, browser) |
| +} |
| + |
| +// writeTree writes testTree's tree at dir and returns its pin. |
| +func writeTree(t *testing.T, dir, browser string) (pin string) { |
| + t.Helper() |
| entries := []string{"dir etc", "dir etc/fonts", "dir usr", "dir usr/lib", "dir usr/lib/chromium"} |
| must(t, os.Mkdir(dir, 0o755)) |
| for _, e := range entries { |
| @@ -96,7 +105,7 @@ func testTree(t *testing.T, browser string) (dir, pin string) { |
| if err := release.VerifyRenderer(dir, pin); err != nil { |
| t.Fatalf("test tree: %v", err) |
| } |
| - return dir, pin |
| + return pin |
| } |
| func testSite(t *testing.T) string { |
| @@ -163,7 +172,7 @@ func runProbe(t *testing.T, cfg LaunchConfig, args ...string) probeReport { |
| // host but the descriptors it binds, and the environment cleared. |
| func TestBwrapArgs(t *testing.T) { |
| want := "--unshare-all --unshare-user --die-with-parent --new-session --clearenv --cap-drop ALL" + |
| - " --ro-bind-fd 6 /usr --symlink usr/lib /lib --symlink usr/lib64 /lib64 --symlink usr/bin /bin" + |
| + " --info-fd 11 --ro-bind-fd 6 /usr --symlink usr/lib /lib --symlink usr/lib64 /lib64 --symlink usr/bin /bin" + |
| " --ro-bind-fd 7 /etc/fonts --ro-bind-fd 8 /runner --ro-bind-fd 9 /site --bind-fd 10 /out" + |
| " --tmpfs /tmp --proc /proc --dev /dev --remount-ro / --chdir / -- /runner render-sandbox" |
| got := bwrapArgs(Subcommand) |
| @@ -437,7 +446,7 @@ func TestCloseKillsTheSandbox(t *testing.T) { |
| if reply, err := bufio.NewReader(s.FromBrowser).ReadString(0); err != nil || reply != "hanging\x00" { |
| t.Fatalf("hang: %q %v", reply, err) |
| } |
| - inside := descendants(s.pid) |
| + inside := descendants(s.cmd.Process.Pid) |
| if len(inside) < 2 { |
| t.Fatalf("processes in the sandbox: %v", inside) |
| } |
| @@ -451,8 +460,8 @@ func TestCloseKillsTheSandbox(t *testing.T) { |
| go func() { s.Close(); close(done) }() |
| select { |
| case <-done: |
| - case <-time.After(20 * time.Second): |
| - t.Fatal("Close did not end the sandbox") |
| + case <-time.After(5 * time.Second): |
| + t.Fatal("Close did not end the sandbox promptly") |
| } |
| if _, err = s.Wait(); err == nil { |
| t.Fatal("a killed sandbox reported success") |
| @@ -597,28 +606,189 @@ func TestReadStatus(t *testing.T) { |
| } |
| } |
| -// Both ways of marking descriptors close-on-exec leave an inheritable |
| -// descriptor close-on-exec and open. |
| -func TestCloseOnExec(t *testing.T) { |
| - for name, mark := range map[string]func(int) error{"close_range": closeOnExecFrom, "each": closeOnExecEach} { |
| - f, err := os.Open(os.DevNull) |
| +// render-sandbox's first step leaves exactly 0 to 5 open, 3 to 5 |
| +// close-on-exec, whatever else it was started with; the /proc fallback |
| +// closes as close_range does. |
| +func TestSandboxDescriptors(t *testing.T) { |
| + self, err := os.Executable() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, mode := range []string{"", "each"} { |
| + var extra []*os.File |
| + for i := 0; i < 5; i++ { |
| + f, err := os.Open(os.DevNull) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer f.Close() |
| + extra = append(extra, f) |
| + } |
| + cmd := exec.Command(self, "render-fds") |
| + if mode != "" { |
| + cmd.Args = append(cmd.Args, mode) |
| + } |
| + cmd.ExtraFiles = extra |
| + out, err := cmd.Output() |
| if err != nil { |
| - t.Fatal(err) |
| + t.Fatalf("%q: %v", mode, err) |
| } |
| - fd, err := unix.FcntlInt(f.Fd(), unix.F_DUPFD, 20) |
| - f.Close() |
| + var r fdsReport |
| + if err = json.Unmarshal(out, &r); err != nil { |
| + t.Fatalf("%q: %v: %s", mode, err, out) |
| + } |
| + if r.Err != "" || !slices.Equal(r.FDs, []int{0, 1, 2, 3, 4, 5}) { |
| + t.Errorf("%q: %+v", mode, r) |
| + } |
| + if mode == "" && (!r.CloExec[3] || !r.CloExec[4] || !r.CloExec[5]) { |
| + t.Errorf("not close-on-exec: %+v", r) |
| + } |
| + } |
| +} |
| + |
| +// A descriptor another goroutine opens without close-on-exec just before |
| +// the launcher forks is inherited by the process the launcher starts, |
| +// and never reaches bubblewrap or the sandbox: render-exec closes it. |
| +func TestSandboxSeesNothingOpenedAtFork(t *testing.T) { |
| + cfg := testConfig(t, false) |
| + var leaked int = -1 |
| + testBeforeFork = func() { |
| + f, err := os.Open(os.DevNull) |
| if err != nil { |
| - t.Fatal(err) |
| + return |
| } |
| - if err = mark(3); err != nil { |
| - t.Fatalf("%s: %v", name, err) |
| + leaked, _ = unix.FcntlInt(f.Fd(), unix.F_DUPFD, 30) |
| + f.Close() |
| + } |
| + defer func() { testBeforeFork = nil }() |
| + r := runProbe(t, cfg) |
| + if leaked < 30 { |
| + t.Fatalf("the test's descriptor: %d", leaked) |
| + } |
| + defer unix.Close(leaked) |
| + if flags, err := unix.FcntlInt(uintptr(leaked), unix.F_GETFD, 0); err != nil || flags&unix.FD_CLOEXEC != 0 { |
| + t.Fatalf("the test's descriptor is not inheritable: %d %v", flags, err) |
| + } |
| + if want := []int{0, 1, 2, fdBrowserIn, fdBrowserOut, fdStatus}; !slices.Equal(r.FDs, want) { |
| + t.Fatalf("descriptors inside %v, want %v (opened at fork: %d)", r.FDs, want, leaked) |
| + } |
| +} |
| + |
| +// The tree mounted is the tree verified: replacing the tree, its usr, |
| +// its etc or its etc/fonts between the verification and the mount is |
| +// refused, and nothing runs. |
| +func TestLaunchRefusesATreeReplacedAfterVerification(t *testing.T) { |
| + for _, part := range []string{"", "usr", "etc", "etc/fonts"} { |
| + t.Run("replace "+part, func(t *testing.T) { |
| + cfg := testConfig(t, false) |
| + testAfterVerify = func() { |
| + p := filepath.Join(cfg.Tree, part) |
| + must(t, os.Rename(p, p+".verified")) |
| + // The impostor: a copy of the tree layout, with a socket |
| + // and an unverified browser in reach. |
| + must(t, os.MkdirAll(filepath.Join(p, "lib/chromium"), 0o755), os.MkdirAll(filepath.Join(p, "fonts"), 0o755), os.MkdirAll(filepath.Join(p, "usr"), 0o755), os.MkdirAll(filepath.Join(p, "etc/fonts"), 0o755)) |
| + must(t, os.WriteFile(filepath.Join(p, "lib/chromium/chromium-headless-shell"), []byte("#!/bin/sh\n"), 0o755)) |
| + } |
| + defer func() { testAfterVerify = nil }() |
| + _, err := Launch(context.Background(), cfg) |
| + var re *release.RendererError |
| + if !errors.As(err, &re) || re.Health != wire.ToolMismatch || !strings.Contains(re.Reason, "changed while it was verified") { |
| + t.Fatalf("Launch: %v", err) |
| + } |
| + if names, _ := os.ReadDir(cfg.Out); len(names) != 0 { |
| + t.Fatalf("something ran: %v", names) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// The tree is verified through the descriptor of its directory that the |
| +// launch holds, not its path: with an ancestor renamed during the |
| +// verification and a good tree put at the old path, the tree checked is |
| +// still the one that will be mounted (here a tampered one), and it is |
| +// refused. |
| +func TestLaunchVerifiesTheTreeItMounts(t *testing.T) { |
| + cfg := testConfig(t, false) |
| + g := filepath.Join(tempDir(t), "g") |
| + must(t, os.MkdirAll(filepath.Join(g, "p"), 0o700)) |
| + cfg.Tree = filepath.Join(g, "p", "tree") |
| + writeTree(t, cfg.Tree, "") |
| + testBeforeVerify = func() { |
| + must(t, os.WriteFile(filepath.Join(cfg.Tree, "usr", "lib", "extra"), []byte("x"), 0o644)) |
| + must(t, os.Rename(g, g+".moved")) |
| + must(t, os.MkdirAll(filepath.Join(g, "p"), 0o700)) |
| + writeTree(t, cfg.Tree, "") |
| + } |
| + defer func() { testBeforeVerify = nil }() |
| + s, err := Launch(context.Background(), cfg) |
| + if err == nil { |
| + s.Close() |
| + } |
| + var re *release.RendererError |
| + if !errors.As(err, &re) || re.Health != wire.ToolMismatch || re.Path != "usr/lib/extra" { |
| + t.Fatalf("Launch: %v", err) |
| + } |
| +} |
| + |
| +// The tree's directory must be this user's or root's and nobody else's |
| +// to write: otherwise another user could swap the tree. |
| +func TestLaunchRefusesATreeOthersCanMove(t *testing.T) { |
| + cfg := testConfig(t, false) |
| + must(t, os.Chmod(filepath.Dir(cfg.Tree), 0o777)) |
| + _, err := Launch(context.Background(), cfg) |
| + var re *release.RendererError |
| + if !errors.As(err, &re) || re.Health != wire.ToolMismatch || !strings.Contains(re.Reason, "another user") { |
| + t.Fatalf("Launch: %v", err) |
| + } |
| +} |
| + |
| +// When Close returns, every process of the sandbox has ended, even one |
| +// that left all the sandbox's pipes, started its own session and kept |
| +// writing to /out. Three rounds: a Close that does not wait returns while |
| +// that writer still runs in most rounds, not all. |
| +func TestCloseReturnsOnlyWhenEverythingEnded(t *testing.T) { |
| + for round := 0; round < 3; round++ { |
| + closeAWriter(t) |
| + } |
| +} |
| + |
| +func closeAWriter(t *testing.T) { |
| + t.Helper() |
| + cfg := testConfig(t, true) |
| + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) |
| + defer cancel() |
| + s, err := Launch(ctx, cfg) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + s.ToBrowser.WriteString("spawn\x00") |
| + if reply, err := bufio.NewReader(s.FromBrowser).ReadString(0); err != nil || reply != "spawned\x00" { |
| + t.Fatalf("spawn: %q %v", reply, err) |
| + } |
| + inside := descendants(s.cmd.Process.Pid) |
| + t.Cleanup(func() { |
| + for _, n := range inside { |
| + unix.Kill(n, unix.SIGKILL) |
| } |
| - flags, err := unix.FcntlInt(uintptr(fd), unix.F_GETFD, 0) |
| - unix.Close(fd) |
| - if err != nil || flags&unix.FD_CLOEXEC == 0 { |
| - t.Errorf("%s: flags %d, %v", name, flags, err) |
| + }) |
| + if err = s.Close(); err != nil { |
| + t.Fatalf("Close: %v", err) |
| + } |
| + ticks := filepath.Join(cfg.Out, "ticks") |
| + before, err := os.Stat(ticks) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, n := range inside { |
| + if alive(n) { |
| + raw, _ := os.ReadFile(filepath.Join("/proc", strconv.Itoa(n), "status")) |
| + t.Fatalf("process %d still runs after Close: %.120s", n, raw) |
| } |
| } |
| + time.Sleep(100 * time.Millisecond) |
| + if after, err := os.Stat(ticks); err != nil || after.Size() != before.Size() { |
| + t.Fatalf("/out was still written after Close: %d then %v %v", before.Size(), after, err) |
| + } |
| } |
| // The real browser, from a tree scripts/build-renderer-tree.py kept |
| @@ -675,7 +845,7 @@ func TestLaunchRealBrowser(t *testing.T) { |
| // Chromium's own sandbox is on: a renderer below bubblewrap runs |
| // under its seccomp filter with no new privileges. |
| deadline := time.Now().Add(10 * time.Second) |
| - for !sandboxedRenderer(s.pid) { |
| + for !sandboxedRenderer(s.cmd.Process.Pid) { |
| if time.Now().After(deadline) { |
| t.Fatal("no renderer under Chromium's own sandbox") |
| } |
diff --git a/internal/runner/render/launch_other.go b/internal/runner/render/launch_other.go| index 57f91822..7cdf5fcc 100644 |
| --- a/internal/runner/render/launch_other.go |
| +++ b/internal/runner/render/launch_other.go |
| @@ -15,5 +15,8 @@ func Launch(context.Context, LaunchConfig) (*Sandbox, error) { |
| return nil, &release.RendererError{Health: wire.ToolMissing, Reason: "the renderer runs only on Linux"} |
| } |
| +// ExecMain is Linux's alone. |
| +func ExecMain([]string) int { return 2 } |
| + |
| // SandboxMain is Linux's alone. |
| func SandboxMain([]string, io.Writer) int { return 2 } |
diff --git a/internal/runner/render/render.go b/internal/runner/render/render.go| index 5f5fa75e..5dccb85a 100644 |
| --- a/internal/runner/render/render.go |
| +++ b/internal/runner/render/render.go |
| @@ -11,8 +11,10 @@ package render |
| import ( |
| "bytes" |
| + "errors" |
| "io" |
| "os" |
| + "os/exec" |
| "sync" |
| "time" |
| ) |
| @@ -21,6 +23,10 @@ import ( |
| // process. |
| const Subcommand = "render-sandbox" |
| +// ExecSubcommand is the runner's subcommand that the launcher starts: it |
| +// closes every descriptor it should not have and executes bubblewrap. |
| +const ExecSubcommand = "render-exec" |
| + |
| // Paths inside the sandbox. |
| const ( |
| // BrowserPath is the pinned tree's program (renderer.json "program"), |
| @@ -110,14 +116,20 @@ type Sandbox struct { |
| FromBrowser *os.File |
| done chan struct{} |
| - err error |
| stop func() |
| - pid int |
| ready chan status |
| stderr *bounded |
| - |
| - mu sync.Mutex |
| - exit BrowserExit |
| + cmd *exec.Cmd |
| + |
| + mu sync.Mutex |
| + // pidfd is the sandbox's PID namespace init, or -1; noInit is an init |
| + // that may exist but could not be watched. |
| + pidfd int |
| + noInit bool |
| + exit BrowserExit |
| + // err is bubblewrap's; ended is ErrNotEnded or nil. |
| + err error |
| + ended error |
| } |
| // BrowserExit is how the browser ended, as render-sandbox saw it. Known |
| @@ -142,28 +154,32 @@ type status struct { |
| // Reasons in a "failed" status. |
| const ( |
| - reasonDescriptors = "descriptors" |
| - reasonSite = "site" |
| - reasonBrowser = "browser" |
| + reasonSite = "site" |
| + reasonBrowser = "browser" |
| ) |
| -// Wait waits for the sandbox to end and returns how the browser ended. |
| -// The error is bubblewrap's (killed, or a non-zero exit), or nil. |
| +// Wait waits until every process of the sandbox has ended and returns |
| +// how the browser ended. The error is bubblewrap's (killed, or a |
| +// non-zero exit), joined with ErrNotEnded when the end of the sandbox's |
| +// processes could not be established; then some may still run. |
| func (s *Sandbox) Wait() (BrowserExit, error) { |
| <-s.done |
| s.mu.Lock() |
| defer s.mu.Unlock() |
| - return s.exit, s.err |
| + return s.exit, errors.Join(s.err, s.ended) |
| } |
| -// Close kills the sandbox, everything in it, waits for it to end and |
| -// closes this side of the browser's pipe. |
| +// Close kills the sandbox and everything in it, waits until every one of |
| +// its processes has ended and closes this side of the browser's pipe. It |
| +// returns ErrNotEnded when that end could not be established. |
| func (s *Sandbox) Close() error { |
| s.stop() |
| <-s.done |
| s.ToBrowser.Close() |
| s.FromBrowser.Close() |
| - return nil |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + return s.ended |
| } |
| // bounded keeps the first max bytes written to it. |
diff --git a/internal/runner/render/sandbox_linux.go b/internal/runner/render/sandbox_linux.go| index a660079b..73b407fa 100644 |
| --- a/internal/runner/render/sandbox_linux.go |
| +++ b/internal/runner/render/sandbox_linux.go |
| @@ -25,27 +25,23 @@ import ( |
| // empty), reports ready with the site's address, then the browser's exit, |
| // and ends. It takes no arguments and reads nothing else from the host. |
| // Exit 0 is a browser that started and ended; 1 a failure it reported; 2 |
| -// a launch that was not the runner's. |
| +// a launch that was not the runner's (arguments, or descriptors 3 to 5). |
| func SandboxMain(args []string, stderr io.Writer) int { |
| if len(args) != 0 { |
| return 2 |
| } |
| - for _, fd := range []int{fdBrowserIn, fdBrowserOut, fdStatus} { |
| - if _, err := unix.FcntlInt(uintptr(fd), unix.F_GETFD, 0); err != nil { |
| - return 2 |
| - } |
| + // Only 0, 1, 2, the browser's pipe and the status pipe stay open, |
| + // all close-on-exec: the browser gets 0, 1, 2 and its pipe |
| + // (ExtraFiles) and nothing else, not the status pipe or the server's |
| + // socket. |
| + if sandboxDescriptors() != nil { |
| + return 2 |
| } |
| statusPipe := os.NewFile(fdStatus, "status") |
| report := func(st status) { |
| b, _ := json.Marshal(st) |
| statusPipe.Write(append(b, '\n')) |
| } |
| - // The browser gets 0, 1, 2 and its pipe (ExtraFiles) and nothing |
| - // else: not the status pipe, not the server's socket. |
| - if err := closeOnExecFrom(3); err != nil { |
| - report(status{Event: "failed", Reason: reasonDescriptors}) |
| - return 1 |
| - } |
| server, site, err := serveSite() |
| if err != nil { |
| fmt.Fprintf(stderr, "render-sandbox: site: %v\n", err) |
diff --git a/internal/runner/render/tree_linux.go b/internal/runner/render/tree_linux.go| new file mode 100644 |
| index 00000000..0e3bf60d |
| --- /dev/null |
| +++ b/internal/runner/render/tree_linux.go |
| @@ -0,0 +1,148 @@ |
| +//go:build linux |
| + |
| +package render |
| + |
| +import ( |
| + "errors" |
| + "fmt" |
| + "os" |
| + "path/filepath" |
| + |
| + "golang.org/x/sys/unix" |
| + |
| + "amadan.net/oficina/equipo/internal/release" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// testBeforeVerify and testAfterVerify, when set, run just before the |
| +// tree's verification and between it and the check that the opened |
| +// objects are still the tree (tests move or replace things there). |
| +var testBeforeVerify, testAfterVerify func() |
| + |
| +// verifiedTree verifies the renderer tree against pin and returns the |
| +// tree's usr and etc/fonts, opened before the verification, as the |
| +// descriptors bubblewrap binds. |
| +// |
| +// Threat model: this user and root are trusted, as VerifyRenderer says; |
| +// nobody else may be able to change what is mounted. Everything is |
| +// reached from one descriptor of the tree's parent, opened with no |
| +// symlink followed: the parent must be owned by this user or root and |
| +// writable by nobody else, so nobody else can rename the tree or put |
| +// another in its place, and the ancestors above it no longer matter. |
| +// VerifyRenderer checks the tree through that same descriptor |
| +// (/proc/self/fd/<parent>/<name>) and that nobody else can write any of |
| +// it. Afterwards the tree, usr and etc/fonts are opened again from the |
| +// parent and must be the very objects opened before (the same device |
| +// and file number), so a replacement at any point between the first |
| +// open and the mount is refused. A replacement that is put back before the second open is |
| +// only possible for this user or root, and is out of scope. |
| +func verifiedTree(tree, pin string) (usr, fonts *os.File, err error) { |
| + if !pinShaped(pin) { |
| + return nil, nil, &release.RendererError{Health: wire.ToolUnpinned, Reason: "no renderer pin is linked into this runner"} |
| + } |
| + parent, name := filepath.Dir(tree), filepath.Base(tree) |
| + if name == "/" || name == "." || name == ".." { |
| + return nil, nil, mismatch("", "%q names no tree", tree) |
| + } |
| + pfd, err := openDir(unix.AT_FDCWD, parent, unix.RESOLVE_NO_SYMLINKS|unix.RESOLVE_NO_MAGICLINKS) |
| + if errors.Is(err, unix.ENOENT) { |
| + return nil, nil, &release.RendererError{Health: wire.ToolMissing, Reason: parent + " does not exist"} |
| + } |
| + if err != nil { |
| + return nil, nil, mismatch("", "%s: %v", parent, err) |
| + } |
| + defer unix.Close(pfd) |
| + var st unix.Stat_t |
| + if err = unix.Fstat(pfd, &st); err != nil || st.Mode&0o022 != 0 || st.Uid != uint32(os.Geteuid()) && st.Uid != 0 { |
| + return nil, nil, mismatch("", "%s, the tree's directory, can be written by another user", parent) |
| + } |
| + before, absent, err := openTreeParts(pfd, name) |
| + if absent { |
| + return nil, nil, &release.RendererError{Health: wire.ToolMissing, Reason: tree + " does not exist"} |
| + } |
| + if err != nil { |
| + return nil, nil, mismatch("", "%s: %v", tree, err) |
| + } |
| + keep := false |
| + defer func() { |
| + if !keep { |
| + closeFDs(before) |
| + } |
| + }() |
| + if testBeforeVerify != nil { |
| + testBeforeVerify() |
| + } |
| + if err = release.VerifyRenderer(fmt.Sprintf("/proc/self/fd/%d/%s", pfd, name), pin); err != nil { |
| + return nil, nil, err |
| + } |
| + if testAfterVerify != nil { |
| + testAfterVerify() |
| + } |
| + after, _, err := openTreeParts(pfd, name) |
| + defer closeFDs(after) |
| + if err != nil { |
| + return nil, nil, mismatch("", "the tree changed while it was verified: %v", err) |
| + } |
| + for i, part := range []string{"", "usr", "etc/fonts"} { |
| + if !sameObject(before[i], after[i]) { |
| + return nil, nil, mismatch(part, "the tree changed while it was verified") |
| + } |
| + } |
| + unix.Close(before[0]) |
| + keep = true |
| + return os.NewFile(uintptr(before[1]), filepath.Join(tree, "usr")), os.NewFile(uintptr(before[2]), filepath.Join(tree, "etc/fonts")), nil |
| +} |
| + |
| +// openTreeParts opens the tree (name, below the parent pfd), its usr and |
| +// its etc/fonts, in that order. On an error none is left open, and |
| +// absent says the tree itself does not exist. |
| +func openTreeParts(pfd int, name string) (fds [3]int, absent bool, err error) { |
| + fds = [3]int{-1, -1, -1} |
| + const resolve = unix.RESOLVE_BENEATH | unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_MAGICLINKS |
| + if fds[0], err = openDir(pfd, name, resolve); err != nil { |
| + return [3]int{-1, -1, -1}, errors.Is(err, unix.ENOENT), err |
| + } |
| + for i, rel := range []string{"usr", "etc/fonts"} { |
| + if fds[i+1], err = openDir(fds[0], rel, resolve); err != nil { |
| + fds[i+1] = -1 |
| + closeFDs(fds) |
| + return [3]int{-1, -1, -1}, false, fmt.Errorf("%s: %w", rel, err) |
| + } |
| + } |
| + return fds, false, nil |
| +} |
| + |
| +func openDir(at int, path string, resolve uint64) (int, error) { |
| + return unix.Openat2(at, path, &unix.OpenHow{Flags: unix.O_PATH | unix.O_DIRECTORY | unix.O_CLOEXEC, Resolve: resolve}) |
| +} |
| + |
| +func closeFDs(fds [3]int) { |
| + for _, fd := range fds { |
| + if fd >= 0 { |
| + unix.Close(fd) |
| + } |
| + } |
| +} |
| + |
| +// sameObject is two descriptors of the same file. |
| +func sameObject(a, b int) bool { |
| + var x, y unix.Stat_t |
| + return a >= 0 && b >= 0 && unix.Fstat(a, &x) == nil && unix.Fstat(b, &y) == nil && x.Dev == y.Dev && x.Ino == y.Ino |
| +} |
| + |
| +// pinShaped is a SHA-256 in lower-case hex, as release.RendererPin gives. |
| +func pinShaped(pin string) bool { |
| + if len(pin) != 64 { |
| + return false |
| + } |
| + for _, c := range pin { |
| + if (c < '0' || c > '9') && (c < 'a' || c > 'f') { |
| + return false |
| + } |
| + } |
| + return true |
| +} |
| + |
| +func mismatch(path, format string, args ...any) error { |
| + return &release.RendererError{Health: wire.ToolMismatch, Path: path, Reason: fmt.Sprintf(format, args...)} |
| +} |