Skip to content

test(daemon): provoke the session error with a non-UTF-8 request line - #7615

Merged
oferchen merged 1 commit into
masterfrom
fix/daemon-session-error-provoker
Sep 2, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/daemon-session-error-provoker

Conversation

@oferchen

@oferchen oferchen commented Sep 1, 2026 •

Copy link
Copy Markdown
Owner

session_error_does_not_stop_the_accept_loop fails on master, and on every open PR whose base carries both of the commits below. It is not caused by any one PR.

Mechanism

run_provoker sends the version banner twice in one write:

@RSYNCD: 32.0 md5 md4\n@RSYNCD: 32.0 md5 md4\n

Line 2 was meant to re-drive Greeting -> ModuleSelect from ModuleSelect and be refused by the FSM, producing the session error the test needs.

The daemon no longer refuses it. session_runtime.rs deliberately treats a second banner as a module name:

// upstream: clientserver.c:1534-1538 start_daemon() - the version line is read
// exactly once, by exchange_protocols(); the very next read_line_old() is the
// request line whatever it contains. A second `@RSYNCD:` banner is therefore a
// module name, not a re-greeting, and falls through to the unknown-module
// refusal. Taking the Greeting -> ModuleSelect edge again instead would fail the
// FSM's ordering check, and a session error is fatal to the whole listener
// (workers.rs join_worker), so a peer could end the daemon with two greeting lines.
Ok(LegacyDaemonMessage::Version(_)) => {}

So the daemon answers @ERROR: Unknown module '@RSYNCD: 32.0 md5 md4' — exactly the string the failing assertion reports.

Why it landed green

commit PR merged
34b49e9cd the fallthrough arm #7579 2026-09-01 14:09
7e2d9391a the test #7590 2026-09-01 16:39

The arm merged first, but #7590's tested head (53d155c07) does not contain it — verified with git merge-base --is-ancestor. Up-to-date-branch enforcement is off, so the test was validated against a master that still refused the repeated banner. Two individually-correct commits, never run together until both were on master.

What this changes

The arm is upstream-faithful and security-motivated — restoring the FSM rejection would revert #7579 and re-open the DoS its comment names. It stays.

Instead the provoker is re-pointed at an error the daemon still raises: a non-UTF-8 request line. The daemon reads it with BufRead::read_line into a String, which fails with InvalidData. That is not a connection-closed kind, so report_session_failure (workers.rs:82) logs it rather than treating it as a normal close — and the accept loop must still serve the second client, which is the property under test.

The module and helper docs now say why a repeated banner cannot be the provoker, so this does not get re-introduced.

The guard did its job

The assertion that fires is the fixture's own non-vacuity check, whose comment predicted this exactly:

"If the daemon ever starts answering a repeated banner cleanly this fixture stops provoking anything, and the property above would pass while proving nothing - so fail loudly here instead."

Without it the transfer assertions would still have passed and the test would have gone quietly inert. It is kept unchanged; only the log assertion is re-pointed at the new cause.

Verification

  • RED on pristine master (macOS, local): first client must be dropped mid-session, not answered; got ["@ERROR: Unknown module '@RSYNCD: 32.0 md5 md4'"] — the CI failure reproduced locally, independent of CI.
  • GREEN after: 1 test run: 1 passed.
  • Mutation-lethal: replacing the non-UTF-8 bytes with a valid-UTF-8 module name reddens it again (got ["@ERROR: Unknown module 'nosuchmodule'"]), so the fixture genuinely depends on the non-UTF-8 byte rather than passing for free.
  • cargo fmt --all -- --check clean. Test-only change, 1 file, +21/-11.

Blast radius

Measured across the open set, these carry both commits and are affected: #7614, #7613, #7612, #7611, #7607, #7598, #7588. Only #7588's feature-flag cells had finished at diagnosis time; #7611 and #7598 had them still in flight. No PR anywhere shows SUCCESS on those cells while carrying both commits.

⚠ nextest fail-fast truncated the CI runs, so one failing test there is a lower bound, not the failure set.

`session_error_does_not_stop_the_accept_loop` fails on master. The fixture
provoked its session error by sending the `@RSYNCD:` version banner twice,
relying on the second banner re-driving `Greeting -> ModuleSelect` from
`ModuleSelect` and being refused by the connection FSM.

The daemon no longer refuses it. `session_runtime.rs` deliberately treats a
second banner as a module name, citing clientserver.c:1534-1538: upstream reads
the version line exactly once, and the next line is the request whatever it
contains. Its comment states the reason - taking the FSM edge again would be a
session error, and a session error is fatal to the whole listener, so a peer
could end the daemon with two greeting lines. That arm is correct and stays.

The two commits are individually right and mutually contradictory. The arm
merged at 14:09 and the test at 16:39 the same day, but the test's branch was
never rebased onto the arm, so the two never ran together until both were on
master.

Re-point the provoker at an error the daemon still raises: a request line that
is not valid UTF-8. The daemon reads it with `BufRead::read_line` into a
`String`, which fails with `InvalidData`. That is not a connection-closed kind,
so `report_session_failure` logs it rather than treating it as a normal close,
and the accept loop must still serve the second client.

The failing assertion was the fixture's own non-vacuity guard, whose comment
predicted exactly this ("if the daemon ever starts answering a repeated banner
cleanly this fixture stops provoking anything"). It is kept as-is, and the log
assertion now names the new cause so a future divergence fails loudly instead
of passing while proving nothing.

Verified on macOS: RED on pristine master with the reported assertion, GREEN
after. Mutation-proven - restoring a valid-UTF-8 request line reddens it again
(`got ["@error: Unknown module 'nosuchmodule'"]`), so the fixture genuinely
depends on the non-UTF-8 byte.
@oferchen

oferchen commented Sep 1, 2026

Copy link
Copy Markdown
Owner Author

Correction to my own blast-radius claim: it is every open PR, not the seven I listed.

I earlier classified affected PRs by whether their head carries both 34b49e9cd (the arm) and 7e2d9391a (the test), and named seven. That predicate is wrong, and #7594 refutes it directly:

7594 head  d597376646e0b62ec41df13ae3e4e75e0607afa7  -> does NOT carry the test
7594 CI    Linux musl (stable) FAILS session_error_does_not_stop_the_accept_loop:169

A head that does not contain the test cannot fail it — unless the tested tree is not the head. It is not:

git fetch origin refs/pull/7594/merge
git merge-base --is-ancestor 7e2d9391a FETCH_HEAD   ->  MERGE ref CARRIES the test

pull_request CI builds merge(head, base), so every open PR compiles master's current content, arm and test included, whatever its own branch holds. The correct statement is therefore: every open PR hits this once its CI runs, and rebasing is not what exposes it.

The cell set is also wider than the two I named. Linux musl (stable) fails the same test on both #7594 and #7588 — same test, same line, same assertion. Any cell that runs the root integration tests reaches it, not just the two Feature flag combinations cells I happened to see first.

Both corrections make the case for the fix stronger, not weaker: the mechanism, the root cause and the fix in #7615 are unchanged — only my estimate of who is affected was too narrow.

@oferchen

oferchen commented Sep 1, 2026

Copy link
Copy Markdown
Owner Author

Independently reproduced and verified on macOS (aarch64, stable), against master fdf83bd26.

RED on master, before this PR:

test session_error_does_not_stop_the_accept_loop ... FAILED
panicked at tests/daemon_session_error_keeps_listener.rs:169:5:
first client must be dropped mid-session, not answered;
got ["@ERROR: Unknown module '@RSYNCD: 32.0 md5 md4'"]

GREEN with only this PR's test file applied, production code untouched at master:

test session_error_does_not_stop_the_accept_loop ... ok
test result: ok. 1 passed; 0 failed

Two things this adds beyond the write-up:

  1. It confirms the change is genuinely test-only. I applied just tests/daemon_session_error_keeps_listener.rs from this branch onto unmodified master (git checkout FETCH_HEAD -- <that one file>, +21/-11, no other path) and the cell went green. So nothing here alters daemon behaviour — it corrects a fixture that stopped provoking.

  2. The failure is the test's own non-vacuity guard firing correctly, not a regression. The assertion at :169 exists precisely to fail loudly if the daemon ever starts answering a repeated banner cleanly, because at that point the property above it would pass while proving nothing. That is exactly what happened: the daemon consumed banner line 2 as the module name and replied @ERROR: Unknown module, which is upstream's own read of clientserver.c — the version line is read once, and the next line is the request whatever it contains. The fixture, not the daemon, is what needed fixing.

Worth stating plainly for anyone triaging the board: this is not "master is broken and #7579/#7590 are contradictory." Both landed commits are individually correct; the test fixture simply lost its ability to provoke once the daemon's banner handling became upstream-faithful. Merging this restores real signal to the cell rather than suppressing it.

⚠ One caveat on my verification: macOS only, and the daemon cell is Linux-relevant too. It establishes the fixture logic is right; it does not substitute for the Linux cells in this PR's own run.

@github-actions github-actions Bot added the test label Sep 1, 2026
@oferchen
oferchen merged commit b32e4de into master Sep 2, 2026
69 of 71 checks passed
@oferchen
oferchen deleted the fix/daemon-session-error-provoker branch September 2, 2026 02:16
oferchen added a commit that referenced this pull request Sep 2, 2026
#7620)

`session_error_does_not_stop_the_accept_loop` fails on every Linux cell of
every open PR, and its assertion discards the evidence needed to diagnose it:

    first client must be dropped mid-session, not answered;
    got ["@error: Unknown module '@rsyncd: 32.0 md5 md4'"]

That names the symptom - the daemon answered the client's VERSION line as if
it were the module request - and then throws away everything that identifies
which line the daemon read first: the greeting the provoker actually received,
the daemon's own log, and both peers' results. The assertion two blocks above
it already carries `log_contents`; this one, the one that actually fires, does
not.

It is not deterministic. #7615's own `nextest (stable)` was SUCCESS on this
exact merge commit, and it fails on other PRs' merge commits with the same
base - so it is a flake that reproduces only in CI. 65 local runs across five
regimes on an aarch64 Linux host all pass: 3x alone (default features), 6x
alone (--all-features), the parallel package run, 24-way concurrent, and
32-way pinned to a single CPU. No x86_64 Linux host is reachable to run the
real cell (`--workspace --all-features`, 33482 tests), so the next CI failure
is the only instrument available - and it has to carry more than it does now.

Two changes, both test-only:

1. `run_provoker` returns a named `ProvokerOutcome { greeting, trailing }`
   instead of a bare `Vec<String>`. The greeting was read and dropped; it is
   the control for "did the daemon speak first at all", which is precisely the
   question the failure raises.

2. The non-vacuity assertion reports the greeting, the trailing lines, both
   results and the daemon log.

Nothing about the property under test moves: the same condition is asserted on
the same value.

Verified: the diagnostic is non-vacuous - mutating the predicate to `false`
makes it fire and print the greeting (`@RSYNCD: 32.0 sha512 sha256 sha1 md5
md4`), both results, and the full daemon log including the
`failed to serve legacy handshake ... stream did not contain valid UTF-8`
line. Restored, re-run, green. `rustfmt --edition 2024 --check` clean.
oferchen added a commit that referenced this pull request Sep 2, 2026
`## [Unreleased]` last covered the #7304-#7522 era. Measured against the 60
most recently merged pull requests, 44 were absent; of the most recent 45,
43 were absent. Nothing from #7574 onward was recorded at all.

Each entry is derived from what the pull request actually landed - the merge
commit and the body - not from its title. Three cases where those differ:

  * #7616 ships far more than the doc-alias correction its body describes:
    the `upstream_version` pin moves to 3.5.0 and `--version` starts naming
    `quic`, `sd-notify`, `vmsplice` and `send_zc`.
  * #7618 also adds the pull-request rustdoc-link job its body says was
    filed separately, which is what closes the master-only-gate recurrence.
  * #7602's squash carries the closed #7597 as its first commit, so the
    directory-obstacle half is recorded under #7602.

#7587 is deliberately not recorded. Its merge commit is empty: the change
had already landed as #7563, which the section already names.

Entries extend the existing Keep a Changelog groups and the bold
sub-groupings. Clusters that are one story carry one entry with several
references: the FERROR_XFER routing and its two-phase drain (#7576, #7581),
the connection-FSM close edge and the accept loop that outlives a session
error (#7579, #7590), the three detaching daemon suites (#7578, #7588,
#7592), the io_uring and SEND_ZC work (#7593, #7600, #7610), the citation
retargets (#7601, #7603, #7604), and the accept-loop pin flake (#7615,
#7620).

Only `## [Unreleased]` is touched; every released section, including the
3.4.4 statements that were correct when written, is byte-identical.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant