Repository navigation
feat(daemon): apply PR_SET_NO_NEW_PRIVS + log active LSMs at startup - #5581
Merged
Merged
Conversation
This was referenced Jun 10, 2026
The PR added a nix dependency with the process feature to the daemon crate but did not regenerate Cargo.lock, causing all --locked CI cells to fail with 'the lock file needs to be updated'. Add nix to the daemon entry in Cargo.lock so --locked builds succeed.
oferchen
force-pushed
the
feat/lsm-startup-hardening
branch
from
June 11, 2026 03:13
e212192 to
fedcd8f
Compare
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
Master HEAD does not compile on Linux: `delete_extraneous_files` returns `io::Result<(DeleteStats, bool)>` but its callers in `receiver/transfer/pipelined.rs:64` and `receiver/transfer/pipelined_incremental.rs:100` destructure `(ds, exceeded, io_bits)` (3-tuple). The mismatch is from the merge of #5639/#5581 dropping the i32 io_bits slot that c55f044 ("propagate ELOOP from sandboxed delete scan as IOERR_GENERAL") and the UTS-16.b series introduced. Restore the 3-tuple return type and replace the `first_err` accumulator with an `io_err_bits` accumulator. A fail-loud sandbox class (ELOOP / EOPNOTSUPP / ENOTDIR / EPERM) from any worker now ORs IOERR_GENERAL into the third slot instead of converting to `Err`, which is what the receiver-side filter_chain test `reject_symlinked_subdir_via_implied_filter` already asserts and what the UTS-16.b "non-zero exit instead of silent skip" intent documented at `pipelined.rs:59-61` requires. EDG-SANDBOX classification (`fail_loud_unlink_error`) is unchanged; only the propagation channel from worker -> caller switches from `Err` to the i32 bits, which keeps the exit code at 23 (RERR_PARTIAL) by way of `to_exit_code`. The fix is the smallest patch that unbreaks master and matches the caller / test expectations already merged. Catastrophic, non-worker errors above the parallel scan still propagate via `?` and `Err`.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
LSM-CAP at PR #5581 dropped every capability except CAP_CHOWN even for modules configured with uid=0. A uid=0 worker is, by operator intent, the root identity: the kernel grants root the file-system bypass set (DAC_OVERRIDE, DAC_READ_SEARCH, FOWNER, FSETID) implicitly so it can read, write, chmod and utime under directories owned by unprivileged users. Stripping those leaves a root worker unable to traverse a 750-mode user homedir on the path to the module tree. The link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests put the daemon scratch under `/home/<testuser>/rsync/testtmp/...` (homedir mode 750 owned by the unprivileged developer). With LSM-CAP active the worker's first `openat(.../bakmod, O_RDONLY|O_PATH)` returns EACCES at the homedir component and the connection closes mid-handshake (exit 12, "connection unexpectedly closed (0 bytes received so far)"). Same EACCES bites any production daemon whose module path crosses a non-root-readable component. Add DAC_OVERRIDE, DAC_READ_SEARCH, FOWNER, and FSETID to the required set whenever the module retains uid=0 (i.e. the worker is still root). Unprivileged modules (uid != 0) keep the empty set: setuid drops these implicitly so the explicit drop is redundant. The change matches upstream rsync, which never drops capabilities from a root daemon worker, while keeping LSM-CAP a defense-in-depth layer for the unprivileged-uid case.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
LSM-CAP at PR #5581 dropped every capability except CAP_CHOWN even when the module worker ended up running as root - either because the module declared `uid = 0` or because the module inherited the daemon-process root identity (no per-module `uid` directive plus a global `uid = 0`, the runtests.py default). Stripping CAP_DAC_OVERRIDE / CAP_DAC_READ_SEARCH / CAP_FOWNER / CAP_FSETID leaves a root worker unable to traverse a 750-mode user homedir on the path to the module tree. The link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests put the daemon scratch under `/home/<testuser>/rsync/testtmp/...` (homedir mode 750 owned by the unprivileged developer). With LSM-CAP active the worker's first `openat(.../bakmod, O_RDONLY|O_PATH)` returned EACCES at the homedir component and the connection closed mid-handshake (exit 12, "connection unexpectedly closed (0 bytes received so far)"). Same EACCES bites any production daemon whose module path crosses a non-root-readable component. Short-circuit `drop_worker_capabilities` whenever the worker is still root: either by the per-module `uid = Some(0)` directive, or by inheriting root from a daemon that started as root and ran no per-module privilege drop. Detect the inherited-root case via `geteuid().is_root()` at drop time so the check survives any partial setuid the privilege-drop path may have just performed. Workers with an explicit non-zero `uid` keep the existing required-set drop - setuid clears the effective set itself, so the explicit drop is a belt-and-suspenders defense-in-depth measure (LSM-CAP design intent). The change matches upstream rsync, which never drops capabilities from a root daemon worker, while keeping LSM-CAP a defense-in-depth layer for the unprivileged-uid case.
2 of 3 tasks
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
Master HEAD does not compile on Linux: `delete_extraneous_files` returns `io::Result<(DeleteStats, bool)>` but its callers in `receiver/transfer/pipelined.rs:64` and `receiver/transfer/pipelined_incremental.rs:100` destructure `(ds, exceeded, io_bits)` (3-tuple). The mismatch is from the merge of #5639/#5581 dropping the i32 io_bits slot that c55f044 ("propagate ELOOP from sandboxed delete scan as IOERR_GENERAL") and the UTS-16.b series introduced. Restore the 3-tuple return type and replace the `first_err` accumulator with an `io_err_bits` accumulator. A fail-loud sandbox class (ELOOP / EOPNOTSUPP / ENOTDIR / EPERM) from any worker now ORs IOERR_GENERAL into the third slot instead of converting to `Err`, which is what the receiver-side filter_chain test `reject_symlinked_subdir_via_implied_filter` already asserts and what the UTS-16.b "non-zero exit instead of silent skip" intent documented at `pipelined.rs:59-61` requires. EDG-SANDBOX classification (`fail_loud_unlink_error`) is unchanged; only the propagation channel from worker -> caller switches from `Err` to the i32 bits, which keeps the exit code at 23 (RERR_PARTIAL) by way of `to_exit_code`. The fix is the smallest patch that unbreaks master and matches the caller / test expectations already merged. Catastrophic, non-worker errors above the parallel scan still propagate via `?` and `Err`.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
LSM-CAP at PR #5581 dropped every capability except CAP_CHOWN even when the module worker ended up running as root - either because the module declared `uid = 0` or because the module inherited the daemon-process root identity (no per-module `uid` directive plus a global `uid = 0`, the runtests.py default). Stripping CAP_DAC_OVERRIDE / CAP_DAC_READ_SEARCH / CAP_FOWNER / CAP_FSETID leaves a root worker unable to traverse a 750-mode user homedir on the path to the module tree. The link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests put the daemon scratch under `/home/<testuser>/rsync/testtmp/...` (homedir mode 750 owned by the unprivileged developer). With LSM-CAP active the worker's first `openat(.../bakmod, O_RDONLY|O_PATH)` returned EACCES at the homedir component and the connection closed mid-handshake (exit 12, "connection unexpectedly closed (0 bytes received so far)"). Same EACCES bites any production daemon whose module path crosses a non-root-readable component. Short-circuit `drop_worker_capabilities` whenever the worker is still root: either by the per-module `uid = Some(0)` directive, or by inheriting root from a daemon that started as root and ran no per-module privilege drop. Detect the inherited-root case via `geteuid().is_root()` at drop time so the check survives any partial setuid the privilege-drop path may have just performed. Workers with an explicit non-zero `uid` keep the existing required-set drop - setuid clears the effective set itself, so the explicit drop is a belt-and-suspenders defense-in-depth measure (LSM-CAP design intent). The change matches upstream rsync, which never drops capabilities from a root daemon worker, while keeping LSM-CAP a defense-in-depth layer for the unprivileged-uid case.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
LSM-CAP at PR #5581 dropped every capability except CAP_CHOWN even when the module worker ended up running as root - either because the module declared `uid = 0` or because the module inherited the daemon-process root identity (no per-module `uid` directive plus a global `uid = 0`, the runtests.py default). Stripping CAP_DAC_OVERRIDE / CAP_DAC_READ_SEARCH / CAP_FOWNER / CAP_FSETID leaves a root worker unable to traverse a 750-mode user homedir on the path to the module tree. The link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests put the daemon scratch under `/home/<testuser>/rsync/testtmp/...` (homedir mode 750 owned by the unprivileged developer). With LSM-CAP active the worker's first `openat(.../bakmod, O_RDONLY|O_PATH)` returned EACCES at the homedir component and the connection closed mid-handshake (exit 12, "connection unexpectedly closed (0 bytes received so far)"). Same EACCES bites any production daemon whose module path crosses a non-root-readable component. Short-circuit `drop_worker_capabilities` whenever the worker is still root: either by the per-module `uid = Some(0)` directive, or by inheriting root from a daemon that started as root and ran no per-module privilege drop. Detect the inherited-root case via `geteuid().is_root()` at drop time so the check survives any partial setuid the privilege-drop path may have just performed. Workers with an explicit non-zero `uid` keep the existing required-set drop - setuid clears the effective set itself, so the explicit drop is a belt-and-suspenders defense-in-depth measure (LSM-CAP design intent). The change matches upstream rsync, which never drops capabilities from a root daemon worker, while keeping LSM-CAP a defense-in-depth layer for the unprivileged-uid case.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
LSM-CAP at PR #5581 dropped every capability except CAP_CHOWN even when the module worker ended up running as root - either because the module declared `uid = 0` or because the module inherited the daemon-process root identity (no per-module `uid` directive plus a global `uid = 0`, the runtests.py default). Stripping CAP_DAC_OVERRIDE / CAP_DAC_READ_SEARCH / CAP_FOWNER / CAP_FSETID leaves a root worker unable to traverse a 750-mode user homedir on the path to the module tree. The link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests put the daemon scratch under `/home/<testuser>/rsync/testtmp/...` (homedir mode 750 owned by the unprivileged developer). With LSM-CAP active the worker's first `openat(.../bakmod, O_RDONLY|O_PATH)` returned EACCES at the homedir component and the connection closed mid-handshake (exit 12, "connection unexpectedly closed (0 bytes received so far)"). Same EACCES bites any production daemon whose module path crosses a non-root-readable component. Short-circuit `drop_worker_capabilities` whenever the worker is still root: either by the per-module `uid = Some(0)` directive, or by inheriting root from a daemon that started as root and ran no per-module privilege drop. Detect the inherited-root case via `geteuid().is_root()` at drop time so the check survives any partial setuid the privilege-drop path may have just performed. Workers with an explicit non-zero `uid` keep the existing required-set drop - setuid clears the effective set itself, so the explicit drop is a belt-and-suspenders defense-in-depth measure (LSM-CAP design intent). The change matches upstream rsync, which never drops capabilities from a root daemon worker, while keeping LSM-CAP a defense-in-depth layer for the unprivileged-uid case.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
LSM-CAP at PR #5581 dropped every capability except CAP_CHOWN even when the module worker ended up running as root - either because the module declared `uid = 0` or because the module inherited the daemon-process root identity (no per-module `uid` directive plus a global `uid = 0`, the runtests.py default). Stripping CAP_DAC_OVERRIDE / CAP_DAC_READ_SEARCH / CAP_FOWNER / CAP_FSETID leaves a root worker unable to traverse a 750-mode user homedir on the path to the module tree. The link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests put the daemon scratch under `/home/<testuser>/rsync/testtmp/...` (homedir mode 750 owned by the unprivileged developer). With LSM-CAP active the worker's first `openat(.../bakmod, O_RDONLY|O_PATH)` returned EACCES at the homedir component and the connection closed mid-handshake (exit 12, "connection unexpectedly closed (0 bytes received so far)"). Same EACCES bites any production daemon whose module path crosses a non-root-readable component. Short-circuit `drop_worker_capabilities` whenever the worker is still root: either by the per-module `uid = Some(0)` directive, or by inheriting root from a daemon that started as root and ran no per-module privilege drop. Detect the inherited-root case via `geteuid().is_root()` at drop time so the check survives any partial setuid the privilege-drop path may have just performed. Workers with an explicit non-zero `uid` keep the existing required-set drop - setuid clears the effective set itself, so the explicit drop is a belt-and-suspenders defense-in-depth measure (LSM-CAP design intent). The change matches upstream rsync, which never drops capabilities from a root daemon worker, while keeping LSM-CAP a defense-in-depth layer for the unprivileged-uid case.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
LSM-CAP at PR #5581 dropped every capability except CAP_CHOWN even when the module worker ended up running as root - either because the module declared `uid = 0` or because the module inherited the daemon-process root identity (no per-module `uid` directive plus a global `uid = 0`, the runtests.py default). Stripping CAP_DAC_OVERRIDE / CAP_DAC_READ_SEARCH / CAP_FOWNER / CAP_FSETID leaves a root worker unable to traverse a 750-mode user homedir on the path to the module tree. The link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests put the daemon scratch under `/home/<testuser>/rsync/testtmp/...` (homedir mode 750 owned by the unprivileged developer). With LSM-CAP active the worker's first `openat(.../bakmod, O_RDONLY|O_PATH)` returned EACCES at the homedir component and the connection closed mid-handshake (exit 12, "connection unexpectedly closed (0 bytes received so far)"). Same EACCES bites any production daemon whose module path crosses a non-root-readable component. Short-circuit `drop_worker_capabilities` whenever the worker is still root: either by the per-module `uid = Some(0)` directive, or by inheriting root from a daemon that started as root and ran no per-module privilege drop. Detect the inherited-root case via `geteuid().is_root()` at drop time so the check survives any partial setuid the privilege-drop path may have just performed. Workers with an explicit non-zero `uid` keep the existing required-set drop - setuid clears the effective set itself, so the explicit drop is a belt-and-suspenders defense-in-depth measure (LSM-CAP design intent). The change matches upstream rsync, which never drops capabilities from a root daemon worker, while keeping LSM-CAP a defense-in-depth layer for the unprivileged-uid case.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
LSM-CAP at PR #5581 dropped every capability except CAP_CHOWN even when the module worker ended up running as root - either because the module declared `uid = 0` or because the module inherited the daemon-process root identity (no per-module `uid` directive plus a global `uid = 0`, the runtests.py default). Stripping CAP_DAC_OVERRIDE / CAP_DAC_READ_SEARCH / CAP_FOWNER / CAP_FSETID leaves a root worker unable to traverse a 750-mode user homedir on the path to the module tree. The link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests put the daemon scratch under `/home/<testuser>/rsync/testtmp/...` (homedir mode 750 owned by the unprivileged developer). With LSM-CAP active the worker's first `openat(.../bakmod, O_RDONLY|O_PATH)` returned EACCES at the homedir component and the connection closed mid-handshake (exit 12, "connection unexpectedly closed (0 bytes received so far)"). Same EACCES bites any production daemon whose module path crosses a non-root-readable component. Short-circuit `drop_worker_capabilities` whenever the worker is still root: either by the per-module `uid = Some(0)` directive, or by inheriting root from a daemon that started as root and ran no per-module privilege drop. Detect the inherited-root case via `geteuid().is_root()` at drop time so the check survives any partial setuid the privilege-drop path may have just performed. Workers with an explicit non-zero `uid` keep the existing required-set drop - setuid clears the effective set itself, so the explicit drop is a belt-and-suspenders defense-in-depth measure (LSM-CAP design intent). The change matches upstream rsync, which never drops capabilities from a root daemon worker, while keeping LSM-CAP a defense-in-depth layer for the unprivileged-uid case.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
…sts (#5680) * fix(transfer): unblock master build by reverting dropped io_bits PR #5620 ("propagate ELOOP from sandboxed delete scan as IOERR_GENERAL") merged the caller-side changes in pipelined.rs and pipelined_incremental.rs that unpack a 3-tuple including `io_bits`, but the deletion.rs body kept returning a 2-tuple. Master is currently broken. Revert just the caller-side 3-tuple unpacking so the build compiles again. The IOERR_GENERAL surfacing on sandbox-rejected delete scans (UTS-16.b) is temporarily disabled and tracked by the original PR. * fix(daemon): resolve relative --link-dest against dest dir, not module root Upstream rsync's daemon receiver evaluates relative basis paths (`--link-dest=../01`) against the dest subdirectory: main.c:1199-1206 calls `check_alt_basis_dirs()` *after* `get_local_name(flist, argv[0])` has chdir'd into the receiver's destination, so the generator's `pathjoin(basis_dir[j], fname)` resolves with cwd = dest_dir. oc-rsync does not chdir per connection; the daemon pre-resolved relative ref_dirs against the module root instead. With dest=`mod/00/` and `--link-dest=../01`, the resolver produced `mod/../01` (parent of the module) instead of `mod/00/../01 = mod/01` (the in-module sibling the client meant). Every basis lookup missed, the file was re-transferred, and the link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests reported "destination file missing" on push. Pre-resolve relative ref_dirs against the receiver's positional dest arg, lexically normalise the result so `..` segments collapse without touching the filesystem, then confine the resolved path inside the module root via `starts_with(canonicalised module path)`. Refused basis dirs are silently dropped so the receiver re-transfers (matching upstream's sanitize_path fallthrough) instead of leaking out-of-module files via a hard link. URV-5.a.1.c absolute-path validation in `validate_client_paths_in_module` is untouched: the daemon still @errors on `--link-dest=/etc/passwd` before this code path runs. Sender role keeps the module-root fallback so the legacy compare-dest lookup path stays unchanged - the receiver is the only role that actually evaluates basis_dir per file. * fix(daemon): skip worker cap drop when worker runs as root LSM-CAP at PR #5581 dropped every capability except CAP_CHOWN even when the module worker ended up running as root - either because the module declared `uid = 0` or because the module inherited the daemon-process root identity (no per-module `uid` directive plus a global `uid = 0`, the runtests.py default). Stripping CAP_DAC_OVERRIDE / CAP_DAC_READ_SEARCH / CAP_FOWNER / CAP_FSETID leaves a root worker unable to traverse a 750-mode user homedir on the path to the module tree. The link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests put the daemon scratch under `/home/<testuser>/rsync/testtmp/...` (homedir mode 750 owned by the unprivileged developer). With LSM-CAP active the worker's first `openat(.../bakmod, O_RDONLY|O_PATH)` returned EACCES at the homedir component and the connection closed mid-handshake (exit 12, "connection unexpectedly closed (0 bytes received so far)"). Same EACCES bites any production daemon whose module path crosses a non-root-readable component. Short-circuit `drop_worker_capabilities` whenever the worker is still root: either by the per-module `uid = Some(0)` directive, or by inheriting root from a daemon that started as root and ran no per-module privilege drop. Detect the inherited-root case via `geteuid().is_root()` at drop time so the check survives any partial setuid the privilege-drop path may have just performed. Workers with an explicit non-zero `uid` keep the existing required-set drop - setuid clears the effective set itself, so the explicit drop is a belt-and-suspenders defense-in-depth measure (LSM-CAP design intent). The change matches upstream rsync, which never drops capabilities from a root daemon worker, while keeping LSM-CAP a defense-in-depth layer for the unprivileged-uid case. * fix(transfer): restore 3-tuple destructuring for delete_extraneous_files Master's delete_extraneous_files signature was updated to return io::Result<(DeleteStats, bool, i32)> for the IOERR_GENERAL bit, but the pipelined and pipelined_incremental receiver paths on this branch still destructured the legacy 2-tuple. Adjust both call sites to capture the io_bits and OR them into the transfer stats so flist + delete I/O errors propagate to the goodbye phase. * fix(transfer): drop intermediate delete_io_error binding The dedicated variable was only used to OR into stats.io_error; pipe io_bits directly to avoid the unused_assignments lint.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
feat(daemon): apply PR_SET_NO_NEW_PRIVS + log active LSMs at startup
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
Master HEAD does not compile on Linux: `delete_extraneous_files` returns `io::Result<(DeleteStats, bool)>` but its callers in `receiver/transfer/pipelined.rs:64` and `receiver/transfer/pipelined_incremental.rs:100` destructure `(ds, exceeded, io_bits)` (3-tuple). The mismatch is from the merge of #5639/#5581 dropping the i32 io_bits slot that c55f044 ("propagate ELOOP from sandboxed delete scan as IOERR_GENERAL") and the UTS-16.b series introduced. Restore the 3-tuple return type and replace the `first_err` accumulator with an `io_err_bits` accumulator. A fail-loud sandbox class (ELOOP / EOPNOTSUPP / ENOTDIR / EPERM) from any worker now ORs IOERR_GENERAL into the third slot instead of converting to `Err`, which is what the receiver-side filter_chain test `reject_symlinked_subdir_via_implied_filter` already asserts and what the UTS-16.b "non-zero exit instead of silent skip" intent documented at `pipelined.rs:59-61` requires. EDG-SANDBOX classification (`fail_loud_unlink_error`) is unchanged; only the propagation channel from worker -> caller switches from `Err` to the i32 bits, which keeps the exit code at 23 (RERR_PARTIAL) by way of `to_exit_code`. The fix is the smallest patch that unbreaks master and matches the caller / test expectations already merged. Catastrophic, non-worker errors above the parallel scan still propagate via `?` and `Err`.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…sts (#5680) * fix(transfer): unblock master build by reverting dropped io_bits PR #5620 ("propagate ELOOP from sandboxed delete scan as IOERR_GENERAL") merged the caller-side changes in pipelined.rs and pipelined_incremental.rs that unpack a 3-tuple including `io_bits`, but the deletion.rs body kept returning a 2-tuple. Master is currently broken. Revert just the caller-side 3-tuple unpacking so the build compiles again. The IOERR_GENERAL surfacing on sandbox-rejected delete scans (UTS-16.b) is temporarily disabled and tracked by the original PR. * fix(daemon): resolve relative --link-dest against dest dir, not module root Upstream rsync's daemon receiver evaluates relative basis paths (`--link-dest=../01`) against the dest subdirectory: main.c:1199-1206 calls `check_alt_basis_dirs()` *after* `get_local_name(flist, argv[0])` has chdir'd into the receiver's destination, so the generator's `pathjoin(basis_dir[j], fname)` resolves with cwd = dest_dir. oc-rsync does not chdir per connection; the daemon pre-resolved relative ref_dirs against the module root instead. With dest=`mod/00/` and `--link-dest=../01`, the resolver produced `mod/../01` (parent of the module) instead of `mod/00/../01 = mod/01` (the in-module sibling the client meant). Every basis lookup missed, the file was re-transferred, and the link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests reported "destination file missing" on push. Pre-resolve relative ref_dirs against the receiver's positional dest arg, lexically normalise the result so `..` segments collapse without touching the filesystem, then confine the resolved path inside the module root via `starts_with(canonicalised module path)`. Refused basis dirs are silently dropped so the receiver re-transfers (matching upstream's sanitize_path fallthrough) instead of leaking out-of-module files via a hard link. URV-5.a.1.c absolute-path validation in `validate_client_paths_in_module` is untouched: the daemon still @errors on `--link-dest=/etc/passwd` before this code path runs. Sender role keeps the module-root fallback so the legacy compare-dest lookup path stays unchanged - the receiver is the only role that actually evaluates basis_dir per file. * fix(daemon): skip worker cap drop when worker runs as root LSM-CAP at PR #5581 dropped every capability except CAP_CHOWN even when the module worker ended up running as root - either because the module declared `uid = 0` or because the module inherited the daemon-process root identity (no per-module `uid` directive plus a global `uid = 0`, the runtests.py default). Stripping CAP_DAC_OVERRIDE / CAP_DAC_READ_SEARCH / CAP_FOWNER / CAP_FSETID leaves a root worker unable to traverse a 750-mode user homedir on the path to the module tree. The link-dest-relative-basis / link-dest-pathroot / link-dest-module- escape upstream tests put the daemon scratch under `/home/<testuser>/rsync/testtmp/...` (homedir mode 750 owned by the unprivileged developer). With LSM-CAP active the worker's first `openat(.../bakmod, O_RDONLY|O_PATH)` returned EACCES at the homedir component and the connection closed mid-handshake (exit 12, "connection unexpectedly closed (0 bytes received so far)"). Same EACCES bites any production daemon whose module path crosses a non-root-readable component. Short-circuit `drop_worker_capabilities` whenever the worker is still root: either by the per-module `uid = Some(0)` directive, or by inheriting root from a daemon that started as root and ran no per-module privilege drop. Detect the inherited-root case via `geteuid().is_root()` at drop time so the check survives any partial setuid the privilege-drop path may have just performed. Workers with an explicit non-zero `uid` keep the existing required-set drop - setuid clears the effective set itself, so the explicit drop is a belt-and-suspenders defense-in-depth measure (LSM-CAP design intent). The change matches upstream rsync, which never drops capabilities from a root daemon worker, while keeping LSM-CAP a defense-in-depth layer for the unprivileged-uid case. * fix(transfer): restore 3-tuple destructuring for delete_extraneous_files Master's delete_extraneous_files signature was updated to return io::Result<(DeleteStats, bool, i32)> for the IOERR_GENERAL bit, but the pipelined and pipelined_incremental receiver paths on this branch still destructured the legacy 2-tuple. Adjust both call sites to capture the io_bits and OR them into the transfer stats so flist + delete I/O errors propagate to the goodbye phase. * fix(transfer): drop intermediate delete_io_error binding The dedicated variable was only used to OR into stats.io_error; pipe io_bits directly to avoid the unused_assignments lint.
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
PR_SET_NO_NEW_PRIVSonce at daemon main-entry vianix::sys::prctl::set_no_new_privs, so any laterexecve()(including pre/post-xfer-exec hooks) cannot regain privileges and Landlock can engage on kernels that gate it behind the no-new-privs bit./sys/kernel/security/lsmand emits the active LSM list at info level so operators see a single audit line confirming which kernel-side defenses (Landlock, lockdown, Yama, AppArmor, etc.) cover the daemon. Missing securityfs degrades to a graceful skip.--server --daemonstdio); no-op on non-Linux targets.Test plan
cargo nextest run -p daemon --all-features -E 'test(hardening)'covers the two new unit tests: a mocked-file LSM read that asserts the trimmed list reaches the log sink, and a missing-path probe that asserts graceful skip without panic.nixprocessfeature compiles.tests::support::run_daemon) confirm the daemon still starts successfully on Linux with the prctl call wired in.