#102 write the downgrade record before the failure sentinel - #133
Merged
matthewdevenny merged 1 commit intoSep 17, 2026
Merged
matthewdevenny merged 1 commit into
matthewdevenny merged 1 commit into
Conversation
Signed-off-by: Brian Joiner <brinkercode@gmail.com>
brinkercode
marked this pull request as ready for review
September 17, 2026 03:04
matthewdevenny
self-requested a review
September 17, 2026 15:10
Contributor
Author
|
Thanks for the merge! Happy to take on more low-level bugs or enhancements whenever you've got them. I can also open that verifier issue if it's useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Under
--api-failure-mode=fail,handlePolicyFetchFailurepublished the failure sentinel before the downgrade record. The action classifies a sentinel as lockdown from that record, so a reader between the two writes saw a lockdown with no record and treated it as a generic startup crash. With the defaultfail-on-unsupported: false, that restored resolv.conf under a live lockdown and passed the step. The record is now written first and the sentinel last.Changes
cmd/start.go:writeDowngradeFileruns beforewriteFailureSentinelin the lockdown branch. TheSEMANTICScomment is unchanged; a newORDERcomment records why the sequence matters.writeDowngradeFilestays best-effort, so a failed record write still leaves the sentinel written.cmd/start_test.go:TestLoadCIConfig_LockdownPublishesSentinelLast.Why this shape
The sentinel is what consumers poll for, so it should be the commit of the state: published only once everything describing that state exists. That fixes the race at the source instead of leaning on the settle delay and sentinel-text fallback from code-cargo/cargowall-action#73, which can stay as a second line of defense.
The test points
downgradeFileandFailureFileat the same path. Both writes atomically replace it, so whichever lands last is what remains, and the test asserts that is the sentinel (pid=). That checks the order deterministically, without a goroutine racing two writes that land microseconds apart.Test plan
main(750c22f)TestLoadCIConfig_LockdownPublishesSentinelLastgo test ./...go test -race ./cmd/Root BPF tests (Multipass VMs, one package per run):
pkg/tc,pkg/network,pkg/stepspass on 5.15, 6.8 and 7.0.bpfandpkg/originpass on 6.8 apart from the known VM-kernelTestTcEgress/Truncated_IP{,v6}_headerEINVALs. This change touches onlycmd, which none of those packages import.Related
Closes #102. Raised as item 1 of the post-merge review on code-cargo/cargowall-action#72; mitigated action-side in code-cargo/cargowall-action#73.
Out of scope
cg_origin_egressexceeds the verifier's 1M-instruction limit on stock 5.15 and 7.0 kernels (reproduced at #106 container attribution + cgroup egress enforcement (phases 3a+3b) #109 and onmain, including a real runner job on 7.0), sobpf/pkg/originfail there and the cgroup hook falls back to TC-only. The budget in Add L7 sni verification #118 /design-l7.mdis measured on CI's 6.17-azure, so this sits outside that measurement. Unrelated to this change; happy to open an issue with the kernel matrix.