Repository navigation
fix(transfer): stop pre-empting the confined -R implied-parent mkdir - #7565
Merged
Merged
Conversation
oferchen
force-pushed
the
fix/relative-implied-parent-preemption
branch
from
August 28, 2026 18:39
9261e8c to
faa37b2
Compare
ensure_relative_parents created every --relative implied parent up front with an unconfined, path-based create_dir. Two consequences followed from the one cause. It ran BEFORE the file list's own directory pass, so the directories already existed when that pass classified them: a real run reported '.d..t......' for parents its own --dry-run reported as 'cd+++++++++', and rsync 3.5.0 reports 'cd+++++++++' in both. Upstream's equivalent is a fallback, not a pre-pass - generator.c:1718-1725 calls make_path() only for a parent do_stat_at() still reports absent, which is after gen_entry_mkdir() (generator.c:1873) has created and itemized every directory the file list carries. The call now runs after the directory pass in all three receiver drivers. And it created through a plain path, so a symlinked component pointed a daemon's implied parent outside the module root. Upstream's make_path() builds every component with do_mkdir_at() (util1.c:238, util1.c:277), i.e. the ownership walk plus mkdirat() (syscall.c:2066), never a bare mkdir(2). The remaining fallback creations now go through fast_io::mkdirat_via_sandbox_or_fallback. Measured on a daemon push with an out-of-module symlink at the first implied parent: before, 'outside/b' and 'outside/b/c' were created outside the module and the client still exited 0; after, only the seeded marker remains, matching rsync 3.5.0 on the same fixture.
oferchen
force-pushed
the
fix/relative-implied-parent-preemption
branch
from
September 1, 2026 06:06
faa37b2 to
50072db
Compare
Replacing a conflicting destination symlink with a real directory used a
path-based `fs::remove_file`. That unlinks an entry whose target the PEER
chose, on the receiver's destination path, re-resolving every component
under the peer's influence. It is now routed onto the shared confined op,
`unlink_via_sandbox_or_fallback`, at both call sites -
`create_directories` and `create_directory_incremental`.
upstream: generator.c:1829/1841 `delete_item(..., del_opts | DEL_FOR_DIR)`
-> delete.c:71-78 `del_unlink()` -> `do_unlink_atfd()` against a held dirfd,
else util1.c:545 `robust_unlink()` -> `do_unlink_at()`. Both arms are the
confined wrappers; upstream issues no plain `unlink()` on this path.
`sandbox` may be `None`. That is a supported arm, not a gap: the helper then
applies upstream's three-arm `do_unlink_at()` contract, which errors rather
than falling back to a plain syscall when the ownership walk refuses.
Second half: a refused removal is now REPORTED. Both sites recovered with
`.unwrap_or_else(|_| if dir_path.exists() { Existing } else { Missing })`,
and `exists()` FOLLOWS symlinks - so the entry whose removal had just been
denied reported back as an existing directory and the transfer walked
straight through it, with the errno discarded. Upstream does
`goto skipping_dir_contents` (generator.c:1840-1843), and
generator.c:1443-1467 states the rule for the family: a runtime denial is a
real failure and is deliberately NOT retried unconfined. The failure now
lands in the same failed-directory set as a denied mkdir, so it reaches
io_error and the exit code.
Also corrects the citation at creation.rs:95-97, which named
`syscall.c do_unlink()`. That is the wrong upstream function for this site
and is what pointed the previous reading at the plain entry point.
The new test denies the removal with a read-only parent - the portable
stand-in for any refusal - and asserts the failure is reported. Restoring
the swallow fails it; the --existing companion stays green.
oferchen
force-pushed
the
fix/relative-implied-parent-preemption
branch
from
September 1, 2026 08:10
4e9b5ba to
a364f2e
Compare
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.
The upstream chain
Replacing a conflicting destination symlink with a real directory reaches the confined unlink wrapper upstream, not the plain one:
Both arms are the confined wrappers. Upstream issues no plain
unlink()on this path.do_unlink_at()insyscall.cis the three-arm contract:symlink_optout_allowed()takes the plain syscall; otherwiseowner_walk_parent()thenunlinkat(dfd, bname, 0); a refused walk returns-1rather than falling back.oc did the opposite.
classify_dir_destinationremoved the symlink with a path-basedfs::remove_file, and the comment above it citedsyscall.c do_unlink()- a function this path never reaches. That citation is what made a plain unlink look correct here. It is fixed in the same commit.Both call sites now route through
fast_io::unlink_via_sandbox_or_fallback, oc's port ofdo_unlink_at().sandboxmay beNone; that is a supported arm, not a gap, and it errors rather than degrading to a plain syscall when the walk refuses.The rule this is an instance of
The worker allowlist is
*at-only by design: it was derived from the sites already routed onto the confined resolver, so anything still callingstd::fsissues a path-based syscall the filter does not carry. Widening it silences the detector and moves oc away from upstream. Someone will hit this again onmkdir83 within the week; the answer there is the same.Why this class is structurally invisible on aarch64
The defect only exists on x86_64, and not by accident of which host happened to fail. Disassembling Ubuntu amd64
libc.so.6(glibc 2.44) with a pure-ELF opcode scanner -b8 imm32followed by0f 05inside each symbol body, nothing executed - gives what glibc actually issues:unlink()rmdir()mkdir()rename()symlink()link()readlink()chmod()chown()lchown()open()openat)open()is the exception, and it is why the gap survived: it already lowers toopenat, so the first operation anyone reaches for to sanity-check the filter is the one that cannot show the defect.stat/lstatare the same shape (newfstatat).aarch64 control, from
asm-generic/unistd.h:__NR_unlink,__NR_mkdir,__NR_rename,__NR_rmdirare absent;__NR_unlinkatis 35. The architecture is*at-only, so an*at-only allowlist is complete there and cannot miss anything. An aarch64 green is not evidence the allowlist is correct - that arch is structurally unable to exercise the gap. Same class as the earlierunlink,readlinkandmkdirfindings.The scanner is kept as
abiscan.py. Note it enumerates detector hits, not additions to make.Reproducing a CI daemon defect locally
Build the binary with
cargo build --workspace --all-features --bin oc-rsync.-p bin --all-featuresenables only the bin package's own features;daemon-seccompis not a default feature and is not reachable from the root manifest, so it engages solely through workspace-wide feature unification - exactly what CI does. Every-p binbuild measures a daemon with no seccomp layer at all, and the daemon says so in its own log:Three separate investigations of this cell produced false passes on that difference before it was noticed.
Mechanism proof
On aarch64, removing
libc::SYS_unlinkatfrom the worker allowlist reproduces the CI failure character-for-character: exit 23,multiplexed frame truncated, daemon logInvalid cross-device link (os error 18) (code 1) at streams.rs(420),outside: ["marker"],inside: ["a", "realdir"]. That is the same defect expressed through the syscall aarch64 does use, which is why it is a valid mechanism proof on a host that cannot reproduce the x86_64 form.The swallow was two sites, not one
create_directoriesandcreate_directory_incrementaleach carried their own copy of:Wrong twice over.
exists()follows symlinks, so the entry whose removal had just been denied reported back as an existing directory and the transfer proceeded through a symlink the peer controls. And the errno was discarded, which is how a denied unlink surfaced three layers later as an opaque EXDEV from the confined walk.Upstream does
goto skipping_dir_contents(generator.c:1840-1843), andgenerator.c:1443-1467states the rule for the whole family: a runtime denial is a real failure and is deliberately NOT retried unconfined. Both sites now report the failure into the same set as a denied mkdir, so it reachesio_errorand the exit code. Fixing only the first would have left the incremental-recursion path walking through the surviving symlink.Verification, and one claim that is inference
daemon_relative_implied_parent_confinementand everydirectory::creationtest. The sibling escape cells still refuse:relative_implied_parents_must_not_be_built_outside_the_module,a_sole_creator_relative_parent_must_not_escape_the_module,a_confined_relative_push_still_delivers_the_whole_path.clippy -p transfer --all-features --all-targets -D warningsclean.⚠ Stated plainly: "the fix works on x86_64" is inference, not measurement. The change removes the EPERM by making the syscall
unlinkat, which the allowlist carries on every architecture - but that has not been observed on a host where the filter is live. No seccomp layer exists on macOS or aarch64, so the local greens cannot show the CI cell flipping. The reasoning is sound and the mutation proved the mechanism through that exact syscall; CI is the instrument for the rest.Known adjacent site, deliberately not in scope
fs::create_dir_allatcreation.rs:325issuesmkdir83 and is in the same gap on the same path. It is the next instance of this class and is left to its own change.