Skip to content

Protect fork recovery from stale writers and inherited state - #578

Merged
yummybomb merged 1 commit into
hypeship/recover-interrupted-forksfrom
hypeship/fork-recovery-guards
Nov 18, 2026
Merged

yummybomb merged 1 commit into
hypeship/recover-interrupted-forksfrom
hypeship/fork-recovery-guards

Conversation

@yummybomb

Copy link
Copy Markdown
Contributor

Targets #555. On its original head, a second manager running ListInstances could persist boot markers after completeFork and put fork_pending back on disk. Recovery could also clear another instance's PCI attachment, delete a Firecracker alias target while the source was parked, and lose the pending mark during an in-place restore.

  • Take a nonblocking lock on the data directory before startup touches instance state. A second API using the same directory exits, including through a symlink. Stop older binaries before an upgrade/downgrade: they don't take the lock.
  • Restore a uniquely identified Firecracker source backup before instance scans. If the layout is ambiguous or the alias does not match the recorded source, stop startup rather than replace a directory.
  • Release a passthrough device only for its recorded owner; check ownership and unbind under the same device-manager lock.
  • Reject in-place restore onto a pending fork. Keep the marked metadata out of the snapshot copy and write only sanitized metadata to the payload.

Verification: exercised the stale boot-marker write on the original head using two independent managers. Regression fixtures on that head exposed the PCI owner change, the inaccessible source, the accepted in-place restore and the marked file in a partially copied payload. On the fix, the focused instance tests and the short tests for cmd/api, providers, devices, forkvm and firecracker pass on Linux. The startup exclusion test uses a real second process. No physical PCI device, host power cut, or full guest integration suite was tested.

@yummybomb
yummybomb merged commit 6f0bc71 into hypeship/recover-interrupted-forks Nov 18, 2026
7 checks passed
@yummybomb
yummybomb deleted the hypeship/fork-recovery-guards branch November 18, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant