carlos / platform Public
- P1 — Restore can still block indefinitely on a FIFO. restore.go:22 After
realParentschecks a child directory, a tenant can rename it aside and replace it with a FIFO beforesyncDircallsroot.Open. That open has neitherO_DIRECTORYnorO_NONBLOCK, so it waits indefinitely without a writer. The install holds the host guard during this operation; cancellation does not interrupt the open. This is an inherited defect still reached through the newRestoreRootcall. Use a descriptor-relative directory open that cannot block, and test the replacement at the existingsyncDirseam.
- P2 — The absence check still confuses a vanished directory with a missing file. relocationflush.go:184, also present.go:63
StatDircloses its descriptor before the subsequent read reopens the directory. If the directory disappears between those operations,ReadBeneathLimitreturnsENOENTfrom opening the directory, andreadInstanceFilereportsabsent=true. A transient rename followed by restoration can therefore let a flush commit deletion of an existing env or adoption item.Presentrepeats this pattern and can incorrectly accept absence. Keep one directory descriptor and recognize absence only from the file lookup beneath it.
Verdict: request changes. The root-opening fix is sound, but the requested protection against blocking and check/use races is incomplete.
The other conclusions from the brief:
OpenRootBeneathkeeps the original descriptor open untilos.OpenRootacquires its own; renaming the pathname cannot redirect that handoff.- I found no outside-root symlink write through
RestoreRoot. Internal symlink redirection remains possible, but bounded by Go’sos.Rootconfinement. - Hard-linked destinations are replaced rather than truncated. Reads still accept hardlinks; cross-tenant protection depends on the existing isolation and migration controls.
RestoreandSyncDirretain their shared implementations and existing caller behavior. No second low-level safe-open implementation was introduced, although the flawed absence-check sequence is duplicated.
Targeted tests could not start: the read-only sandbox prevented Go from creating its build directory. Findings are from source inspection.
---
FIRST PROMPT: “Follow the review brief docs/superpowers/plans/CODEX-REVIEW-REGION-HA-TENANT-DIR-BRIEF.md. Review the diff cfb4314d..3194d674 on branch region-ha-1b-next-build.”
WHAT: Review tenant-directory safety in the requested diff.
STATUS: Review complete: one P1 and one P2; tests blocked by the sandbox.
NEEDED: Nothing for this review.
RECOMMENDED: Fix both races and add deterministic regression tests before approval.
SESSION: Safe to close. No files changed or processes left running; the read-only sandbox prevented saving a handoff file.