Repository navigation
fix(daemon): open the lock file through the ownership walk at mode 0600 - #7439
Merged
Merged
Conversation
`lock file = PATH` is named by the operator in oc-rsyncd.conf, and the
daemon opens it as whatever user it runs as - typically root, and before
the per-module privilege drop. Both opens went straight to
`OpenOptions`, so a symlink planted at any component redirected a
privileged `O_CREAT` open to a file the operator never named. The leaf
need not exist yet, so a leaf-only `O_NOFOLLOW` could not have rejected
it either.
Upstream closes this with the same primitive it uses for every other
operator-named auxiliary file:
connection.c:35 open_no_attacker_symlinks(fname, O_RDWR|O_CREAT, 0600)
oc already had that walk in `fast_io::owner_walk` and already routed the
daemon config, motd, secrets file, --password-file, --log-file and both
merge-file parsers onto it. The lock file was the one daemon aux-file
open left on a bare path, because no existing helper opened
`O_RDWR|O_CREAT` - so this adds `operator_open_rw_create` alongside the
existing read and append variants, all three delegating to the same
private `operator_open_with`.
The mode is upstream's, not incidental. `OpenOptions::create(true)`
requests 0666, which lands on 0644 under the common 022 umask, leaving a
shared lock file world-readable on a daemon with a permissive umask.
Upstream passes 0600 explicitly.
Two behaviour notes, both deliberate:
- The reopen per claim now carries `O_CREAT`, matching upstream's single
`O_RDWR|O_CREAT` per `claim_connection()`. Previously a lock file
removed after startup made every later claim fail; upstream recreates
it. It also removes a second unguarded path resolution.
- That change invalidated the DETECTOR in
`negative_max_connections_still_opens_the_lock_file_first`, not its
claim. The test proves a disabled module does not short-circuit ahead
of the open, and it detected the open by deleting the lock file. With
`O_CREAT` a missing file is no longer an error, so the detector is now
a DIRECTORY at the lock path, which fails EISDIR even with `O_CREAT`.
The assertion it makes is unchanged; only the unopenable condition
moved, and the comment says why so it is not simplified back.
Windows keeps the plain open: there is no `st_uid` to trust, matching
how the rest of the tree gates fast_io's operator-path helpers.
The new pin asserts the created mode is exactly 0600. That is
umask-independent by construction - a umask only clears bits, and 0600
has no group or other bits left to clear - so it discriminates rather
than restating the environment. RED proven by setting the constant to
0666: the test fails with `got 644`, which is precisely the pre-fix
behaviour.
daemon + fast_io: 2570 run, 2570 passed, 6 skipped (--no-fail-fast).
The constant is read only inside the `#[cfg(unix)]` arm of
`open_lock_file`, so on Windows it is dead code. CI builds with
`-D warnings`, which turned "constant `LOCK_FILE_MODE` is never used"
into a hard error and failed all eight Windows cells - the Windows
stable/beta/nightly matrix, IOCP, ACL/xattr, daemon, the Windows
feature-flag cell and the best-effort Windows interop leg.
Reproduced locally with the windows-gnu cross-check rather than guessed
at, since `gh run view --log-failed` returns nothing on this repo:
RUSTFLAGS="-D warnings" cargo check -p daemon \
--target x86_64-pc-windows-gnu --all-targets
error: constant `LOCK_FILE_MODE` is never used
--> crates/daemon/src/daemon/module_state/connection_limiter.rs:76:7
Clean afterwards on windows-gnu and on the native target.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…7477) The docs were last refreshed at #7423; 55 PRs have merged since, and the testsuite figures they quote had drifted far enough to understate the current state by roughly half. CHANGELOG: fill in Unreleased for everything merged since #7423. The dominant theme is routing every operator-named auxiliary file open onto the ownership walk - upstream's open_no_attacker_symlinks() applied at the call sites upstream applies it - plus a daemon hardening batch and an alt-dest correctness batch. README and SECURITY: the per-leg outcome tables were re-derived from the committed expect manifests rather than carried forward. Failures fell and the corpus grew, so every figure moved: non-root pipe 43 -> 21 fail (345 -> 349 corpus) root pipe 62 -> 29 fail (345 -> 349 corpus) non-root tcp 42 -> 29 fail (155 -> 158 corpus) root tcp 55 -> 38 fail (155 -> 158 corpus) Distinct divergences: 64 -> 31 across the two full-corpus legs, 89 -> 55 across all four. SECURITY, two CVE rows that had gone stale: - CVE-2026-53790 said "under audit". The refusal has since been applied at the live sink - oc-rsync's own single-character config expander, which upstream does not have, so an upstream-shaped port alone would have been inert (#7465, #7430, #7445). - CVE-2026-53795 listed only the staging family. The auxiliary-file family followed it onto the walk (#7421-#7426, #7439, #7441-#7443, #7459, #7463); what remains is the per-option-family confinement.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…00 (#7439) * fix(daemon): open the lock file through the ownership walk at mode 0600 `lock file = PATH` is named by the operator in oc-rsyncd.conf, and the daemon opens it as whatever user it runs as - typically root, and before the per-module privilege drop. Both opens went straight to `OpenOptions`, so a symlink planted at any component redirected a privileged `O_CREAT` open to a file the operator never named. The leaf need not exist yet, so a leaf-only `O_NOFOLLOW` could not have rejected it either. Upstream closes this with the same primitive it uses for every other operator-named auxiliary file: connection.c:35 open_no_attacker_symlinks(fname, O_RDWR|O_CREAT, 0600) oc already had that walk in `fast_io::owner_walk` and already routed the daemon config, motd, secrets file, --password-file, --log-file and both merge-file parsers onto it. The lock file was the one daemon aux-file open left on a bare path, because no existing helper opened `O_RDWR|O_CREAT` - so this adds `operator_open_rw_create` alongside the existing read and append variants, all three delegating to the same private `operator_open_with`. The mode is upstream's, not incidental. `OpenOptions::create(true)` requests 0666, which lands on 0644 under the common 022 umask, leaving a shared lock file world-readable on a daemon with a permissive umask. Upstream passes 0600 explicitly. Two behaviour notes, both deliberate: - The reopen per claim now carries `O_CREAT`, matching upstream's single `O_RDWR|O_CREAT` per `claim_connection()`. Previously a lock file removed after startup made every later claim fail; upstream recreates it. It also removes a second unguarded path resolution. - That change invalidated the DETECTOR in `negative_max_connections_still_opens_the_lock_file_first`, not its claim. The test proves a disabled module does not short-circuit ahead of the open, and it detected the open by deleting the lock file. With `O_CREAT` a missing file is no longer an error, so the detector is now a DIRECTORY at the lock path, which fails EISDIR even with `O_CREAT`. The assertion it makes is unchanged; only the unopenable condition moved, and the comment says why so it is not simplified back. Windows keeps the plain open: there is no `st_uid` to trust, matching how the rest of the tree gates fast_io's operator-path helpers. The new pin asserts the created mode is exactly 0600. That is umask-independent by construction - a umask only clears bits, and 0600 has no group or other bits left to clear - so it discriminates rather than restating the environment. RED proven by setting the constant to 0666: the test fails with `got 644`, which is precisely the pre-fix behaviour. daemon + fast_io: 2570 run, 2570 passed, 6 skipped (--no-fail-fast). * fix(daemon): gate LOCK_FILE_MODE on unix The constant is read only inside the `#[cfg(unix)]` arm of `open_lock_file`, so on Windows it is dead code. CI builds with `-D warnings`, which turned "constant `LOCK_FILE_MODE` is never used" into a hard error and failed all eight Windows cells - the Windows stable/beta/nightly matrix, IOCP, ACL/xattr, daemon, the Windows feature-flag cell and the best-effort Windows interop leg. Reproduced locally with the windows-gnu cross-check rather than guessed at, since `gh run view --log-failed` returns nothing on this repo: RUSTFLAGS="-D warnings" cargo check -p daemon \ --target x86_64-pc-windows-gnu --all-targets error: constant `LOCK_FILE_MODE` is never used --> crates/daemon/src/daemon/module_state/connection_limiter.rs:76:7 Clean afterwards on windows-gnu and on the native target.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…7477) The docs were last refreshed at #7423; 55 PRs have merged since, and the testsuite figures they quote had drifted far enough to understate the current state by roughly half. CHANGELOG: fill in Unreleased for everything merged since #7423. The dominant theme is routing every operator-named auxiliary file open onto the ownership walk - upstream's open_no_attacker_symlinks() applied at the call sites upstream applies it - plus a daemon hardening batch and an alt-dest correctness batch. README and SECURITY: the per-leg outcome tables were re-derived from the committed expect manifests rather than carried forward. Failures fell and the corpus grew, so every figure moved: non-root pipe 43 -> 21 fail (345 -> 349 corpus) root pipe 62 -> 29 fail (345 -> 349 corpus) non-root tcp 42 -> 29 fail (155 -> 158 corpus) root tcp 55 -> 38 fail (155 -> 158 corpus) Distinct divergences: 64 -> 31 across the two full-corpus legs, 89 -> 55 across all four. SECURITY, two CVE rows that had gone stale: - CVE-2026-53790 said "under audit". The refusal has since been applied at the live sink - oc-rsync's own single-character config expander, which upstream does not have, so an upstream-shaped port alone would have been inert (#7465, #7430, #7445). - CVE-2026-53795 listed only the staging family. The auxiliary-file family followed it onto the walk (#7421-#7426, #7439, #7441-#7443, #7459, #7463); what remains is the per-option-family confinement.
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 gap
lock file = PATHis operator-named inoc-rsyncd.conf, and the daemon opens it as whatever user it runs as — typically root, and before the per-module privilege drop. Both opens went straight toOpenOptions:A symlink planted at any component redirects that privileged
O_CREATopen to a file the operator never named. The leaf need not exist yet, so a leaf-onlyO_NOFOLLOWcould not reject it either — the parent-component case is exactly what the ownership walk exists for.Upstream closes it with the same primitive it uses for every other operator-named aux file:
Why this was the last one
oc already had the walk and already routed the daemon config,
motd,secrets file,--password-file,--log-fileand both merge-file parsers onto it. The lock file was the one daemon aux-file open still on a bare path, because no existing helper openedO_RDWR|O_CREAT—operator_open_readandoperator_open_appendwere the only variants. This addsoperator_open_rw_createbeside them; all three delegate to the same privateoperator_open_with, so there is one walk, not a third copy.The mode is upstream's, not incidental
OpenOptions::create(true)requests0666, which lands on 0644 under the common022umask — a shared lock file left world-readable on a daemon with a permissive umask. Upstream passes0600explicitly.Two deliberate behaviour changes
1. The per-claim reopen now carries
O_CREAT, matching upstream's singleO_RDWR|O_CREATperclaim_connection(). Previously, a lock file removed after startup made every later claim fail; upstream recreates it. It also removes a second unguarded resolution of the operator path.2. That invalidated a test's DETECTOR, not its claim — stated explicitly rather than re-baselined.
negative_max_connections_still_opens_the_lock_file_firstproves a disabled module must not short-circuit ahead of the open (upstreamconnection.c:31), and it detected the open by deleting the lock file. WithO_CREAT, a missing file is no longer an error, so that detector would have silently stopped detecting anything. It is now a directory at the lock path, which failsEISDIReven withO_CREAT. The assertion is unchanged; the comment records why, so it is not "simplified" back toremove_file.Verification
The new pin asserts the created mode is exactly
0600. That is umask-independent by construction — a umask can only clear bits, and0600has no group or other bits left to clear — so it discriminates rather than restating whatever the environment produces.RED proven by setting the constant to
0666:644is precisely the pre-fix behaviour, so this test is red against master and green only with upstream's constant.cargo nextest run -p daemon -p fast_io --all-features --no-fail-fast→ 2570 run, 2570 passed, 6 skipped. fmt + clippy clean.Scope note
create_dir_all(parent)inConnectionLimiter::openis left as-is. Upstream does not create the lock file's parent at all; removing it would change behaviour for operators relying on the auto-created directory, which is a separate decision from routing the open.