Repository navigation
fix: enforce --max-delete on make-room deletes and remote limits - #8218
Merged
Merged
Conversation
A client asked for --max-delete=0 forwards --max-delete=-1 (options.c:3002-3006), and upstream clamps any negative value back to 0 (options.c:2308-2311). The server parsed the value as unsigned and refused it, so every remote --max-delete=0 transfer died with exit 12 before a single file moved. Reuse the client parser, which already clamps.
cleanup.c:213-218 assigns RERR_PARTIAL last, for io_error & IOERR_GENERAL or got_xfer_error, so a transfer error outranks RERR_VANISHED and RERR_DEL_LIMIT too. The funnel consulted got_xfer_error only for an otherwise clean run, so a refused make-room that also tripped --max-delete exited 25 where rsync 3.5.1 exits 23.
delete_dir_contents() strips DEL_MAKE_ROOM before it recurses (delete.c:126), so every child of a directory cleared to make room is an ordinary capped deletion (delete.c:217), while the obstacle node itself stays exempt. A child the cap refuses leaves the directory standing, the make-room fails at FERROR_XFER, and generator.c:2904-2907 reports the skipped total. The local executor ignored the cap entirely and cleared the obstacle at exit 0. The receiver capped each obstacle from zero, dropped the skipped count, sized a --delete-after sweep without the make-room deletions, and reported the limit only on the server side. Both now share upstream's single run-wide budget and skipped_deletes, and the receiver frames the warning for the client as MSG_WARNING like rwrite() does.
11 of 13 tasks
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
--max-deletenow caps the contents of a directory cleared to make room for an incoming file, locally and on a receiver. The obstacle node itself stays exempt (delete.c:217,delete.c:126), and the make-room shares one run-wide budget and oneDeletions stoppedwarning with the delete sweeps, as upstream does.--max-delete=0no longer dies with exit 12: the server clamps the forwarded--max-delete=-1to 0 (options.c:3002-3006,options.c:2308-2311).cleanup.c:213-218.Details
upstream exempts only the make-room removal of the obstacle node (
delete.c:217,!(flags & DEL_MAKE_ROOM)).delete_dir_contents()strips that flag before it recurses (delete.c:126), so every child is an ordinary capped deletion. A child the cap refuses leaves the directory standing, the make-room fails atFERROR_XFER, andgenerator.c:2904-2907reports the run-wide skipped total.What was wrong, per commit:
--max-deleteas unsigned and rejected the-1that oc and upstream clients forward for=0. Every remote--max-delete=0transfer exited 12 before moving a file. The server now reuses the client's clamping parser.got_xfer_erroronly for an otherwise clean run, so the deletion limit (25) beat a transfer error (23). The existing assertion(IOERR_VANISHED, got_xfer_error) -> 24encoded that divergence and is corrected.Local executor: it ignored the cap. With
--max-deleteset, the peel now goes through the capped delete pass's leaf walk (remove_children_capped, extracted fromremove_entry_capped).Receiver:
--delete-aftersweep ignored make-room deletions;It now keeps one run-wide
skipped_deletes, settled once wheregenerator.c:2904does it (after the late sweep, beforetouch_up_dirs()). The warning is framed asMSG_WARNING, asrwrite()does (log.c:357-366).Measured against rsync 3.5.1 with
-rlI -vanddst/obstacle/{a,b}wheresrc/obstacleis a regular file. Each cell was run locally and over a--serverchild. Both modes now match upstream on exit code, survivors, warning anddeletingrows.--delete --max-delete=0a,b,(2 skipped)a,b,(2 skipped)--force --max-delete=0a,b,(2 skipped)a,b,(2 skipped)--delete --max-delete=1b, keepsa,(1 skipped)b, keepsa,(1 skipped)--delete --max-delete=2--delete --max-delete=0, symlink obstacle--delete --max-delete=1plus extraneouszextrazextragone, keepsa,b,(2 skipped)--delete-after --max-delete=2pluszextrazextrakept,(1 skipped)The two
zextrarows pin the shared budget in both orders: the sweep spends it first under--delete, and the make-room spends it first under--delete-after.Mutation checks: each fix site was reverted alone and the suite turned red every time.
max_delete_budget_spans_segments_and_reports_onceio_error_rule_matches_upstreamKnown gaps, not in this PR:
-vrow of a run that ends with exit 23, with or without--max-delete. So the partial-cap cell pins thedeleting obstacle/brow over the remote shell only.--one-file-systemmount points the waydelete_dir_contents()'sFLAG_MOUNT_DIRcheck does.Test plan
cargo fmt --all -- --checkandpython3 tools/ci/check_rustfmt_all.pycargo clippy -p transfer -p engine -p core -p cli -p bin --all-targets --all-features --no-deps -- -D warningscargo nextest run -p transfer -p engine -p core -p cli --all-features(15271 passed)cargo nextest run -p bin --all-features -E 'binary(make_room_max_delete)'(7 passed), plus the 16 root binaries touching delete, obstacle, max-delete and exit codes (121 passed)cargo run --locked -p xtask -- no-placeholders,cargo run --locked -p xtask -- citations,python3 tools/ci/citation_drift_audit.py --ratchet,python3 tools/ci/unsafe_owner_deps.py/usr/bin/rsync3.5.1 (protocol 33), locally and over a--rshshim, compared on exit code, surviving files and stderrCoordination
crates/core/src/exit_code/funnel.rs, which no other open PR touches.Conventional commit prefix
fix:Security considerations
--max-deleteis a data-safety control. Before this change, a make-room peel could remove an unbounded number of files despite the cap (locally, and on the receiver when earlier deletions had used up the budget).tests/make_room_max_delete.rspins the refusal, the partial cap, the exempt single-entry node and the shared budget, locally and over a remote shell, and is mutation-checked.delete.c:126,delete.c:217-218,generator.c:2904-2907,cleanup.c:213-218.Pre-merge checklist
cargo fmt --allrun locally.CHANGELOG.mdupdated if user-visible.SECURITY.mdupdated if security-relevant.