Skip to content

feat(fast_io): mkdirat/symlinkat/linkat sandbox helpers (SEC-1.h) - #4683

Merged
oferchen merged 1 commit into
masterfrom
feat/fast-io-mkdirat-symlinkat-linkat-sec1h
May 21, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/fast-io-mkdirat-symlinkat-linkat-sec1h

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

Extends the SEC-1 dirfd-anchored carrier with the create-class siblings:

  • mkdirat(dirfd, name, mode)
  • symlinkat(target, dirfd, name)
  • linkat(old_dirfd, old_name, new_dirfd, new_name, 0)
  • mkdirat_via_sandbox_or_fallback / symlinkat_via_sandbox_or_fallback / linkat_via_sandbox_or_fallback adaptors that route a single-component leaf under the receiver's DirSandbox root through the *at variant while preserving the existing path-based fallback for multi-component paths, missing sandbox, and non-Unix targets.

Pattern source: SEC-1.g (#4671) unlink_via_sandbox_or_fallback.

Receiver callers wired

  • create_symlinks (crates/transfer/src/receiver/directory/links.rs) - creates symlinks via symlinkat_via_sandbox_or_fallback.
  • create_hardlinks (same file) - creates follower hard links via linkat_via_sandbox_or_fallback. The new endpoint is anchored on the sandbox dirfd; the leader endpoint stays on AT_FDCWD because cross-segment hardlinks may live outside dest_dir. Falls back to fast_io::hard_link (io_uring LINKAT fast path / std::fs::hard_link) for multi-component / no-sandbox cases, preserving EXDEV / EPERM semantics.
  • create_directories (crates/transfer/src/receiver/directory/creation.rs) - creates directories via mkdirat_via_sandbox_or_fallback; falls back to fs::create_dir_all for multi-component --relative shapes the parent walk did not pre-create.
  • create_directory_incremental (same file) - same wiring for the incremental flist path.

sandbox is plumbed through both directory-creation entry points under #[cfg(unix)], matching the SEC-1.g pattern.

mknodat status

Deferred. Device/FIFO/socket creation is wrapped by the metadata crate (create_device_node_with_fake_super, create_fifo_with_fake_super, apple_fs::mknod) and used by the local-copy executor; the receiver pipeline reaches those paths via several abstraction layers that need a deeper refactor before the sandbox can be threaded through. Receiver-side mknod is not on the daemon-reachable TOCTOU surface that SEC-1 targets today, so the cutover is left as follow-up.

Cross-platform

  • Linux + macOS: *at libc syscalls are POSIX-2008, present on every supported Unix target.
  • Windows: falls through to path-based stdlib per the SEC-1.l audit (NTFS uses handle-based APIs that sidestep path TOCTOU). DirSandbox and all *at helpers remain #[cfg(unix)]; the call sites switch on #[cfg(unix)] to keep the build green.

Test plan

  • CI fmt + clippy
  • CI nextest (stable + Linux musl + macOS + Windows)
  • Interop validation against upstream 3.4.1 / 3.4.2 (symlink, hardlink, directory tree shapes)
  • SEC-1.m / SEC-1.n swap-resistance test PRs (in flight) exercise the new helpers under TOCTOU attack

Adds the create-class siblings to the SEC-1 dirfd carrier:
mkdirat / symlinkat / linkat and the via_sandbox_or_fallback
adaptors that route a single-component leaf under the receiver's
DirSandbox root through the *at variant while preserving the
existing path-based fallback for multi-component paths, missing
sandbox, and non-Unix targets.

Wires the receiver pipeline:
- create_symlinks now creates symlinks through
  symlinkat_via_sandbox_or_fallback.
- create_hardlinks creates follower hard links through
  linkat_via_sandbox_or_fallback, keeping fast_io::hard_link
  (io_uring LINKAT fast path) as the fallback so EXDEV/EPERM
  semantics survive.
- create_directories and create_directory_incremental create
  new directories through mkdirat_via_sandbox_or_fallback, with
  fs::create_dir_all retained as the multi-component fallback.

Follows the SEC-1.g pattern (PR #4671). mknodat is deferred:
device/FIFO/socket creation is wrapped by the metadata crate and
needs deeper refactoring before the sandbox can be threaded
through; receiver-side mknod is not on the daemon-reachable
TOCTOU surface today.

Windows stays on path-based stdlib per the SEC-1.l NTFS-handle
audit.
@github-actions github-actions Bot added the enhancement New feature or request label May 21, 2026
@oferchen
oferchen merged commit 2cfb8ba into master May 21, 2026
55 checks passed
oferchen added a commit that referenced this pull request May 21, 2026
Extends the SEC-1 dirfd-anchored carrier with the metadata-application
siblings:

- fchmodat(dirfd, name, mode, follow_symlinks)
- fchownat(dirfd, name, uid, gid, follow_symlinks)
- utimensat(dirfd, name, atime, mtime, follow_symlinks)
- fchmodat_via_sandbox_or_fallback / fchownat_via_sandbox_or_fallback /
  utimensat_via_sandbox_or_fallback adaptors that route single-component
  leaves under the receiver's DirSandbox root through the *at variant
  while preserving path-based fallbacks for multi-component paths,
  missing sandbox, and non-Unix targets.

Pattern source: SEC-1.g unlink_via_sandbox_or_fallback.

The new helpers live in a sibling at_syscalls_metadata.rs module so the
SEC-1.h create-class additions (#4683) and SEC-1.i metadata-class
additions can land independently without conflicting on the same file.
Once both PRs merge the two modules may be re-folded into a single
at_syscalls namespace as housekeeping.

Receiver-side wiring of the metadata application path through these
helpers is deferred follow-up: the metadata crate does not depend on
fast_io today and threading DirSandbox through apply_metadata_from_file_entry
requires propagating it across the transfer pipeline. Same staging
strategy as SEC-1.b which landed the carrier ahead of subsequent cutover
PRs.
oferchen added a commit that referenced this pull request May 21, 2026
…4690)

* feat(fast_io): fchmodat/fchownat/utimensat sandbox helpers (SEC-1.i)

Extends the SEC-1 dirfd-anchored carrier with the metadata-application
siblings:

- fchmodat(dirfd, name, mode, follow_symlinks)
- fchownat(dirfd, name, uid, gid, follow_symlinks)
- utimensat(dirfd, name, atime, mtime, follow_symlinks)
- fchmodat_via_sandbox_or_fallback / fchownat_via_sandbox_or_fallback /
  utimensat_via_sandbox_or_fallback adaptors that route single-component
  leaves under the receiver's DirSandbox root through the *at variant
  while preserving path-based fallbacks for multi-component paths,
  missing sandbox, and non-Unix targets.

Pattern source: SEC-1.g unlink_via_sandbox_or_fallback.

The new helpers live in a sibling at_syscalls_metadata.rs module so the
SEC-1.h create-class additions (#4683) and SEC-1.i metadata-class
additions can land independently without conflicting on the same file.
Once both PRs merge the two modules may be re-folded into a single
at_syscalls namespace as housekeeping.

Receiver-side wiring of the metadata application path through these
helpers is deferred follow-up: the metadata crate does not depend on
fast_io today and threading DirSandbox through apply_metadata_from_file_entry
requires propagating it across the transfer pipeline. Same staging
strategy as SEC-1.b which landed the carrier ahead of subsequent cutover
PRs.

* fix(fast_io): make filetime dep available on unix for SEC-1.i fallback

The fchmodat/fchownat/utimensat_via_sandbox_or_fallback helpers in
at_syscalls_metadata.rs use filetime::FileTime and
filetime::set_symlink_file_times for the multi-component fallback
path. Move filetime out of cfg(not(unix)) so it compiles on all
platforms.

* fix(fast_io): gate at_syscalls_metadata mod with cfg(unix)

at_syscalls_metadata.rs is unix-only (libc *at calls + filetime). The
mod declaration was unconditional, causing Windows builds to try
compiling it and fail with 'unresolved crate filetime'. Gate both the
mod declaration and the re-exports with #[cfg(unix)].

* fix(fast_io): move filetime to universal deps for non-unix syscall_batch

The cfg(unix) move regressed Windows because syscall_batch.rs has a
cfg(not(unix)) block that uses filetime::FileTime. Move filetime out of
target-specific deps to general [dependencies] so both unix
(at_syscalls_metadata fallback) and non-unix (syscall_batch) paths see
it.

* fix(fast_io): use inferred cast for timespec fields (musl libc::time_t deprecated)

musl 1.2.0 deprecated libc::time_t in favor of a 64-bit alias. Cast
unix_seconds() and nanoseconds() to the timespec field type with 'as _'
so the cast picks up whichever signed integer the target's libc uses.
oferchen added a commit that referenced this pull request May 21, 2026
… triggers (#4694)

SEC-1.h (PR #4683) shipped mkdirat/symlinkat/linkat sandbox helpers but
explicitly punted mknodat because device/FIFO/socket creation lives
behind metadata-crate abstractions that do not carry DirSandbox and is
not on today's daemon-reachable TOCTOU surface. Records the rationale,
sketches the helper signature, and lists the explicit re-open triggers
so the SEC-1 audit chain has a clear closure for the mknodat
sub-question.
oferchen added a commit that referenced this pull request May 21, 2026
…ship (#4695)

Captures the hygiene follow-up to consolidate
`crates/fast_io/src/dir_sandbox/at_syscalls{,_metadata,_rename}.rs`
into a single `at_syscalls` namespace now that all three SEC-1 *at*
helper PRs (.h #4683, .i #4690, .j #4693) are on master. Both .i and .j
module headers explicitly scheduled the re-fold; this doc turns that
into a concrete plan with section dividers, re-export collapse steps,
and an LoC sanity check that confirms the consolidated file remains
within the post-2026-05-18 LoC policy.
@oferchen
oferchen deleted the feat/fast-io-mkdirat-symlinkat-linkat-sec1h branch May 22, 2026 06:40
oferchen added a commit that referenced this pull request Aug 24, 2026
)

Adds the create-class siblings to the SEC-1 dirfd carrier:
mkdirat / symlinkat / linkat and the via_sandbox_or_fallback
adaptors that route a single-component leaf under the receiver's
DirSandbox root through the *at variant while preserving the
existing path-based fallback for multi-component paths, missing
sandbox, and non-Unix targets.

Wires the receiver pipeline:
- create_symlinks now creates symlinks through
  symlinkat_via_sandbox_or_fallback.
- create_hardlinks creates follower hard links through
  linkat_via_sandbox_or_fallback, keeping fast_io::hard_link
  (io_uring LINKAT fast path) as the fallback so EXDEV/EPERM
  semantics survive.
- create_directories and create_directory_incremental create
  new directories through mkdirat_via_sandbox_or_fallback, with
  fs::create_dir_all retained as the multi-component fallback.

Follows the SEC-1.g pattern (PR #4671). mknodat is deferred:
device/FIFO/socket creation is wrapped by the metadata crate and
needs deeper refactoring before the sandbox can be threaded
through; receiver-side mknod is not on the daemon-reachable
TOCTOU surface today.

Windows stays on path-based stdlib per the SEC-1.l NTFS-handle
audit.
oferchen added a commit that referenced this pull request Aug 24, 2026
…n/.k/.l ship state

Update CVE-2026-29518 and CVE-2026-43619 entries to "Mostly fixed",
reflecting the SEC-1 sub-tasks now in master:

- .a/.b/.c/.d/.e: DirSandbox carrier, openat2 detection, receiver wiring
- .f: lstat to fstatat (PR #4668)
- .g: remove to unlinkat (PR #4671)
- .h: mkdir/symlink/hard_link to *at variants (PR #4683)
- .k: macOS verified
- .l: Windows audited (NTFS handle-based, not affected)
- .m: symlink-swap attack regression (PR #4675)
- .n: legitimate symlink interop regression (PR #4678)

Remaining work explicitly listed:

- .i (chmod/lchown/utimes to *at) - in flight
- .j (rename to renameat) - in flight
- mknodat for device/FIFO nodes - deferred (not daemon-reachable)
- Receiver wiring for SEC-1.i helpers - deferred (carrier-first staging)

Target full-Fixed status: when SEC-1.i and SEC-1.j ship and all receiver
call sites are wired through DirSandbox.
oferchen added a commit that referenced this pull request Aug 24, 2026
…4690)

* feat(fast_io): fchmodat/fchownat/utimensat sandbox helpers (SEC-1.i)

Extends the SEC-1 dirfd-anchored carrier with the metadata-application
siblings:

- fchmodat(dirfd, name, mode, follow_symlinks)
- fchownat(dirfd, name, uid, gid, follow_symlinks)
- utimensat(dirfd, name, atime, mtime, follow_symlinks)
- fchmodat_via_sandbox_or_fallback / fchownat_via_sandbox_or_fallback /
  utimensat_via_sandbox_or_fallback adaptors that route single-component
  leaves under the receiver's DirSandbox root through the *at variant
  while preserving path-based fallbacks for multi-component paths,
  missing sandbox, and non-Unix targets.

Pattern source: SEC-1.g unlink_via_sandbox_or_fallback.

The new helpers live in a sibling at_syscalls_metadata.rs module so the
SEC-1.h create-class additions (#4683) and SEC-1.i metadata-class
additions can land independently without conflicting on the same file.
Once both PRs merge the two modules may be re-folded into a single
at_syscalls namespace as housekeeping.

Receiver-side wiring of the metadata application path through these
helpers is deferred follow-up: the metadata crate does not depend on
fast_io today and threading DirSandbox through apply_metadata_from_file_entry
requires propagating it across the transfer pipeline. Same staging
strategy as SEC-1.b which landed the carrier ahead of subsequent cutover
PRs.

* fix(fast_io): make filetime dep available on unix for SEC-1.i fallback

The fchmodat/fchownat/utimensat_via_sandbox_or_fallback helpers in
at_syscalls_metadata.rs use filetime::FileTime and
filetime::set_symlink_file_times for the multi-component fallback
path. Move filetime out of cfg(not(unix)) so it compiles on all
platforms.

* fix(fast_io): gate at_syscalls_metadata mod with cfg(unix)

at_syscalls_metadata.rs is unix-only (libc *at calls + filetime). The
mod declaration was unconditional, causing Windows builds to try
compiling it and fail with 'unresolved crate filetime'. Gate both the
mod declaration and the re-exports with #[cfg(unix)].

* fix(fast_io): move filetime to universal deps for non-unix syscall_batch

The cfg(unix) move regressed Windows because syscall_batch.rs has a
cfg(not(unix)) block that uses filetime::FileTime. Move filetime out of
target-specific deps to general [dependencies] so both unix
(at_syscalls_metadata fallback) and non-unix (syscall_batch) paths see
it.

* fix(fast_io): use inferred cast for timespec fields (musl libc::time_t deprecated)

musl 1.2.0 deprecated libc::time_t in favor of a 64-bit alias. Cast
unix_seconds() and nanoseconds() to the timespec field type with 'as _'
so the cast picks up whichever signed integer the target's libc uses.
oferchen added a commit that referenced this pull request Aug 24, 2026
… triggers (#4694)

SEC-1.h (PR #4683) shipped mkdirat/symlinkat/linkat sandbox helpers but
explicitly punted mknodat because device/FIFO/socket creation lives
behind metadata-crate abstractions that do not carry DirSandbox and is
not on today's daemon-reachable TOCTOU surface. Records the rationale,
sketches the helper signature, and lists the explicit re-open triggers
so the SEC-1 audit chain has a clear closure for the mknodat
sub-question.
oferchen added a commit that referenced this pull request Aug 24, 2026
…ship (#4695)

Captures the hygiene follow-up to consolidate
`crates/fast_io/src/dir_sandbox/at_syscalls{,_metadata,_rename}.rs`
into a single `at_syscalls` namespace now that all three SEC-1 *at*
helper PRs (.h #4683, .i #4690, .j #4693) are on master. Both .i and .j
module headers explicitly scheduled the re-fold; this doc turns that
into a concrete plan with section dividers, re-export collapse steps,
and an LoC sanity check that confirms the consolidated file remains
within the post-2026-05-18 LoC policy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant