Repository navigation
fix: allow DirSandbox to follow in-tree symlinks for -K - #5510
Merged
Merged
Conversation
oferchen
force-pushed
the
fix/copy-dirlinks-sandbox-regression
branch
3 times, most recently
from
June 6, 2026 19:54
5e8846e to
ca2e0de
Compare
The SEC-1 sandbox unconditionally rejected symlinks during directory descent via RESOLVE_NO_SYMLINKS / O_NOFOLLOW. This caused failures when -K (--copy-dirlinks) was active because the receiver could not descend through legitimate directory symlinks on the destination side. Add DirSandbox::enter_follow_dirlinks() that uses RESOLVE_BENEATH without RESOLVE_NO_SYMLINKS on Linux 5.6+, allowing symlinks that resolve within the tree while still rejecting .. escapes. On older kernels and other platforms, a same-device fstat check provides a conservative fallback. Mirrors upstream rsync 3.4.3 fix for secure_relative_open() which switched from per-component O_NOFOLLOW to openat2(RESOLVE_BENEATH).
The two failing tests created symlinks with absolute path targets. openat2's RESOLVE_BENEATH flag rejects symlinks whose stored target is an absolute path even when that path would resolve in-tree, because the kernel cannot prove the target stays beneath dirfd without re-resolving from /. Real-world -K (copy-dirlinks) flows preserve the source's symlink target verbatim over the wire and these are typically relative (foo/bar) rather than absolute (/tmp/xyz/foo/bar). Switching the test fixtures to relative targets aligns with both the RESOLVE_BENEATH contract and how rsync's wire protocol round-trips symlinks during -K. Affected tests: - enter_follow_dirlinks_allows_in_tree_symlink - enter_follow_dirlinks_nested_descent_through_symlink The existing rejection tests (enter_rejects_symlink_child, open_root_rejects_symlink_root) keep absolute targets because their assertion (ELOOP / ENOTDIR) is independent of target absoluteness.
oferchen
force-pushed
the
fix/copy-dirlinks-sandbox-regression
branch
from
June 10, 2026 02:59
625db0c to
aa73355
Compare
The copy_dirlinks_descent_through_in_tree_directory_symlink test was still creating an absolute-target symlink in the transfer crate's integration test, matching the same bug fixed in the fast_io unit tests by aa73355. openat2(RESOLVE_BENEATH) rejects absolute symlink targets with EXDEV ("Cross-device link") even when the target resolves in-tree, because the kernel cannot prove the re-resolution from / stays beneath the dirfd. Real -K (--copy-dirlinks) flows preserve the source's symlink target verbatim over the wire and these are typically relative. Switching the fixture to a relative target aligns with both the RESOLVE_BENEATH contract and how rsync's wire protocol round-trips -K symlinks. This unblocks the Linux feature-flag-combinations cells (incremental-flist, flat-flist) and Linux musl (stable), which all hit the same EXDEV panic during enter_follow_dirlinks.
2 tasks
oferchen
added a commit
that referenced
this pull request
Jun 10, 2026
Group PRs #5510, #5516, #5519, #5520, #5523, #5525-#5544 by shared root cause rather than by Stream bucket. Seven clusters surface; the parser- stores-string and field-vs-method shadowing clusters cover the largest share of the series, and the receiver-driver wiring-parity gap explains the NDX_DEL_STATS goodbye misses in both #5536 and #5542. Includes a defense-in-depth audit mapping each cluster onto the rust-landlock ruleset wired at crates/fast_io/src/landlock.rs. Doc-only; no code paths touched.
oferchen
added a commit
that referenced
this pull request
Jun 10, 2026
Group PRs #5510, #5516, #5519, #5520, #5523, #5525-#5544 by shared root cause rather than by Stream bucket. Seven clusters surface; the parser- stores-string and field-vs-method shadowing clusters cover the largest share of the series, and the receiver-driver wiring-parity gap explains the NDX_DEL_STATS goodbye misses in both #5536 and #5542. Includes a defense-in-depth audit mapping each cluster onto the rust-landlock ruleset wired at crates/fast_io/src/landlock.rs. Doc-only; no code paths touched.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
* fix: allow DirSandbox to follow in-tree directory symlinks for -K The SEC-1 sandbox unconditionally rejected symlinks during directory descent via RESOLVE_NO_SYMLINKS / O_NOFOLLOW. This caused failures when -K (--copy-dirlinks) was active because the receiver could not descend through legitimate directory symlinks on the destination side. Add DirSandbox::enter_follow_dirlinks() that uses RESOLVE_BENEATH without RESOLVE_NO_SYMLINKS on Linux 5.6+, allowing symlinks that resolve within the tree while still rejecting .. escapes. On older kernels and other platforms, a same-device fstat check provides a conservative fallback. Mirrors upstream rsync 3.4.3 fix for secure_relative_open() which switched from per-component O_NOFOLLOW to openat2(RESOLVE_BENEATH). * style: fix cargo fmt line break in openat2 flags assignment * test: use relative symlink targets for enter_follow_dirlinks tests The two failing tests created symlinks with absolute path targets. openat2's RESOLVE_BENEATH flag rejects symlinks whose stored target is an absolute path even when that path would resolve in-tree, because the kernel cannot prove the target stays beneath dirfd without re-resolving from /. Real-world -K (copy-dirlinks) flows preserve the source's symlink target verbatim over the wire and these are typically relative (foo/bar) rather than absolute (/tmp/xyz/foo/bar). Switching the test fixtures to relative targets aligns with both the RESOLVE_BENEATH contract and how rsync's wire protocol round-trips symlinks during -K. Affected tests: - enter_follow_dirlinks_allows_in_tree_symlink - enter_follow_dirlinks_nested_descent_through_symlink The existing rejection tests (enter_rejects_symlink_child, open_root_rejects_symlink_root) keep absolute targets because their assertion (ELOOP / ENOTDIR) is independent of target absoluteness. * test: use relative symlink target in dir_sandbox_carrier -K test The copy_dirlinks_descent_through_in_tree_directory_symlink test was still creating an absolute-target symlink in the transfer crate's integration test, matching the same bug fixed in the fast_io unit tests by aa73355. openat2(RESOLVE_BENEATH) rejects absolute symlink targets with EXDEV ("Cross-device link") even when the target resolves in-tree, because the kernel cannot prove the re-resolution from / stays beneath the dirfd. Real -K (--copy-dirlinks) flows preserve the source's symlink target verbatim over the wire and these are typically relative. Switching the fixture to a relative target aligns with both the RESOLVE_BENEATH contract and how rsync's wire protocol round-trips -K symlinks. This unblocks the Linux feature-flag-combinations cells (incremental-flist, flat-flist) and Linux musl (stable), which all hit the same EXDEV panic during enter_follow_dirlinks.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
Group PRs #5510, #5516, #5519, #5520, #5523, #5525-#5544 by shared root cause rather than by Stream bucket. Seven clusters surface; the parser- stores-string and field-vs-method shadowing clusters cover the largest share of the series, and the receiver-driver wiring-parity gap explains the NDX_DEL_STATS goodbye misses in both #5536 and #5542. Includes a defense-in-depth audit mapping each cluster onto the rust-landlock ruleset wired at crates/fast_io/src/landlock.rs. Doc-only; no code paths touched.
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
DirSandbox::enter_follow_dirlinks()method that follows directory symlinks resolving within the sandbox tree, fixing a regression where-K/--copy-dirlinkscaused the receiver sandbox to reject legitimate directory symlinks during descentopenat2(RESOLVE_BENEATH)withoutRESOLVE_NO_SYMLINKSfor kernel-enforced confinement; on older kernels and macOS falls back tofstatsame-device verificationopenat2_beneath_follow()syscall helper andopenat_follow_and_verify()fallback infast_io::dir_sandboxContext
Upstream rsync 3.4.3 fixed a regression where
secure_relative_open()rejected every symlink via per-componentO_NOFOLLOWwalk, breaking-K(copy-dirlinks) during delta transfers with "failed verification -- update discarded" errors. Our SEC-1 sandbox had the same issue:DirSandbox::enter()usesRESOLVE_BENEATH | RESOLVE_NO_SYMLINKSwhich rejects directory symlinks that-Kneeds to follow.The fix mirrors upstream's approach: use
RESOLVE_BENEATHalone (noRESOLVE_NO_SYMLINKS) so symlinks within the tree are followed while..escapes are still rejected by the kernel.Test plan
enter_follow_dirlinks_allows_in_tree_symlink- directory symlink to in-tree target succeedsenter_follow_dirlinks_works_on_real_directory- non-symlink directories still workenter_follow_dirlinks_rejects_nonexistent- ENOENT for missing childrenenter_follow_dirlinks_rejects_file_child- ENOTDIR for non-directory childrenenter_follow_dirlinks_nested_descent_through_symlink- descend through symlink then into real subdirectoryenter_follow_dirlinks_preserves_stack_on_failure- stack integrity on failed descentcopy_dirlinks_descent_through_in_tree_directory_symlink- integration test verifying defaultenter()still rejects symlinks whileenter_follow_dirlinks()permits them, including file stat through the followed symlinkenter_rejects_symlink_childtest continues to pass (no regression on default behavior)