Repository navigation
fix: anchor receiver opens via held parent, local-copy delete fidelity - #8228
Merged
Merged
Conversation
Upstream's macOS build has no SUPPORT_ACL_FD (configure.ac:1512-1514), so set_rsync_acl() sets the extended ACL by path (acls.c:1315-1322) and re-walks every parent. A parent swapped for a symlink between the confined pin and that call redirects the ACL outside the destination. A confined macOS receiver now writes the ACL with acl_set_fd_np on the O_NOFOLLOW leaf fd the xattr writes already hold. A refused pin skips the ACL as upstream's xattr_refuse does; device and socket leaves keep the path-based set. Entries are encoded as sys_acl_set_info() does (lib/sysacls.c:2833-2874): allow/deny tag, the mbr_*_to_uuid qualifier, then the permission and flag sets. This is a deliberate improvement over upstream on macOS. FreeBSD keeps upstream's path-based set until a FreeBSD CI job exists to exercise an fd arm. Linux is unchanged.
The network receiver's directory, symlink, hard-link and special-file passes still stat, read, chmod and re-time destination entries by path, and create missing parents with fs::create_dir_all. A directory inside the destination swapped for a symlink after entry could steer those operations, including a mkdir chain, out of the tree. Route them through the destination sandbox the way upstream resolves every entry against the held destination (syscall.c held_dfd_for(), util1.c make_path()): - fast_io: one shared resolver (at_dest_leaf) backs the lstat, stat, metadata, chmod and utimes helpers. chmod and utimes gain the held parent and beneath-only arms, and utimes takes optional slots so an mtime repair leaves atime alone. create_dir_all_via creates missing parents one mkdirat at a time beneath the sandbox. - transfer: directory classification, pre-transfer stats, touch_up_dirs, symlink readlink, probes and make_path, hard-link leader probes, special-file probes and make_path, and the symlink itemize stat use the anchored helpers. Tests swap dest/a for a symlink to outside/ after the sandbox opens and assert nothing under outside/ is created, chmodded or re-timed.
The generator opens the exact destination basis, and the receiver reads the delta basis, beneath the held destination: held parent, single component or RESOLVE_BENEATH anchor, with O_NOFOLLOW on the leaf. The in-place output, the --write-devices target and the post-transfer truncate and hole punch reopen the destination the same way. A missing leaf under the held parent is now that directory's answer, as upstream's held descriptor gives it, instead of dropping the cache and re-resolving. upstream: receiver.c:1086-1093, receiver.c:1212-1241, syscall.c:3858
Resolve the remaining receiver-side destination operations from the pinned destination instead of by path, so a parent swapped for a symlink after resolution cannot redirect them out of the tree. - Nested directory listings open through the held parent dirfd (upstream: syscall.c:3858-3871 held_dfd_for) instead of falling back to std::fs::read_dir for any multi-component path. - The backup ladder's link and rename tiers run the ownership walk from the held destination rather than from the absolute path, as upstream walks from the receiver's chdir'ed cwd (backup.c:445 operator_path_resolve, syscall.c:1100 do_link_at, syscall.c:2026 do_rename_at). A trusted in-tree symlink at the backup dir is still followed and a foreign one refused; an absolute --backup-dir walks from / as before. The existence and regular-file probes stat beneath the destination (backup.c:236 x_lstat). - The --delete pre-delete backup probes the victim beneath the destination, so a present victim is never reported as vanished and unlinked without a backup. - Partial-dir obstruction clearing and the emptied partial-dir rmdir resolve beneath the destination (upstream: util1.c handle_partial_dir PDIR_CREATE / PDIR_DELETE), for the commit, robust_rename and delayed-update callers. - The in-place EACCES recovery arms (the protected_regular retry and the read-only recovery's probe and reopen) run through the same anchored opener as the first arm instead of falling back to the path chain (upstream: receiver.c:1212-1241), so an EACCES never hands the retry to a resolver a swapped parent could redirect.
std::fs::Metadata has no public constructor, so a destination stat answered by fstatat beneath the pinned destination cannot be handed to the metadata layer. Promote the sender's SourceMetadata to fast_io::EntryMetadata, an either/or of a std::fs::Metadata and an fstatat AtMetadata behind one MetadataExt-named accessor surface, and take it wherever the metadata apply and quick-check paths accept a destination stat. The retype is behaviour-neutral: every existing caller wraps its std::fs::Metadata in the Std variant, including the engine's local-copy callers, and no syscall changes. Windows keeps only the Std variant. A parity test stats a regular file, a directory, a symlink and a FIFO through both variants and requires mode, size, uid, gid, dev, ino, nlink, rdev, file type and the second and nanosecond fields of mtime and atime to match lstat exactly; the quick-check compares mtime to the nanosecond.
The receiver's pre-transfer destination stats went through metadata_via_sandbox_or_fallback, which opened the entry O_PATH, fstat'ed it and closed it: three syscalls where upstream's do_lstat_at() issues one fstatat (syscall.c). The O_PATH open existed only because fs::Metadata has no public constructor. With EntryMetadata in place the consumers take the fstatat answer directly: - directory creation and symlink replacement stat through dest_lstat (lstat/stat_via_sandbox_or_fallback); - the quick-check, existence-gate, itemize and up-to-date helpers take EntryMetadata, so their path-based stats wrap without a second call; - a non-directory symlink obstacle reuses the lstat already taken instead of statting it again. metadata_via_sandbox_or_fallback has no callers left and is removed.
The receiver kept two held-directory caches over the same destination: the DirSandbox's, for probes and opens, and the metadata DestinationRoot's, for attribute applies. Both resolve root-relative parents with open_dir_beneath_nofollow beneath the same pinned root, so every nested parent was opened twice. Upstream keeps a single held parent for every per-entry operation (syscall.c:3858-3871 held_dfd_for()). The receiver now opens the sandbox before the metadata root and hands it the sandbox's cache. Behaviour is unchanged; a nested parent is opened once instead of once per consumer.
0.103.15 may accept certificate paths through the distrusted emSign intermediates, whose private keys are public. oc trusts only the operator --quic-ca store or pinned certificates and loads no public roots, so exposure needs an emSign anchor in that store; bump anyway.
A source that cannot be opened while sending no longer suppresses the --delete-during and --delete-delay decisions taken during the walk, while --delete-after now sees send errors from every directory. Upstream's sender reports them only after its send loop (sender.c:811-812), so only the after pass's delete_in_dir() sees them.
A file or directory that vanishes between the walk and its send sets IOERR_VANISHED, which upstream's delete_in_dir() never tests (generator.c:304 gates on IOERR_GENERAL only), so deletions proceed at every timing. The vanish is also reported once, by the frame that sent the file, instead of again by each enclosing directory and the operand.
A local copy now prints `send_files failed to open "<path>": <error>` for every source it cannot open, and ends the run with upstream's summary: `some files/attrs were not transferred (see previous errors)` for exit 23, or `some files vanished before they could be transferred` for exit 24. Before, only the first failure was printed, folded into the final line, and every later one was lost (sender.c:708-722, log.c:98-99).
upstream's sender bumps created_files (for a new entry), xferred_files and total_transferred_size before it opens the file (sender.c:625-635), so a source that cannot be opened still counts as attempted. A local copy now does the same, so --stats on such a run matches upstream.
A local --delete that met an rmdir failure inside a doomed directory (EBUSY on a mount point without -x, say) aborted the recursive peel, so the failing entry's siblings survived, and under --max-delete it aborted the whole transfer. Nothing named the entry, and the non-empty notice printed an absolute path. The peel now records each entry it cannot remove and keeps going, the pass prints upstream's `delete_file: rmdir(<name>) failed` line for it, and the run ends RERR_PARTIAL as upstream does (delete.c:141-164, delete.c:264-266). The non-empty notice uses the transfer-relative name.
14 of 15 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
CVE-2026-53796 receiver anchoring and rustls-webpki
do_*_at()/ held-dirfd model.rustls-webpki0.103.15 -> 0.103.16 (lockfile only) for RUSTSEC-2026-0382, which turnedcargo-denyred on master and on every PR.RUSTSEC-2026-0382 (rustls-webpki)
0.103.15 may accept certificate paths through the distrusted emSign intermediates, whose private keys are public. oc's only rustls user is the QUIC transport (
rsync_io::quic). It verifies peers against the operator's--quic-castore or pinned certificates and loads no public root set (nowebpki-roots, native or platform verifier). Exposure therefore needs an emSign anchor in that store, but the patched release is semver-compatible, so bump.cargo clippy -p rsync_io --all-targets --all-featuresand the 58 QUIC tests pass on 0.103.16.Local-copy delete and error fidelity (round 2)
--delete-afterpass. Before, it also suppressed deletions the walk had already decided under--delete-duringand--delete-delay. upstream: sender errors reach the generator only after the send loop (sender.c:811-812), so onlydo_delete_passsees them, andgenerator.c:304gates onIOERR_GENERALalone.file has vanishedonce. The run ends with exit 24 and upstream's warning. upstream:IOERR_VANISHEDgates nothing (generator.c:304), andcleanup.c:215-216maps it toRERR_VANISHED.rsync: [sender] send_files failed to open "<path>": <error>. The run then ends withsome files/attrs were not transferred (see previous errors) (code 23). Before, only the first failure was printed, folded into the final line, and every later one was lost (sender.c:711-722,log.c:98-99).--stats. An unreadable source still counts as created and transferred in--stats(sender.c:625-635).--delete. A busy mount point (EBUSY) inside a doomed directory no longer aborts the recursive peel, so its siblings are still deleted.delete_file: rmdir(<name>) failed: <error>(delete.c:141-164,delete.c:264-266).--max-delete, the failure no longer aborts the whole transfer.cannot delete non-empty directorynow uses the transfer-relative name instead of an absolute path.Oracle: upstream 3.5.1 (
/usr/bin/rsync) vs this branchEvery row matches upstream on exit code, filesystem outcome and diagnostics.
--delete-during--delete-delay--delete-before--delete-after--delete/-after/-delayz/staledeleted, onefile has vanished-rand--delete-beforesub/b.txtmode 000send_files failed to open "D/src/sub/b.txt": Permission denied (13)+(code 23)summaryfailed to copy filein final line--stats, unreadable 1000-byte filea.txt5 B +sub/b.txtdst/x/m,--delete/-after/-delayx/sib,x/m/innersib+innerdeleted,xkept,rmdir(x/m) failed: Device or resource busy (16), stdoutcannot delete non-empty directory: xsibkept, normdirline, absolute path in notice--max-delete=10anot copied)Known remaining difference, out of scope: a local copy's
Total bytes sent/receivedreports bytes copied rather than upstream's wire bytes. Local copies have no wire model.Details
What is anchored (each step goes through the held parent dirfd of the destination directory):
fix: apply macOS ACLs through the pinned destination fdfix: anchor receiver directory, link and special probesreceiver/directory/*,itemize.rs)fix: anchor receiver basis and destination opensfix: anchor receiver backup, listing and partial-dir cleanup--backuprenames, delete listing,--partial-dircleanuprefactor: give destination stats a constructible metadata typeEntryMetadataso anchored stats can feed metadata applyperf: stat destinations with fstatat instead of an O_PATH openfstataton the held parentperf: share one held parent between the sandbox and metadata applyDestinationRoot::sharing_heldreuses the sandbox'sArc<HeldDir>fix: stat regular-file destinations through the held parentreceiver/transfer/candidates.rs(dest_lstat(follow=true))Upstream parity:
generator.c:2600-2602(touch-up stats against the held directory) and thedo_stat_at()/held_dfd_for()pattern insyscall.c.HeldDirholds its mutex only for the cached lookup and, on a miss, the one parent open (fast_io/src/held_dir.rs:58-75). Operations then use the returnedArc<OwnedFd>outside the lock.Measured (release builds, 10,100-file tree plus one deep path, quiet host, 9 interleaved rounds)
iois the strace-f -ctotal excludingfutexandsched_yield(median of 3).master-copyis an identical second copy of the master binary, used as the noise floor.The accepted costs for this work were +12 syscalls for the anchored touch-up stat (generator.c:2600-2602 parity) and about +132 for the anchored Phase-B stat, +144 in total. On current master the observed increases are all at or below that: the largest is +57, on push noop. Wall time stays within the master/master-copy noise in every case.
Residuals (later waves)
crates/transfer/src/disk_commit/process/metadata.rs:65: the pre-transfer stat on the disk-commit path still resolves the full path.crates/transfer/src/disk_commit/process/file_ops.rsinplace_pre_transfer_stat: same, for--inplace.CVE-2026-53796 stays "Partially fixed" in the CHANGELOG index until those are anchored.
Test plan
CVE-2026-53796 receiver anchoring and rustls-webpki
cargo-deny(clears RUSTSEC-2026-0382).cargo nextest run -p rsync_io --all-features -E 'test(quic)'onrustls-webpki0.103.16: 58 passedcargo fmt --all -- --checkandpython3 tools/ci/check_rustfmt_all.pycargo clippy --workspace --all-targets --all-features --no-deps -- -D warningscargo check --target x86_64-pc-windows-gnu -p fast_io -p metadata -p transfer -p engine --all-featurescargo nextest run -p transfer -p engine -p metadata -p fast_io -p filters -p daemon --all-features: 13,821 passedcargo nextest run --all-features -E 'binary(destination_root_owner_walk) | binary(daemon_concurrent_module_confinement) | binary(nonutf8_network_receiver) | binary(receiver_generator_rsyserr) | binary(upstream_compat_inc_recurse_receiver_oracle) | binary(make_room_max_delete) | binary(daemon_transfer_logging_per_file) | binary(ssh_transport) | binary(daemon_client_filter_merge_does_not_read_hidden_file)': 74 passedpython3 tools/ci/unsafe_owner_deps.py,python3 tools/ci/dead_code_census.py,cargo run -p xtask -- no-placeholders,cargo run -p xtask -- citations,python3 tools/ci/citation_drift_audit.py --ratchetEMIT_EXPECT_RESULTmanifests identical: nonroot 274 passed on both, root 304 passed on both, 0 differing cells.Local-copy delete and error fidelity (round 2)
cargo nextest run -p engine --all-features -E 'test(/send_time_open_failure|walk_time_error/)': deletion timing (Expose ProtocolVersionAdvertisement in protocol crate #138).cargo nextest run -p engine --all-features -E 'test(/vanished_file_does_not_suppress/)': vanished gating (Add negotiation sniffer test for legacy prefix mismatches #139).cargo nextest run -p bin --all-features -E 'binary(local_copy_unreadable_source_reporting)': wording and--stats(Support mutable protocol advertisements in negotiation #140, Add buffer draining helper for negotiation sniffer #141).cargo nextest run -p bin --all-features -E 'binary(local_copy_delete_busy_mount)'(Add consistency regression test for protocol helper outputs #142).sudo -n.cargo nextest run -p engine --all-features -E 'test(peel_stepped_over_child_error)': the emitter rebuilds each stepped-over path under its plan directory.cargo fmt --all -- --checkandtools/ci/check_rustfmt_all.py;-D warningsonengine,core,cli,fast_ioandbin, for both the Linux andx86_64-pc-windows-gnutargets;engine,core,cliandfast_io, plus the root local-copy, delete, exit-code and stats tests;unsafe_owner_deps,dead_code_census,xtask no-placeholdersandcitation_drift_audit.Coordination
CVE-2026-53796 receiver anchoring and rustls-webpki
receiver/transfer/setup/context.rsand is already on master, and this branch is rebased onto it.Local-copy delete and error fidelity (round 2)
Conventional commit prefix
fix:- security fix (receiver path confinement), a dependency advisory bump, and local-copy fixes that mirror upstream.Security considerations
CVE-2026-53796 receiver anchoring and rustls-webpki
receiver/tests/dest_parent_swap.rs,tests/destination_root_owner_walk.rs, and the existing sandbox carrier tests.SECURITY.md(CVE-2026-53796 row),CHANGELOG.mdSecurity section and CVE index.Local-copy delete and error fidelity (round 2)
fast_io::recursive_unlinkat, the dirfd-anchored recursive peel.rmdirfailure on a nested directory is now recorded inUnlinkResidue::failuresand stepped over. Before, it aborted the descent.EACCESon a child unlink is recorded the same way.rmdirfailure is still returned to the caller.O_DIRECTORY | O_NOFOLLOWdescent,ELOOPcycle refusal and the per-levelopenaterrors still abort exactly as before.recursive_unlinkat_*tests and the new busy-mount root test.SECURITY.mdis unchanged.Pre-merge checklist
cargo fmt --allrun locally.CHANGELOG.mdupdated if user-visible.SECURITY.mdupdated if security-relevant. The CVE stays "Partially fixed" because of the residuals above, so no status change.