Repository navigation
fix(classifier): an nft that refuses before reading its script still reports what it said - #3289
Conversation
…reports what it said `run_nft_script` wrote the whole script to nft's stdin and returned the write's error first. An nft that exits on its first lines leaves the write in EPIPE, so the error read `Broken pipe (os error 32)` and nft's own words were lost; the unit test that drives a refusing stand-in lost that race once in 213 lab runs and once on a Lima host. The write now tolerates EPIPE and the error carries nft's stderr and exit status as before; an nft that exits 0 without reading its whole script is an error of its own, not a success. The test makes the early exit certain with a script past the pipe's buffer, and covers the exit-0 case. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 1 billable file and costs up to $0.25.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 59 minutes for your next included review. View limit details
|
|
Reviewed: no findings; approval withheld, 1 thread unresolved at APPROVE withheld: 1 unresolved thread — norrietaylor crates/minimald/src/net/classifier.rs. Resolving the last thread releases the approval on this head. Resolve the open threads. Resolving the last one releases the approval on this head; no new review is required. Clobber: none seen. |
There was a problem hiding this comment.
Scope matches the title. The change touches one function, run_nft_script, and its existing unit test. Clobber none. git log on classifier.rs shows that the recent fixes (#3240, #3187, #3179) touch other code, and the diff keeps them. Correctness The BrokenPipe arm now records unread and falls through to wait_with_output. A refusing nft still reports its stderr and exit status, and a different write error still returns at once. The new test is a true regression test. A 200 KB script is past the 64 KB pipe buffer, so write_all must hit EPIPE after the stand-in exits. Without the fix, the error is Broken pipe and the no such table assert fails. The silent case is also deterministic for the same reason. Rust ignores SIGPIPE in the test binary, so the write returns EPIPE and the process does not die. The unread check fires only when the write itself fails. A production fence script is a few hundred bytes and fits in the pipe buffer, so an nft that exits 0 without reading it still counts as a success. The code comment at 774-776 claims more than that, but nothing reaches the case. A pre-existing point that is outside this fix: write_all runs outside TABLE_LIST_DEADLINE. The sibling run_guest_child_bounded (classifier.rs:2628) bounds the write for that reason. With the current small scripts the write cannot block, so this is not a finding. Pattern: bep/src/store.rs:895 already tolerates BrokenPipe in the same way. No other nft stdin writer in the repo has the same race. Not checked: a test run, because the review rules allow no build.
|
|
||
| // An nft that refuses before reading its whole script (the write ends in EPIPE, which won the | ||
| // race over its stderr once in 213 lab runs and once on a Lima host) still reports what it said. | ||
| // A script past the pipe's buffer makes the early exit certain. |
There was a problem hiding this comment.
nit · This test comment tells the flake history of this PR ("once in 213 lab runs and once on a Lima host"). That history belongs in the commit message. Keep the part that explains the test: a script past the pipe's buffer makes nft exit before it reads the script, and the write then ends in EPIPE.
There was a problem hiding this comment.
Trimmed in 318e11e: the comment keeps the mechanism (a script past the pipe's buffer makes nft exit before it reads it, so the write ends in EPIPE) and the history is in the commit.
The comment on the early-exit case told this change's own history (where the race was seen) rather than what the test proves; the history is in the commit that added it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
run_nft_scriptwrote the whole script to nft's stdin and returned the write's error first. An nft that exits on its first lines leaves the write in EPIPE, so the error readBroken pipe (os error 32)and nft's own words (the refusal, the exit status) were lost. The unit test that drives a refusing stand-in lost that race once in 213 Linux CI-mirror runs and once on a Lima host (noted in #3256's verification as a pre-existing flake), each time ashost_ip_lookup_outside_a_steered_box_resolves_real_fence_admits_only_the_box_leaffailing onBroken pipe.The write now tolerates EPIPE and the error carries nft's stderr and exit status as before. An nft that exits 0 without reading its whole script is an error of its own (
exited 0 before reading its whole script), not a success. The test makes the early exit certain with a script past the pipe's buffer and covers the exit-0 case, so the race is no longer a race.Lab: the full CI mirror on Linux passes at this tree, and the baseline and the host_ip egress scenario hold on Ubuntu 24.04 and Fedora against the current release.
🤖 Generated with Claude Code