Repository navigation
Add coverage for duplicate protocol offers in negotiation - #3
Merged
Merged
Conversation
3 tasks
oferchen
added a commit
that referenced
this pull request
May 1, 2026
…3535) Maps each entry in the unconditional KNOWN_FAILURES array and each conditional rule in is_known_failure_from_conf() to a concrete eliminate path: fix in oc-rsync, permanent upstream bug, or permanent protocol-version-locked. Cites upstream rsync 3.4.1 source (compat.c, exclude.c, token.c) and existing tracking issues (#1916, #1685, companion iconv/zstd/protocol audits) so beta-readiness criterion #3 has an explicit work-plan. Two entries are fixable (standalone:iconv-upstream daemon plumbing and standalone:delta-stats daemon-mode delta engine); six are permanent (one upstream bug, five protocol-version-locked at proto < 29 or 30).
2 tasks
oferchen
added a commit
that referenced
this pull request
May 5, 2026
…3535) Maps each entry in the unconditional KNOWN_FAILURES array and each conditional rule in is_known_failure_from_conf() to a concrete eliminate path: fix in oc-rsync, permanent upstream bug, or permanent protocol-version-locked. Cites upstream rsync 3.4.1 source (compat.c, exclude.c, token.c) and existing tracking issues (#1916, #1685, companion iconv/zstd/protocol audits) so beta-readiness criterion #3 has an explicit work-plan. Two entries are fixable (standalone:iconv-upstream daemon plumbing and standalone:delta-stats daemon-mode delta engine); six are permanent (one upstream bug, five protocol-version-locked at proto < 29 or 30).
3 tasks
oferchen
added a commit
that referenced
this pull request
May 17, 2026
Adds three env-gated sub-scenarios to scripts/windows_throughput_bench.sh that isolate the IOCP hotspots catalogued in the IOCP sync-blocking audit, so future Windows write/read/network improvements can be attributed to specific changes instead of moving the aggregate large_1gib / small_10000 numbers. Enabled by OC_RSYNC_BENCH_DRILLDOWN=1; the existing scenarios run unchanged when the flag is absent. - write_only_iocp: oc-rsync --whole-file --inplace vs cp control to pin the IocpWriter per-IO drain (audit rows #1, #4, #13). - read_only_iocp: oc-rsync --dry-run vs upstream --dry-run over the 1 GiB fixture to pin the IocpReader drain (audit rows #2, #3). - network_only_loopback: rsync push between two short-lived loopback daemons on 127.0.0.1, cancelling out disk bandwidth so only the IocpSocket send/recv path varies (audit rows #8-#11). Documents the invocation, hotspot mapping, and interpretation rules in docs/benchmarks/windows-throughput.md. The drilldown scenarios are not in the required-checks list and have no acceptable-band thresholds; they exist to attribute movement, not to gate merges.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
…ete/context.rs (#2353) (#4365) * docs: design SpillPolicy public API + env-var surface (#2335) (#4340) Introduces design for a 5-knob SpillPolicy struct replacing the single spill_threshold_bytes field on ConcurrentDeltaConfig. Documents defaults, env-var precedence under OC_RSYNC_SPILL_*, ops-friendly CLI flags (--spill-dir, --spill-threshold-bytes), validation rules, a one-release deprecated-forwarding migration story, and a 5-step implementation plan keyed to subtasks STN-2..STN-14. Design only; no runtime changes. * docs(audits): mutex poison recovery classification (#2350, #2351, #2358) (#4341) Inventory all `.lock().expect()` / `.lock().unwrap()` (and `RwLock` peers) sites across the workspace. Classify each as RECOVERABLE (safe to `PoisonError::into_inner()` and proceed), FATAL (mid-operation panic leaves wire state inconsistent, must propagate), or TEST-ONLY (test fixtures and `#[cfg(test)]` env mutexes). Adds tables for the delete module and workspace hotspots, per-crate counts, and follow-up MPE-3..MPE-17 task list anchored on a shared `lock_or_recover` / `lock_or_panic` helper. Identifies `crates/engine/src/local_copy/context_impl/options.rs` as the highest- value single remediation target (7 FATAL batch-writer sites). * feat(engine): add lock_or_recover helpers for poison recovery (#4342) Introduce util::poison with lock_or_recover, read_or_recover, and write_or_recover helpers that promote PoisonError into the inner guard for state that remains valid after a panicking thread unwinds. These helpers will be used by upcoming refactors that replace .lock().expect(...) call sites in modules whose protected state is monotonic or otherwise self-consistent (delete emitter recorder, buffer pool counters, work-queue shards) so a single panicking worker no longer cascades into a full pool abort. Includes unit tests that poison a Mutex and RwLock via a panicking spawned thread and verify the helpers return a usable guard rather than re-panicking. * docs(audits): io_uring data path coverage (#2361) (#4343) Catalogue every SQE construction site in fast_io/io_uring by opcode category. Trace each site upward to confirm whether engine, transfer, or rsync_io route real production data through it. Refute the "metadata-only" framing - the receiver write path, disk-commit thread, and sender source-read path all submit file-data SQEs today. Identify the three production sites where switching to io_uring data SQEs would yield the largest throughput gain (sockets, sub-1MiB source reads, sparse/append fallback) for follow-on IUD-2 and IUD-3 work. * test(fuzz): extend varint decode fuzz target (#2318) (#4344) Adds structured boundary coverage to the protocol varint fuzz target so it does not rely on the corpus to reach extreme inputs: - i32 edges (MIN/MAX, +-1, 0, -0x4000_0000) and i64 edges encoded with write_int/write_varint/write_varlong/write_longint/encode_varint_to_vec, decoded with the matching readers and asserted to roundtrip. - Truncated buffers: every strict prefix of each encoded boundary value is fed through decode_varint/read_varint/read_varlong/read_longint to exercise mid-byte UnexpectedEof paths without panicking. - Both protocol 31 (legacy 4-byte LE via read_int) and protocol 32 (varint) paths driven through read_varint30_int with proto 28-32. - Legacy longint short and long (0xFFFFFFFF-prefixed) forms. The unstructured arbitrary-bytes coverage from the original target is preserved and still runs every iteration. * docs: document Windows NTFS ACL behaviour and lossy cases (#2313) (#4346) Expand the --acls reference, README platform table, and operator migration guide to describe the Tier 1C partial Windows DACL path: deny ACEs dropped, inherited ACEs skipped, SACL gated on --audit-acls, non-rwx access bits collapsed, and unresolvable SIDs dropped. Document --audit-acls, --fail-on-windows-acl-loss, and --windows-acls as planned flags with SDDL wire encoding notes, and cross-link the design doc from all three surfaces. * docs(audits): fuzz coverage gap followups (#2316) (#4347) Decompose the remaining P0/P1 fuzz coverage gaps from the FCV audit into individually filable follow-up tasks. Each entry cites the parse function (file:line), recommends a raw vs structured Arbitrary input shape, and lists the panic / no-panic invariants the harness should assert. Covers the two open P0 gaps (negotiation_prologue, capability_vstring) plus a P0 fill-in (legacy_sniffer reader paths) and the five highest P1 surfaces (compat_flags, filter_list_wire, ndx_codec, incremental_flist, idlist, compress_decoders). * feat(rsync_io): ssh-socketpair-stderr connection primitive (#2372) (#4348) Implements task SSE-3 from docs/design/socketpair-stderr-channel.md. Adds the `socketpair_stderr` module gated behind the new `ssh-socketpair-stderr` Cargo feature (default off). The primitive returns a connected pair of `File`-typed byte streams ready to back the async drain that SSE-4 will layer on top. Unix path uses `UnixStream::pair` (`socketpair(AF_UNIX, SOCK_STREAM, 0)` under the hood with `SOCK_CLOEXEC`) and converts both halves through `OwnedFd` so callers store the parent and child ends behind the same handle type as the existing pipe fallback. A `set_nonblocking` helper toggles `O_NONBLOCK` via the safe stdlib API, ready for the SSE-4 tokio reactor registration. Windows currently returns `io::ErrorKind::Unsupported`; the loopback shim ships under SSE-5 alongside the safe handle bridge in `fast_io`, so the crate keeps `#![deny(unsafe_code)]` intact. Tests gated on Unix + feature flag: 1 KiB round-trip, peer-close EOF, and `set_nonblocking` mode flip surfaced as `WouldBlock`. * docs(design): io_uring data path - receive + send (#2362, #2363) (#4349) Two companion design docs specifying how transfer file data will be routed through io_uring SQEs end-to-end on Linux: - iouring-receive-data-path.md: route disk-commit chunk writes through registered buffers + IORING_OP_WRITE_FIXED, gated by the new iouring-data-writes feature (default off). Shares a pool with the SMR-3a basis reader. - iouring-send-data-path.md: basis re-read via IORING_OP_READ_FIXED feeding directly into IORING_OP_SEND_ZC against the multiplex socket, with the 4-byte MSG_DATA header pre-pended in-slot. Gated by the new iouring-data-sends feature (default off). Both docs spell out ordering, fsync placement, short-write handling, fallback hierarchy, SQPOLL exclusion, and a 5-step phased rollout keyed to follow-up tasks IUD-5..IUD-8. No code changes. * docs(audits): Windows hardlink ACL inheritance (#2311) (#4350) Audits every ACL apply site for files participating in NTFS hardlink cohorts, compares oc-rsync behaviour to upstream rsync 3.4.2 on cygwin, and documents the one divergence: the local-copy --copy-dest Link branch re-applies the source DACL once per follower instead of relying on NTFS inode-level sharing. The writes are idempotent (identical bytes), so correctness holds; the cost is N redundant SetNamedSecurityInfoW round trips and audit log noise. Includes a 3-link cohort test plan covering wire receive, local copy, --copy-dest and cross-cohort isolation. * ci: nightly fuzz coverage report per target (#2322) (#4351) Add `Fuzz Coverage Report` workflow that runs `cargo fuzz coverage` for every target across the `fuzz/`, `crates/protocol/fuzz/`, and `crates/filters/fuzz/` workspaces nightly at 03:30 UTC and uploads the resulting `.lcov` files as 30-day workflow artifacts. The job is informational (`continue-on-error: true`) and emits a per-target line coverage summary to the GitHub step summary, mirroring the SAFETY audit informational pattern from ci.yml. Documents the rollout in docs/audits/fuzz-coverage-matrix.md so the matrix and promotion criteria stay in one place. * bench(windows): per-hotspot drilldown mode (#2305) (#4352) Adds three env-gated sub-scenarios to scripts/windows_throughput_bench.sh that isolate the IOCP hotspots catalogued in the IOCP sync-blocking audit, so future Windows write/read/network improvements can be attributed to specific changes instead of moving the aggregate large_1gib / small_10000 numbers. Enabled by OC_RSYNC_BENCH_DRILLDOWN=1; the existing scenarios run unchanged when the flag is absent. - write_only_iocp: oc-rsync --whole-file --inplace vs cp control to pin the IocpWriter per-IO drain (audit rows #1, #4, #13). - read_only_iocp: oc-rsync --dry-run vs upstream --dry-run over the 1 GiB fixture to pin the IocpReader drain (audit rows #2, #3). - network_only_loopback: rsync push between two short-lived loopback daemons on 127.0.0.1, cancelling out disk bandwidth so only the IocpSocket send/recv path varies (audit rows #8-#11). Documents the invocation, hotspot mapping, and interpretation rules in docs/benchmarks/windows-throughput.md. The drilldown scenarios are not in the required-checks list and have no acceptable-band thresholds; they exist to attribute movement, not to gate merges. * docs(architecture): BGID lifecycle (#2299) (#4353) Add docs/architecture/bgid-lifecycle.md covering the allocation flow, Drop-driven recycling rules, u16 namespace exhaustion math, pre-sized free-list rationale, planned high-water-mark stat (BGE-3), and the planned graceful fallback when exhausted (BGE-6). Cross-references the audit at docs/audits/bgid-lifecycle.md (PR #4331) and the session topology overview. * feat(metadata): Windows DACL/SACL SDDL round-trip (#2307, #2308) (#4354) Adds opt-in SDDL serialisation helpers in crates/metadata/src/acl_windows.rs: - read_dacl_sddl(path): GetNamedSecurityInfoW + ConvertSecurityDescriptor ToStringSecurityDescriptorW for owner/group/DACL. - read_sddl_with_sacl(path): same plus SACL (requires SE_SECURITY_NAME). - write_dacl_sddl(path, sddl): ConvertStringSecurityDescriptorToSecurity DescriptorW + SetNamedSecurityInfoW, applying owner, group, DACL, and SACL components present in the parsed descriptor. DACL is written with PROTECTED_DACL_SECURITY_INFORMATION per design section 5.2 to avoid silently inheriting extra ACEs from the parent directory. All Win32-allocated buffers are wrapped in RAII guards (OwnedSecurity Descriptor, OwnedLocalWString) that release via LocalFree on drop, even on error paths. Unsafe blocks each carry SAFETY notes naming the invariant they uphold. Implements the Windows fidelity payload described in docs/design/windows-ntfs-acl-support.md section 4.2. Re-exports the new functions from crates/metadata/src/lib.rs under the existing cfg(all(feature = "acl", windows)) gate so consumers can drive the round-trip without poking module internals. Tests on a Windows tempdir: - read_dacl_sddl_returns_non_empty_for_temp_file - write_dacl_sddl_round_trips_known_descriptor - write_dacl_sddl_preserves_owner_and_group - write_dacl_sddl_rejects_invalid_input * feat(fast_io): BGID high-water mark + 50%-occupancy warning (#2295) (#4355) Adds an observable peak counter to the io_uring buffer-group-ID allocator so operators can see the worst-case namespace pressure the process has experienced. - `PEAK_USED: AtomicU16` is updated via `fetch_max` after every successful `BgidAllocator::allocate`, including reuses from the free-list. Deallocation never lowers the value. - `bgid_peak_used()` and `bgid_inflight()` expose the stat and the live snapshot for dashboards and capacity tests. - The free-list is pre-sized to 4 096 entries so steady-state daemon churn does not trigger `Vec` reallocations under the free-list mutex. - When the in-flight count crosses 50 % of the 16-bit namespace (32 768) a throttled `tracing::warn!` fires at most once per 30 s so a hot allocate loop cannot flood the log. - Non-Linux stub mirrors the new public accessors with zero returns so cross-platform callers compile without cfg-gating. - Tests cover the 100-allocation peak, the deallocate monotonicity, the pre-sized capacity, and the inflight subtraction. * docs(architecture): drain error recovery contract (#2385) (#4356) * feat(fast_io): IOCP concurrent_ops auto-size based on CPU count (#2302) (#4358) Replace the static IocpConfig::concurrent_ops default (4) with a CPU-derived value: (cpus * 4).clamp(8, 64). This mirrors io_uring's default_sq_entries derivation so wide hosts keep more overlapped WriteFile operations in flight, while a 1-CPU host still gets a healthy 8-deep submission window. The field stays overridable for explicit tuning. The COMPLETION_DRAIN_BATCH = 64 in disk_batch.rs and DEFAULT_BATCH_SIZE = 64 in pump.rs remain fixed (intentionally aligned with the new MAX_CONCURRENT_OPS ceiling) so a single GetQueuedCompletionStatusEx call can reap an entire in-flight cohort; the pump path already grows on demand up to MAX_BATCH_SIZE on ERROR_INSUFFICIENT_BUFFER (#1930). * docs: Mutex poison recovery policy (#2360) (#4359) Capture the engine-wide contract for reacting to a poisoned Mutex / RwLock. Distils the per-site audit at docs/audits/mutex-poison-policy.md and the helpers landed in crates/engine/src/util/poison.rs into one document new code can follow. Defines the four cases (RECOVERABLE, FATAL, TEST-ONLY, UNAUDITED), the decision tree for picking between them, code templates for the RECOVERABLE (lock_or_recover) and FATAL (expect + # Panics rustdoc) paths, the per-crate audit counts (23 fatal / 28 recoverable / 317 test-only across 368 sites), and the MPE-4..MPE-10 promotion path that ends with the contract becoming a CI lint. Cross-references docs/architecture/drain-error-recovery.md for the ATU-series companion and the rsync_io/fast_io call sites that already match the helper recipe. * feat(engine): SpillPolicy struct + ConcurrentDeltaConfig wiring (#2336) (#4360) Introduce a public SpillPolicy aggregate that groups every spill-layer knob (threshold_bytes, dir, reclaim_mode, granularity, compression) under one value, and wire it through ConcurrentDeltaConfig so callers can stage policy changes without touching the DeltaConsumer API. The legacy spill_threshold_bytes / spill_dir fields collapse into spill_policy; deprecated accessors keep existing call sites compiling while pointing readers at the new field. Defaults match the historical behaviour (no spill, no extra plumbing). The new SpillCompression::Zstd variant lives behind the additive spill-compression feature so default builds gain no dependency. * test(metadata): Windows source -> Linux destination ACL round-trip (#2312) (#4366) Pins the cross-platform translation contract from the Windows NTFS ACL design (docs/design/windows-ntfs-acl-support.md, sections 5.1/5.2/5.3): - Forward leg: synthetic Windows-side DACL with owner/group/Everyone allow ACEs plus one named user lowers to user_obj/group_obj/other_obj and a RsyncAcl::names entry, with name preserved. - Reverse leg: POSIX mode 0o755 plus one named user and one named group round-trips through the Windows-side ACE shape and back to the same rwx triplet, kinds, RIDs, and account names. - Lossy path: deny ACEs are dropped on lowering; POSIX bits derive exclusively from surviving allow ACEs. Gate on OC_RSYNC_METADATA_INTEROP=1 to match acl_xattr_roundtrip_linux, and cfg(unix) so Linux/macOS CI runners can pick it up. Uses synthetic SDDL-style fixtures so no Windows host is needed; assertions exercise the documented mapping rules without depending on the in-flight WAS-2, WAS-3, and WAS-4 helpers. * docs(audits): Windows IOCP profiling methodology (#2300) (#4370) WPG-1 deliverable: methodology a Windows operator follows to convert the wall-clock signal from the throughput bench into a ranked hotspot table. Picks ETW + WPA as the default stack (free, ships with the Windows ADK), with VTune and WPR as alternatives. Documents the six profiling steps (release-with-debug build, drilldown bench run, ETW CPU + IO captures, classify, append results), defines the three hotspot buckets (per-IO blocking drain, CQ-depth saturation, bounce-buffer copy) keyed to rows of the sync-blocking audit and to WPG-3/WPG-4 mitigations, and lays out a five-step implementation plan keyed to WPG-4..WPG-6. * docs: document ssh-socketpair-stderr feature (#2377) (#4368) Adds the experimental `ssh-socketpair-stderr` feature to the README cargo features table and a dedicated subsection in the vNEXT operator migration guide. The flag was introduced by SSE-3 (#2372) on top of the design in docs/design/socketpair-stderr-channel.md (#2371) and gates the AF_UNIX socketpair stderr channel that lets the async SSH transport register the drain with epoll/kqueue/tokio AsyncFd and wake it via shutdown(2) instead of consuming a per-connection blocking thread. Migration guide entry explains when to opt in (Linux endpoints running with async-ssh, fan-out clients, deployments wanting the larger socketpair kernel buffer and shutdown-based wake) and when to leave the default (Windows until SSE-5 lands, sync-only SSH builds, operators who prefer the simpler pipe semantics for debugging). Updates the section 4 count, rollback list, and appendix table. Cross-links to the design doc and the SSE-1 stderr handling audit. Task SSE-8. * docs: SpillPolicy user-facing documentation (#2346) (#4378) Document the receiver-side SpillPolicy surface across the three operator-facing docs: - README: add a Receiver memory tuning subsection under the cargo features table cross-linking the public-API design and the spillable buffer internals. - docs/oc-rsync.1.md: document the planned --spill-dir and --spill-threshold-bytes flags (STN-11) under Performance Options, including the OC_RSYNC_SPILL_* env-var bridge until they ship. - docs/operator-migration-guide-vNEXT.md: add a Receiver spill tunability subsection covering all five OC_RSYNC_SPILL_* env vars, defaults, precedence, and when to override. * docs: ssh-socketpair-stderr opt-in feature (SSE-8 #2377) (#4385) * docs(audit): SPL-9 spill mod.rs re-export audit (#2331) (#4390) * refactor(engine): document delete/context mutex panic invariants (#2353) Per the workspace mutex-poison policy (docs/audits/mutex-poison-policy.md, MPE-1/2/9), every `.lock().expect()` site in `crates/engine/src/delete/context.rs` is classified FATAL. The cursor stack encodes upstream's parent-before-child traversal order and the segment-entries buffer is overwritten in place; recovery from a poisoned guard would mis-order deletes or unlink stale names. The strict policy is to keep `.lock().expect("...")` and document the invariant. Changes - Add `# Panics` sections to `observe_directory`, `begin_directory`, `publish_plan_for` naming the invariant and pointing at the audit doc. - Refresh the existing `# Panics` block on `observe_segment_for_delete` to match the new wording. - Normalise the three `cursor.lock().unwrap()` test sites to `cursor.lock().expect("test cursor poisoned")` so diagnostics match the production message. No production swap to `lock_or_recover` here: the audit lists 0 RECOVERABLE sites in this file. The helper now lives in `crates/engine/src/util/poison.rs` (PR #4342) for later MPE-* tickets that target genuinely recoverable state (drain shard buffer, recorder sinks, bgid free lists). No public API change. `cargo fmt --all` clean.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
Adds three env-gated sub-scenarios to scripts/windows_throughput_bench.sh that isolate the IOCP hotspots catalogued in the IOCP sync-blocking audit, so future Windows write/read/network improvements can be attributed to specific changes instead of moving the aggregate large_1gib / small_10000 numbers. Enabled by OC_RSYNC_BENCH_DRILLDOWN=1; the existing scenarios run unchanged when the flag is absent. - write_only_iocp: oc-rsync --whole-file --inplace vs cp control to pin the IocpWriter per-IO drain (audit rows #1, #4, #13). - read_only_iocp: oc-rsync --dry-run vs upstream --dry-run over the 1 GiB fixture to pin the IocpReader drain (audit rows #2, #3). - network_only_loopback: rsync push between two short-lived loopback daemons on 127.0.0.1, cancelling out disk bandwidth so only the IocpSocket send/recv path varies (audit rows #8-#11). Documents the invocation, hotspot mapping, and interpretation rules in docs/benchmarks/windows-throughput.md. The drilldown scenarios are not in the required-checks list and have no acceptable-band thresholds; they exist to attribute movement, not to gate merges.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
Adds three env-gated sub-scenarios to scripts/windows_throughput_bench.sh that isolate the IOCP hotspots catalogued in the IOCP sync-blocking audit, so future Windows write/read/network improvements can be attributed to specific changes instead of moving the aggregate large_1gib / small_10000 numbers. Enabled by OC_RSYNC_BENCH_DRILLDOWN=1; the existing scenarios run unchanged when the flag is absent. - write_only_iocp: oc-rsync --whole-file --inplace vs cp control to pin the IocpWriter per-IO drain (audit rows #1, #4, #13). - read_only_iocp: oc-rsync --dry-run vs upstream --dry-run over the 1 GiB fixture to pin the IocpReader drain (audit rows #2, #3). - network_only_loopback: rsync push between two short-lived loopback daemons on 127.0.0.1, cancelling out disk bandwidth so only the IocpSocket send/recv path varies (audit rows #8-#11). Documents the invocation, hotspot mapping, and interpretation rules in docs/benchmarks/windows-throughput.md. The drilldown scenarios are not in the required-checks list and have no acceptable-band thresholds; they exist to attribute movement, not to gate merges.
4 tasks
This was referenced Jun 10, 2026
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
Adds three env-gated sub-scenarios to scripts/windows_throughput_bench.sh that isolate the IOCP hotspots catalogued in the IOCP sync-blocking audit, so future Windows write/read/network improvements can be attributed to specific changes instead of moving the aggregate large_1gib / small_10000 numbers. Enabled by OC_RSYNC_BENCH_DRILLDOWN=1; the existing scenarios run unchanged when the flag is absent. - write_only_iocp: oc-rsync --whole-file --inplace vs cp control to pin the IocpWriter per-IO drain (audit rows #1, #4, #13). - read_only_iocp: oc-rsync --dry-run vs upstream --dry-run over the 1 GiB fixture to pin the IocpReader drain (audit rows #2, #3). - network_only_loopback: rsync push between two short-lived loopback daemons on 127.0.0.1, cancelling out disk bandwidth so only the IocpSocket send/recv path varies (audit rows #8-#11). Documents the invocation, hotspot mapping, and interpretation rules in docs/benchmarks/windows-throughput.md. The drilldown scenarios are not in the required-checks list and have no acceptable-band thresholds; they exist to attribute movement, not to gate merges.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
RUSSH-ASY.3: replace tokio::task::spawn_blocking with std::thread::Builder + tokio::sync::oneshot for the per-session server pipeline join in run_async_session. Removes one of two long-lived blocking-pool slots per async-SSH session without touching the threaded transfer pipeline (per project_no_async_threaded_only). The dedicated OS thread is named oc-rsync-ssh-server so ps, top, audit logs, and panic backtraces surface async-SSH workers. Builder::spawn propagates spawn failures as ClientError rather than panicking. The oneshot receiver gives an explicit error path when the worker thread closes without reporting an outcome. Prerequisite for RUSSH-ASY.5 re-bench at 128/256/512 sessions; once the bench confirms wins, RUSSH-ASY.6 flips the dispatch default. Sites #2 (writer_fanin), #3 (daemon hybrid), and #4 (per-file metadata) remain on spawn_blocking and ship as separate follow-ups. See docs/design/russh-async-native-migration-plan.md section 4.
oferchen
added a commit
that referenced
this pull request
Nov 28, 2026
rsync 3.5.2 enters the module root with change_dir(module_chdir) for every session (clientserver.c:1063). For use chroot = no that is the ownership walk (util1.c:1351-1361): a symlink in the module path owned by another user is refused, and the client gets @error: chdir failed. oc ran that walk only when the session also chrooted or dropped privileges. A rootless daemon with use chroot = no returned early and served the module through the plain path, so a foreign-owned symlink in path = was followed on push and pull alike. The early path now runs the same walk and keeps the root's descriptor. It does not chdir: a session served as a thread of an async daemon would move every other session's working directory. The refusal is logged as 3.5.2 logs it: the walk's untrusted-symlink notice, then "[Receiver] chdir <path> failed: <errno text>" (clientserver.c:695). A privileged session still enters the module root before its privilege drop, as upstream does (clientserver.c:1063 before :1102, :1127), so a module below a directory its uid cannot search keeps working. Inside the module, 3.5.2 enters the client's destination with the confined walk, secure_relative_dirfd() and fchdir() (util1.c:1430-1446). An in-tree relative symlink is followed; one that leaves the module is refused with ELOOP whoever owns it. get_local_name() reports that as change_dir#1, #2 or #3 "<dest>" (in <module>) and exits 3, or as the make_path() mkdir failure with exit 11 under --mkpath. oc did a plain stat and failed later with its own code-11 line. The receiver now walks a daemon destination beneath the module root's descriptor through fast_io's open_dir_beneath, create_dir_beneath and make_path_beneath, and prints 3.5.2's lines. Each session records its module root once as a ServedRoot: the absolute module path, its canonical form and the root's descriptor. full_fname() strips the module root from that path, as util1.c:1543 strips module_dirlen from curr_dir, and a relative merge-file name is joined onto it (exclude.c:735-746). This also fixes the privileged leg, which served "." and printed link_stat "/d/d/a1" and "failed to open exclude file etc/hostname" where 3.5.2 prints "/d/a1" and the module-rooted name. insecure links = yes keeps the plain open for the root and the tail (syscall.c:139, :433-436), so an opted-out module's symlinked root is followed instead of being replaced by a new directory. The daemon now logs a fatal cause and trailer before framing them for the client, as rwrite() calls logit() before sending (log.c:390-407). A 3.5.2 client kills its remote-shell child on exit (cleanup.c:203-204), so a daemon reached that way lost the line when it logged afterwards. Deliberate deviation: 3.5.2's do_mkdir() (main.c:817) follows an escaping link and makes a new destination outside the module before change_dir#2 refuses it. oc refuses first, with the same line and exit code, and makes nothing.
oferchen
added a commit
that referenced
this pull request
Nov 28, 2026
rsync 3.5.2 enters the module root with change_dir(module_chdir) for every session (clientserver.c:1063). For use chroot = no that is the ownership walk (util1.c:1351-1361): a symlink in the module path owned by another user is refused, and the client gets @error: chdir failed. oc ran that walk only when the session also chrooted or dropped privileges. A rootless daemon with use chroot = no returned early and served the module through the plain path, so a foreign-owned symlink in path = was followed on push and pull alike. The early path now runs the same walk and keeps the root's descriptor. It does not chdir: a session served as a thread of an async daemon would move every other session's working directory. The refusal is logged as 3.5.2 logs it: the walk's untrusted-symlink notice, then "[Receiver] chdir <path> failed: <errno text>" (clientserver.c:695). A privileged session still enters the module root before its privilege drop, as upstream does (clientserver.c:1063 before :1102, :1127), so a module below a directory its uid cannot search keeps working. Inside the module, 3.5.2 enters the client's destination with the confined walk, secure_relative_dirfd() and fchdir() (util1.c:1430-1446). An in-tree relative symlink is followed; one that leaves the module is refused with ELOOP whoever owns it. get_local_name() reports that as change_dir#1, #2 or #3 "<dest>" (in <module>) and exits 3, or as the make_path() mkdir failure with exit 11 under --mkpath. oc did a plain stat and failed later with its own code-11 line. The receiver now walks a daemon destination beneath the module root's descriptor through fast_io's open_dir_beneath, create_dir_beneath and make_path_beneath, and prints 3.5.2's lines. Each session records its module root once as a ServedRoot: the absolute module path, its canonical form and the root's descriptor. full_fname() strips the module root from that path, as util1.c:1543 strips module_dirlen from curr_dir, and a relative merge-file name is joined onto it (exclude.c:735-746). This also fixes the privileged leg, which served "." and printed link_stat "/d/d/a1" and "failed to open exclude file etc/hostname" where 3.5.2 prints "/d/a1" and the module-rooted name. insecure links = yes keeps the plain open for the root and the tail (syscall.c:139, :433-436), so an opted-out module's symlinked root is followed instead of being replaced by a new directory. The daemon now logs a fatal cause and trailer before framing them for the client, as rwrite() calls logit() before sending (log.c:390-407). A 3.5.2 client kills its remote-shell child on exit (cleanup.c:203-204), so a daemon reached that way lost the line when it logged afterwards. Deliberate deviation: 3.5.2's do_mkdir() (main.c:817) follows an escaping link and makes a new destination outside the module before change_dir#2 refuses it. oc refuses first, with the same line and exit code, and makes nothing.
oferchen
added a commit
that referenced
this pull request
Nov 28, 2026
## Summary A daemon serving a module with `use chroot = no` had two gaps against rsync 3.5.2, one destructive bug, and one pre-existing rendering defect on its privileged leg. **Data loss: an opted-out module's symlinked root was replaced.** With `insecure links = yes` and `path =` naming a symlink, oc replaced the operator's symlink with a new empty directory and wrote the transfer into it. rsync 3.5.2 follows the link. oc now does the same: the symlink is still there afterward and the data lands in its target. **The module root was never walked by a rootless daemon.** rsync 3.5.2 enters the module root with `change_dir(module_chdir)` on every session (clientserver.c:1063). For an unchrooted module that is the ownership walk (util1.c:1351-1361): a symlink in `path =` owned by another user is refused. The client gets `@ERROR: chdir failed`, and the daemon log gets `chdir <path> failed` (clientserver.c:692-699). oc had this walk, but `apply_privilege_restrictions_with_upstream_errors` returned early when the session neither chrooted nor dropped privileges. A rootless daemon therefore served a foreign-owned symlinked module root, on push and pull alike. The early path now runs the same walk and keeps the root's descriptor. It does not chdir (see "Working directory" below). **The destination beneath the root was not walked either.** rsync 3.5.2 enters the client's destination with the confined walk `secure_relative_dirfd()` (util1.c:1430-1446). That walk follows an in-tree relative symlink and refuses one that leaves the module with `ELOOP`, whoever owns it. `get_local_name()` then prints `change_dir#1/#2/#3 "<dest>" (in <module>) failed` and exits 3. Under `--mkpath` it prints `mkdir ... failed` and exits 11 (main.c:757-869). oc instead did a plain stat and failed later in its anchored sandbox, with either an oc-only code-11 line or a landlock `EACCES`. The receiver now walks a daemon destination beneath the module root's descriptor and prints 3.5.2's lines. **Pre-existing defect on the privileged leg.** A root daemon serving an unchrooted module with `uid =` enters the module root and served the transfer as `.`. Two renderers took the module root from that spelling: - `full_fname()` rendered a missing source as `link_stat "/d/d/a1" (in m)`. 3.5.2 prints `"/d/a1"` (util1.c:1540-1547, `p1 = curr_dir + module_dirlen`). - A relative merge-file name was not joined onto the module root. oc logged `failed to open exclude file etc/hostname`; 3.5.2 logs `<module path>/etc/hostname` (exclude.c:735-746). Both reproduce on master (c87bc25) under `sudo`. Both renderers now read one absolute module root, recorded once per session. `insecure links = yes` keeps the plain open for both the root and the tail (syscall.c:139, :433-436; util1.c:1447-1451). A chrooted module also keeps the plain chdir for the tail. ## Difference from rsync 3.5.2's process model The observable semantics are 3.5.2's, taken from its C source: - the `full_fname()` strip (util1.c:1543) - the merge-file join (exclude.c:735-746) - entering the module root before the privilege drop (clientserver.c:1063) Only the mechanism differs, in one place. A rootless unchrooted session does not change directory; it walks relative to the module root's descriptor, because oc's threaded async daemon cannot share a process working directory. - **What 3.5.2 does:** every session runs `change_dir(module_chdir, CD_NORMAL)` (clientserver.c:1063). That is safe there because each connection is its own process: `start_accept_loop()` forks per connection (socket.c:761). - **Why oc differs:** under `--features async-daemon`, oc serves sessions as threads of one process, and those threads share one working directory. A `chdir`/`fchdir` in one session would move every other session. - **What oc does instead:** a rootless session runs the same ownership walk, keeps the module root's descriptor, and resolves the client's destination beneath that descriptor. - **Privileged sessions are unchanged:** they still `fchdir` into the module root before the privilege drop, as 3.5.2 does (clientserver.c:1063 before the setgid/setuid at :1102 and :1127). A module below a directory its `uid` cannot search works only that way. - **No async session reaches that `fchdir`:** a privileged session always runs in its own forked process, because the async daemon refuses `uid`, `gid`, `use chroot` and running as root (daemon.rs, `run_async_daemon`). No new task is needed. Client-visible output is byte-identical to 3.5.2. Both renderers take the module root from its absolute path, so they print what 3.5.2 prints from its working directory: - `full_fname()` strips the module root the way util1.c:1540-1547 does (`p1 = curr_dir + module_dirlen`). - A relative merge-file name is joined onto the module root, as exclude.c:735-746 joins it onto `dirbuf`. The oracle cells compare every line against 3.5.2, in both legs and in all four client/daemon pairings. ## Changes - `transfer` `config/served_root.rs`: new `ServedRoot`. It holds the module root's absolute path, its canonical form, whether the session runs from that directory, and the root's descriptor. It is set once per connection and replaces `daemon_module_dir`. - `transfer` `full_fname.rs`: `FullFnamePaths::daemon` takes the `ServedRoot`. The module strip always uses the absolute path. A session served from its working directory roots the relative spellings first; the sender's paths and `curr_dir` are both cwd-space (`.sender()`), the receiver's `curr_dir` only. - `transfer` `receiver/dest_root.rs`: new `Entry::Confined(ModuleRoot)`; `Entry::Walked` is Unix-only, as its only constructor is. The destination is walked beneath the root's descriptor: - change_dir#1 and #3 through `open_dir_beneath` - the change_dir#2 mkdir through `create_dir_beneath` - `--mkpath` through `make_path_beneath`, whose `ELOOP` stays make_path()'s own failure (exit 11), as the relative make_path of 3.5.2 reports it (syscall.c:2306-2332) - an `ELOOP` from change_dir is the refusal that names the step - `transfer` `receiver/directory/mod.rs`: the destination root itself is stat'd through a symlink that names it. Upstream stats `.` in the directory it entered (main.c:776-781). Without this, serving the absolute path brought the opted-out data-loss bug back. - `transfer` `setup/context.rs`: `destination_entry` picks `Confined` for an unchrooted daemon module that has not opted out. The merge-name filter strips the canonical and the absolute module root. - `daemon` `module_access/transfer/sandbox.rs`: - The rootless early path walks and opens the module root with no chdir. - The privileged path pins, then fchdirs, as before. Both return the root's descriptor for the `ServedRoot`. - On a refusal it logs the walk's own notice, then `[Receiver] chdir <path> failed: <strerror> (<errno>)` in rsyserr form (clientserver.c:695). - `daemon` `orchestration.rs`, `server_config.rs`: build the `ServedRoot` and hand it to the server config. A relative merge-file name is joined onto the absolute root (exclude.c:735-746). - `daemon` `module_access/helpers.rs`: `log_pending_diagnostics` drains session diagnostics into the daemon log. It is shared with `streams.rs`, so a notice raised before the transfer reaches the log, not stderr. - `daemon` `module_access/transfer/streams.rs`: a fatal cause and its trailer are written to the daemon log before they are framed for the client. This matches upstream rwrite(), which calls logit() before sending (log.c:390-407). - A 3.5.2 client exits on the first error frame and kills its remote-shell child (cleanup.c:203-204 kill_all()). Over a remote-shell daemon, that child is the oc server, so the line never reached the log. - Measured: the cell with a 3.5.2 client and an oc daemon over a remote shell failed on that log line before this change. - `fast_io` `at_syscalls/create.rs`: `open_dir_beneath`, `create_dir_beneath` and `make_path_beneath` take the anchor descriptor. `EINVAL` for an absolute path or `..`, as at syscall.c:3477-3484. `make_path_beneath_cwd` delegates to `make_path_beneath(CWD, ...)`. The cwd-only `open_dir_beneath_cwd` and `create_dir_beneath_cwd` are removed, so there are no duplicates. ## Deviations | Case | rsync 3.5.2 | oc | |---|---|---| | Push to `mod/esc/new/`, where `esc` leaves the module | `do_mkdir()` (main.c:817) follows `esc` and **creates `outside/new`**, then `change_dir#2 "esc/new" (in mod) failed: Too many levels of symbolic links (40)`, exit 3 | Refuses before the mkdir: the same `change_dir#2` line, exit 3, **nothing created outside the module** | This deviation is owner-approved and matches #8858 and #8899. Every other cell below matches 3.5.2. ## Measured The 3.5.2 client drove a 3.5.2 daemon and an oc daemon, each with `use chroot = no` and a global `log file`. The rootless rows ran the daemon as an unprivileged user, with `flink`/`esc` owned by `nobody`. | Cell | 3.5.2 | oc before | oc after | |---|---|---|---| | root-flink (module root is a foreign symlink) | `@ERROR: chdir failed`, exit 5 | transfer through the link, exit 0 | same as 3.5.2 | | root-fmid (`flink/sub`) | exit 5 | exit 0 | same | | pull-flink | exit 5 | exit 0 | same | | root-olink (own symlink) | exit 0 | exit 0 | same | | opt-root-flink (`insecure links = yes`) | follows, exit 0 | replaced the symlink with an empty dir | same as 3.5.2 | | tail-rel (`rel -> inner`) | exit 0 | exit 0 | same | | tail-esc / tail-oesc (foreign / own escaping link) | `change_dir#1 "esc/" (in mod) ... (40)`, exit 3 | oc-only line, exit 11 | same line, exit 3 | | tail-escfile (`mod/esc/f`) | `change_dir#3 "esc" (in mod) ... (40)`, exit 3 | exit 11 | same | | tail-escmk (`--mkpath mod/esc/a/b/`) | `mkdir "esc/a/b/" (in mod) ... (40)`, exit 11 | `... Permission denied (13)`, exit 11 | same | | tail-escnew | see Deviations | `mkdir ... (13)`, exit 11 | see Deviations | | opt-tail-esc (`insecure links = yes`) | follows, exit 0 | exit 0 | same | | priv: pull missing `d/a1` (root daemon, `uid =` the user) | `link_stat "/d/a1" (in m)`, exit 23 | `link_stat "/d/d/a1" (in m)` | same as 3.5.2 | | priv: `-M--filter=. /etc/hostname` | log: `failed to open exclude file <module>/etc/hostname`, exit 11 | log: `... etc/hostname` | same as 3.5.2 | Daemon log after the change: line for line equal to 3.5.2's, apart from the program name (`oc-rsync:`) and the trailer location. That covers the untrusted-symlink notice, `[Receiver] chdir <path> failed: ...`, each `change_dir#N`/`mkdir` line with its trailer, and the merge-file line. ## Tests - `crates/cli/tests/daemon_module_change_dir.rs`. It runs each cell oc to oc and, when `OC_RSYNC_UPSTREAM_BIN_3_5_2` resolves, with a 3.5.2 client, a 3.5.2 daemon, and both. Results must be equal, except for the deviation cell, which pins oc's daemon. The cells cover: - the three refused tails (exit code, line, trailer, daemon-log line, nothing written outside) - the new-directory deviation - in-tree and opted-out links - a Linux-only foreign-owned module root: `@ERROR: chdir failed`, exit 5, nothing written, and the untrusted-symlink notice followed by the `chdir <path> failed` log line - a Linux-only opted-out foreign root (the data-loss bug): exit 0, the root is still a symlink to the same target, and the data is in the target - Linux-only privileged leg under `sudo -n`: a missing source renders `link_stat "/inner/a1" (in priv)`, and the merge file is logged as `<module>/etc/hostname`. Red against the master binary (`"/inner/inner/a1"`), green after. - Linux-only privileged module below a directory its `uid` cannot search (mode 000): push, pull and a new destination directory all exit 0 and land in the module. This pins why the privileged session keeps its working-directory entry. - The root and privileged cells need `sudo -n`. They fail rather than skip when it is unavailable. - Log-line cells compare each daemon log line byte for byte with 3.5.2's line. Only the program name is substituted (`rsync` vs `oc-rsync`), and the log stamp before `] ` is stripped. A trailer is compared up to its source location, which names each program's own file and line. - `crates/daemon/src/tests/chunks/daemon_async_push_pull.rs`: `concurrent_async_sessions_keep_their_own_module_roots_and_the_process_cwd`. Two sessions on different modules run at once in one async daemon. Each pushes 200 files and pulls a seed from its own module, and the process working directory is unchanged afterwards. Red on this PR's first head (a7ac723), where the rootless path fchdir'd: the cwd moved to `module-a`. Green on master and after. - `crates/fast_io/tests/daemon_destination_beneath_root.rs` (renamed from `..._beneath_cwd.rs`): the three walks beneath a descriptor, with no chdir. Covers the root and an in-tree link, an escape, `EINVAL`, mkdir errors, a whole `make_path`, nothing made outside, and a cell showing the anchor, not the cwd, decides where a name resolves. - `full_fname.rs` unit tests: a session served from its cwd renders the sender's `./d/a1` once below the root; the receiver roots only its `curr_dir`; a session not served from its cwd roots nothing. - Before and after: on the base sources, 4 of the 5 rootless cli cells fail. The foreign module root exits 0, the opted-out root's symlink is replaced, and the tails and the new dir exit 11 with oc's own lines. The in-tree and opted-out-tail cell passes on both, as it should. After the change all pass. - Mutations, each red on the new cells: - (a) plain open of the module root: the root cells red (measured before the cell split, 4/4) - (b) the tail follows the escaping link: only the 2 tail cells red - (c) swapped step mapping, change_dir#2 reported as #1: only the new-dir cell red - Measured locally on Linux, with `OC_RSYNC_UPSTREAM_COMPAT=1` and the 3.5.2 oracle (`cargo nextest run -p <crate> --all-features`): - cli: 3773 passed, 2 skipped - bin: 1092 passed, 29 skipped (with the 3.5.1 oracle as well) - fast_io: 1381 passed, 1 skipped - transfer: 3515 passed, 0 skipped - daemon: 2209 passed, 20 skipped - The skips are existing ones. None of the new cells skips; the root and privileged cells fail without `sudo -n`. - Gates: - fmt and `check_rustfmt_all` - workspace clippy `-D warnings` on the host and on `x86_64-pc-windows-gnu` - rustdoc `-D warnings` - `no-placeholders` - `citation_drift_audit --ratchet` ## Follow-ups - A chrooted module with a `/./` inner path (`module_dirlen > 0`). 3.5.2 confines the tail there too (util1.c:1430). oc keeps its anchored sandbox for chrooted modules, unchanged here.
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
Testing