Repository navigation
fix(daemon): bound the client argument vector and stop logging it verbatim - #7633
Merged
Merged
Conversation
…batim Two coupled defects on the daemon's post-`@RSYNCD: OK` argument read. 1. No MAX_DAEMON_ARGS ceiling. Upstream bounds the argument vector a daemon module connection may send: `MAX_DAEMON_ARGS (MAX_ARGS * 16)` at io.c:1452 over `MAX_ARGS 1000` at rsync.h:202, enforced per read line at io.c:1476-1479 with `rprintf(FERROR, "too many daemon arguments\n")` and `exit_cleanup(RERR_PROTOCOL)`. oc had no such bound at either phase, so a client could make the daemon accumulate an unbounded argument vector before a single argument was parsed. The ceiling reaches the reader as a caller-supplied `Option<usize>` rather than a constant, mirroring upstream's gate: `read_args()` applies it only under `if (mod_name && ...)`, so the rsh/server argument read is deliberately unbounded on both implementations. `crates/cli/src/frontend/server/run.rs` passes `None` for exactly that reason and says so. 2. The daemon wrote every client argument token verbatim into the log file. Upstream never logs the argument vector at all. Echoing it made a connection a log-amplification primitive: every byte a peer sent before authentication was appended to the operator's log, and neither the token count nor the per-token length was under the daemon's control. The ceiling in (1) bounds the count but not the total bytes, so it does not close this on its own - the payload had to go. The line now reports the argument COUNT, which is daemon-derived, bounded by construction, and still lets an operator correlate a connection with a refusal. Each half carries its own pin, and each pin has a non-vacuity companion: the refusal tests would otherwise also pass if the readers had simply stopped working. The protocol companion feeds the SAME oversized wire through an unbounded read and asserts it is accepted, which pins the deliberate rsh/server divergence rather than leaving it as an unstated asymmetry.
oferchen
added a commit
that referenced
this pull request
Sep 3, 2026
…use, and a pre-mangled log operand (#7639) * fix(docs): stop linking a cfg-gated type from an always-rendered module doc `rustdoc links (informational)` has been red on master, reporting exactly two errors, both at crates/fast_io/src/io_uring/mod.rs:117 - the `///` comment on `pub mod send_zc;`: error: unresolved link to `ZeroCopySender` error: unresolved link to `ZeroCopySender::send_zc` Two things combine to produce them, and neither is visible on its own. `ZeroCopySender` is `#[cfg(feature = "iouring-send-zc")]` at BOTH the struct (send_zc.rs:320) and the re-export (mod.rs:166), so in a DEFAULT build the type does not exist and no path can resolve to it. Separately, `pub mod send_zc;` carries a `///` comment, and rustdoc concatenates that with the module's own `//!` block and resolves the result in the OUTER module's scope - which is why the errors are reported against mod.rs:117 rather than against the `//!` lines in send_zc.rs that actually contain them. crates/logging-sink/src/escape.rs documents this same concatenation trap in its own header. Both links become plain code spans. The prose already said the type is exposed "when the `iouring-send-zc` cargo feature is enabled", so nothing is lost: a link that cannot resolve in the configuration the doc gate actually builds is not carrying the reader anywhere. An `--all-features` doc build cannot see either half of this, which is how the broken link reached master in the first place - the note now says so at the site, so the next reader does not "fix" it back into a link. Verified: `RUSTDOCFLAGS="-D warnings" cargo doc -p fast_io --no-deps` on a default build is clean. The red baseline is CI's own two errors at this exact file and line. * test(daemon): pin the dead-converter cause as STICKY, not as one errno `a_dead_converter_fails_instead_of_answering_unknown` is the first of the two tests that turned master red: it appeared at ed5a38b (#7627, an unrelated sender diff), one commit after the run at 7a82dea that was green, and it failed on all three nextest retries with assertion `left == right` failed: the recorded cause must be reported, not a fresh one: name converter: writing the request: Broken pipe (os error 32) left: BrokenPipe right: UnexpectedEof The assertion pinned `UnexpectedEof` as the recorded cause. Which cause gets recorded is a RACE, and both arms are legitimate: the child is `exit 0`, so if it has already exited and closed the pipe when the first lookup runs, the request WRITE fails with EPIPE and BrokenPipe becomes the sticky cause; if it has not yet exited, the write lands and the answer READ hits EOF, recording UnexpectedEof. Neither outcome is a defect - the host just decides which one wins. What the test exists for is the property one line below it in its own comment: that the death is RECORDED and REPLAYED rather than the stream being spoken to again. That property is orthogonal to which errno won the race, so the test now captures whichever cause the first failure recorded and asserts the later lookup reports THAT, plus a bound that the cause came from the pipe at all (`UnexpectedEof | BrokenPipe`) rather than some unrelated error. This deliberately keeps two assertions rather than deleting the errno check: without the pipe-cause bound, a converter that failed for a completely different reason would satisfy "sticky" trivially. daemon --lib name_converter_tests: 16/16. * fix(daemon): stop pre-mangling peer bytes at the log call sites `daemon_log_file_escaping` is the second of the two tests that turned master red. It failed at its own non-vacuity guard, not at an assertion: PR #7633 stopped writing the client's argument vector to the daemon log - correctly, since upstream never writes it at all - and that vector was the test's only subject. With nothing peer-supplied left in the log, every later assertion would have passed vacuously, and the guard said so. Re-pointing the test at a vector oc does log measured a real divergence. Upstream escapes in the SINK. `logit()` is the only writer of `logfile_fp` and hands every line to `filtered_fwrite(logfile_fp, buf, len, 0, 1, trailing)` (log.c:126-132), so no call site needs to pre-clean its operands and none of upstream's do: `clientserver.c:787` passes the module name straight into `rprintf(FLOG, "rsync %s %s from %s@%s (%s)\n", ...)`. oc ports that `filtered_fwrite` faithfully in `crates/logging-sink/src/escape.rs`. But seven of oc's daemon log builders wrapped the module name in `sanitize_module_identifier` first, which replaces every control character with `?`. Measured on a module named `A<ESC>B`, requested over a raw @rsyncd handshake, master writes BOTH renderings into the SAME log file: rsync allowed access on module A?B from localhost (127.0.0.1) module 'A\#033B' from localhost (127.0.0.1): 0 client args The second line is already correct - `client_args_log_line` does not sanitise, so the sink escapes reversibly. The first is lossy: `?` cannot be undone, and a reader cannot tell an escaped byte from a literal question mark. Two builders naming the same peer string in the same file disagreed about what it says. The sanitiser call is removed from all seven builders. It is deliberately KEPT on the wire `@ERROR` reply path, which is a different sink with no escaping layer of its own; that is a separate decision and is not touched here. The doc on `log_module_refused_option` claimed the name was "sanitised to strip control chars" - true when written, false after this change - so it now says the sink escapes it. Leaving it would have been exactly the drift this repo keeps getting bitten by. The test moves onto the module name as its vector and asserts three things: the escaped form is present, the mangled form is absent, and no raw ESC byte reached the file. The already-correct client-args line is the in-run control that proves the sink works and the fixture is live, alongside a plain-named control module. Its header records what is NOT covered: an unresolvable module name, which upstream also logs (clientserver.c:1568) but oc cannot, because it opens a log sink only per resolved module. That is a real separate gap, filed rather than faked. RED/GREEN proven by restoring the sanitiser calls: the test fails on the mangled-form assertion, printing both disagreeing lines. daemon 1800/1800; daemon + log-file sweep 82/82; fmt clean.
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.
Two coupled defects on the daemon's post-
@RSYNCD: OKargument read. Task 820 RC-2 asked for both in one commit, each with its own pin.1. No
MAX_DAEMON_ARGSceilingUpstream bounds the argument vector a daemon module connection may send:
oc had no such bound at either phase, so a client could make the daemon accumulate an unbounded argument vector before a single argument was parsed. Zero hits for
MAX_ARGS/MAX_DAEMON_ARGSanywhere incrates/beforehand.The ceiling reaches the reader as a caller-supplied
Option<usize>rather than a constant, because that mirrors upstream's own gate:read_args()applies it only underif (mod_name && ...), so the rsh/server argument read is deliberately unbounded on both implementations.recv_secluded_argshas exactly two production callers and they sit on opposite sides of that split —crates/cli/src/frontend/server/run.rspassesNoneand says why.2. The daemon logged every client argument verbatim
Upstream never writes the argument vector to the daemon log at all. Echoing it made a connection a log-amplification primitive: every byte a peer sent before authentication was appended to the operator's log file, and neither the token count nor the per-token length was under the daemon's control.
The ceiling in (1) bounds the count but not the total bytes — there is no per-argument length cap — so it does not close this on its own; the payload had to go. The line now reports the argument count, which is daemon-derived, bounded by construction, and still lets an operator correlate a connection with a refusal.
Pins
Each half carries its own pin, and each pin has a non-vacuity companion, since a refusal test would otherwise also pass if the reader had simply stopped working.
max_argscheck inrecv_secluded_argsa_daemon_bound_refuses_a_vector_past_max_daemon_argsFAILS, other 6 greenread_client_argumentsread_client_arguments_refuses_past_the_daemon_ceilingFAILS, other 6 greenclient_args.join(" ")in the log lineThe protocol companion feeds the same oversized wire through an unbounded read and asserts it is accepted, which pins the deliberate rsh/server divergence rather than leaving it as an unstated asymmetry.
Verification
cargo fmt --all -- --checkclean.cargo nextest run -p protocol -p daemon -p cli: 11656 run, 11655 passed. The single failure istransfer_request_with_sparse_preserves_holes, proven inherited by running it in a detached worktree at the pristine base029c2c53b— it fails there identically (APFS sparse-block accounting), and this diff touches nothing on the sparse or copy path.