Skip to content

fix(daemon): keep a dead name converter apart from an unknown name - #7629

Merged
oferchen merged 2 commits into
masterfrom
fix/daemon-name-converter-fail-closed
Sep 2, 2026
Merged

oferchen merged 2 commits into
masterfrom
fix/daemon-name-converter-fail-closed

Conversation

@oferchen

@oferchen oferchen commented Sep 2, 2026 •

Copy link
Copy Markdown
Owner

Residuals from the daemon name-converter work (task 751), following the request-side newline-injection fix in #7346.

What was wrong

NameConverter::query() returned Option<String>. Five situations arrived at the caller as one None:

situation upstream (namecvt_call, clientserver.c:1311) oc before
a usable answer True (:1355-1359) Some(line)
an empty answer False (:1345-1346) None
a malformed id answer False (:1347-1354) None
a control byte in the name FERROR + False (:1317-1319), nothing written None
a request too long to frame exit_cleanup(RERR_UNSUPPORTED) (:1324-1327) None
a failed write to the converter exit_cleanup(RERR_SOCKETIO) (:1329-1334) None
the converter closed its answer pipe False (:1336-1337), then the next request's write exits at :1333 None

Upstream gets away with a bare BOOL because the two fatal rows never return. False therefore only ever means "the converter answered, and the answer is no id". Merging the fatal rows into it fails open: a daemon module configures name converter to take ownership decisions away from the peer, and a converter that has died then reports every name as unresolved - at which point recv_add_id() (uidlist.c:273-282) keeps the sender's numeric id for each one.

What changed

The four outcomes are a type. ConverterOutcome<T> = Resolved / Unknown / Refused / Failed(io::Error), returned by NameConverterCallbacks, with each arm carrying its upstream citation. The converter's own liveness is in its type too: the pipes are a Result<ConverterStream, ConverterDeath>, so a stream that has broken cannot be spoken to again and reported as "no such name".

Fail closed at the lookup API. LookupError splits Database from Converter, because upstream treats them differently - a getpwnam() that yields nothing is "no id" (uidlist.c:160-163), a converter failure ends the session. no_id_unless_converter_failed() is that asymmetry written once; the call sites that used .ok().flatten() now go through it, and IdList::read()'s resolver became fallible so the receiver's name-to-id pass propagates a converter failure instead of keeping the sender's ids.

Empty-name guard on the non-Unix lookups (uidlist.c:146-147, :172-173), where upstream decides an empty name before consulting any back end.

Refuted / corrected

  • The empty-name guard was already present on the Unix path (nss.rs) and is not new here. What was missing is the non-Unix half - and, more usefully, its Unix test could not see the guard: it installed a converter that answered "unknown", so lookup_user_by_name(b"") returned None whether or not the guard existed. Removing the guard did not redden it. The test now installs a converter that fails every query, which makes reaching the converter observable; both halves are now mutation-killed.
  • An empty answer to an id-to-name query stays "unknown" here, where upstream strdup("")s it (clientserver.c:1357). The two are wire-equivalent (an empty name is written with length 0 and read back as no name), and "unknown" is the arm the CVE-2026-53798 fix asks for.

Mutation results

Each production change was reverted individually; passed + failed == run on every row, so no kill list was truncated.

mutation result
Failed maps to Ok(None) in into_lookup 4 tests RED
converter EOF reads as an empty answer 2 RED
the recorded death is not stored (stream retried) 1 RED
an over-long request reads as Unknown 1 RED
an empty answer reads as a transport failure 3 RED
the control-byte guard is removed 2 RED
IdList::read swallows the resolver's error 1 RED
the receiver call site tolerates every failure 1 RED
no_id_unless_converter_failed tolerates the converter too 4 RED
the Unix empty-name guard is removed (user half) 1 RED
the Unix empty-name guard is removed (group half) 1 RED
the non-Unix empty-name guard is removed not killable on macOS - nss_stub is cfg(not(unix)); its test runs in the Windows job

Baseline after every revert: 39/39 green.

Verification

Rebased onto master 023b695fa; head 22921f56b. Every number below was measured on that head, not on the original base.

  • cargo fmt --all -- --check: exit 0.
  • cargo nextest run -p metadata -p protocol -p daemon -p transfer -p batch: 11395 passed, 0 failed.
  • cargo nextest run --workspace: 32597 run, 32595 passed, 2 failed - neither in a crate this branch touches:
    • xtask ... backdated_tree_populates_and_backdates_the_root shells out to touch -d @epoch, a GNU-ism BSD touch rejects, so it fails on macOS regardless of this branch.
    • bandwidth limiter::tests::convergence::debt_decreases_toward_zero_over_steady_state is a timing convergence assertion; it passes 3/3 in isolation, and this branch changes zero files in crates/bandwidth.
    • Across the three full runs on successive rebases the failing set rotated (engine execute_sparse_with_multiple_hole_patterns, core run_client_sparse_copy_creates_holes, then this one), each passing on isolated re-run and each in a crate outside this diff - host noise, not a footprint.
  • cargo clippy --locked --workspace --all-targets --all-features --no-deps: exit 0, 0 errors. The collapsible_if warnings in touched files (idlist/mod.rs:222, name_cache.rs:60/87, nss.rs:301) all sit outside this diff's hunks.
  • python3 tools/ci/citation_drift_audit.py --ratchet (the gate strengthened by fix(sender): skip a directory operand when xfer_dirs is off #7627): ratchet OK. This branch adds 9 citations to the scanned population (5263 vs master's 5254) and 0 new suspected-drift findings (374 on both). The advisory transfer improved 6 -> 4; lower the baseline note reproduces on pristine master, so it is pre-existing baseline slack, not this branch's doing.
  • cargo check --target x86_64-pc-windows-gnu -p metadata -p daemon -p transfer -p batch (incl. --all-targets for metadata) clean, since the non-Unix lookups and the Windows converter both changed shape.
  • Mutation kills re-verified on the rebased heads: into_lookup 4 RED, eof_unknown 2, not_sticky 1, idlist_swallow 1, receiver_tolerates 1, nss_empty_name 1; baseline 39/39 after every revert, and passed + failed == run on every row.

Rebase collision check

86a549bbf (#7612) restructured the resumable walk and collapsed the parallel NDX fields into NdxMap, touching two files this branch also touches. The rebase replayed with no conflict and the overlap is genuinely disjoint: master's edits are in assign_hardlink_indices / send_file_list's sub-list push, this branch's in collect_id_mappings / collect_acl_id_mappings. Both survive in the rebased tree (ndx_map.first_ndx_start() still at hardlinks.rs:40 and protocol_io.rs:747); the restructure added no new callers of the two functions whose signature changed, and no new IdList::read call sites. Master carries none of this work (git grep for ConverterOutcome|LookupError|no_id_unless_converter_failed|ConverterDeath on origin/master is empty, and master's query() still returns Option<String>), so nothing here regresses it.

Known residuals (not addressed here)

  • Upstream prints invalid name-converter token: %s to FERROR (clientserver.c:1318); the Refused arm here is silent, because the converter holds no log sink. Routing one in is a separate change.
  • id_lookup::cache::map_uid_uncached() and the --usermap/--groupmap ACL mappers still fold a lookup error into "keep the id". They run after the id-list pass that now aborts, so a dead converter no longer reaches them, but they are not themselves fail-closed.
  • engine/src/local_copy/executor/directory/recursive/batch.rs:98,103 still uses .ok().flatten(). That is the local-copy executor, where no name converter is ever installed (only the daemon session thread installs one), so it stays tolerant by construction rather than by oversight.

@github-actions github-actions Bot added the bug Something isn't working label Sep 2, 2026
@oferchen
oferchen force-pushed the fix/daemon-name-converter-fail-closed branch 2 times, most recently from 3cb5870 to 9ad6c29 Compare September 2, 2026 15:07
The daemon's `name converter` query returned `Option<String>`, so five
situations reached the caller as the same `None`: a usable answer's absence,
an empty answer, a name refused for carrying a control byte, a request too
long to frame, and a converter whose request/answer stream had broken.
Upstream can afford a bare `BOOL` because two of those never return -
`namecvt_call()` calls `exit_cleanup(RERR_UNSUPPORTED)` on an over-long
request (clientserver.c:1324-1327) and `exit_cleanup(RERR_SOCKETIO)` on a
failed write (:1329-1334) - so its `False` only ever means "the converter
answered, and the answer is no id" (:1317-1319, :1345-1354).

Merging those two classes fails open. An operator configures `name converter`
precisely to take ownership decisions away from the peer; a converter that has
died then reports every name as unresolved, and uidlist.c:273-282 keeps the
SENDER's numeric id for each one - silently restoring the mapping the
directive exists to prevent.

Model the four outcomes instead of the sentinel:

  Resolved(v)  a usable answer                clientserver.c:1355-1359 True
  Unknown      an empty or malformed answer   clientserver.c:1345-1354 False
  Refused      a control byte in the name     clientserver.c:1317-1319 False
  Failed(err)  over-long request / dead pipe  clientserver.c:1326, :1333 exit

`ConverterOutcome` carries them out of `NameConverterCallbacks`, and the
converter's own liveness lives in its type - the pipes are a
`Result<ConverterStream, ConverterDeath>`, so a stream that has broken cannot
be spoken to again and reported as "no such name". `LookupError` then keeps
the two back ends' failures apart at the lookup API, because upstream treats
them differently: a `getpwnam()` that yields nothing is "no id"
(uidlist.c:160-163), a converter failure ends the session. Callers that used
to write `.ok().flatten()` go through `no_id_unless_converter_failed()`, which
is that asymmetry written once, and `IdList::read()`'s resolver became
fallible so the receiver's name-to-id pass propagates it.

Also add the empty-name guard to the non-Unix lookups (uidlist.c:146-147,
:172-173), where upstream decides an empty name before consulting any back
end; the Unix half already had it, but its test used a converter that answered
"unknown" and so passed with the guard removed. It now uses one that fails
every query, which makes reaching the converter observable.
@oferchen
oferchen force-pushed the fix/daemon-name-converter-fail-closed branch from 9ad6c29 to 22921f5 Compare September 2, 2026 15:42
@oferchen
oferchen merged commit 7a82dea into master Sep 2, 2026
73 checks passed
@oferchen
oferchen deleted the fix/daemon-name-converter-fail-closed branch September 2, 2026 20:31
oferchen added a commit that referenced this pull request Sep 2, 2026
… merged PRs (#7634)

* docs(rustdoc): reach the public items rustdoc could not see, and gate the class

Two halves of the same question - is what a public item says actually reachable
from `cargo doc`?

Half 1: seven `//` comment blocks documented a `pub` item, so their text never
reached the generated docs. Found positionally, not by content: a `//` run whose
next non-attribute line declares a `pub` item. A census keyed on comment CONTENT
is false-positive dominated; this one is mechanical.

Nine sites matched; two are DELIBERATELY left as `//`, because they document the
`#[cfg_attr]` / `#[allow]` attribute directly beneath them rather than the item -
`local_copy/overrides.rs` and `local_copy/plan/report.rs`. Promoting those would
attach a lint rationale to a public surface as if it described the surface.

Text is preserved verbatim, upstream citations included (`generator.c:2149` on
the obstacle module). The only rewrite is `socket_options/consts.rs`, where one
group note covered two constants: split per item, matching the file's own house
style where every other const already carries `///`.

Half 2: five intra-doc links could not resolve in a DEFAULT build, and the
existing gate is structurally unable to see them.

  crates/fast_io/src/lib.rs, ewma.rs (x4)  -> `adaptive_dispatch`, gated by the
                                              off-by-default
                                              `adaptive-basis-dispatch` feature
  crates/rsync_io/.../sync_bridge.rs       -> `crate::channel_adapter`, gated by
                                              the off-by-default `async-ssh`
                                              feature
  crates/fast_io/src/confinement.rs        -> `PinnedRoot`, a PRIVATE struct

plus one already on the branch in `module_list/types.rs`, where the link was
`Transport::Quic` (the `quic` feature) and its surrounding prose still described
the variant as unbuilt.

Every crate denies `rustdoc::broken_intra_doc_links`, so each of these is a hard
`cargo doc` failure, not a warning. MEASURED on the pristine base:

    cargo doc --no-deps --workspace   ->  7 errors, `fast_io` and `rsync_io`
                                          could not be documented
    cargo doc --no-deps --workspace --all-features  ->  clean

That gap is the whole point. Under `--all-features` the gated items EXIST, so
the link resolves and the gate is green; in a default build the item is not
compiled at all. `ci.yml`'s `rustdoc-links` job runs only `--all-features`,
deliberately mirroring `pages.yml` - which is right for the question Pages asks
and cannot ask this one. So the fix is paired with a SECOND step on default
features, and neither subsumes the other: `crates/fast_io/src/io_uring` is
`cfg(all(target_os = "linux", feature = "io_uring"))` and only the all-features
run compiles it.

The names stay in backticks with the reason stated at each site, rather than
being deleted or the links made conditional - the prose still says what it said,
and the next reader learns why it is not a link.

After: both invocations document all 25 crates cleanly, 0 errors. fmt clean;
clippy on the five touched crates reports no new diagnostics.

* docs(changelog): record the ten pull requests merged since the last sweep

#7624 brought the Unreleased section up to #7620 and then stopped being true:
#7621-#7632 landed after it, of which #7624 is itself that changelog pass and
#7628 was never merged. Ten entries were missing.

Each is placed in the subsection its change belongs to rather than appended in
number order, and #7625 is SPLIT across two, because it is two changes: wiring
`--force` is a receiver fix, and the synthetic-transfer-root guard that wiring
made necessary is a peer-supplied input bound. Filing it once under either
heading would have hidden whichever half the reader was looking for.

  Security / peer-supplied input bounds   #7625 (guard half), #7630
  Fixed / transfer and receiver           #7622, #7625 (--force half), #7627
  Fixed / daemon                          #7629
  Testing and CI                          #7621, #7623, #7632
  Documentation                           #7626, #7631

Wording is taken from each merge commit's own body, not from its title - the
titles compress away the part a reader needs. #7629's title says "keep a dead
name converter apart from an unknown name"; what makes it worth an entry is that
five outcomes collapsed into one `None` and the merge failed OPEN on exactly the
mechanism an operator installs to take ownership decisions away from the peer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant