Repository navigation
Clamp peer protocol advertisements to supported range - #5
Merged
Merged
Conversation
oferchen
added a commit
that referenced
this pull request
May 22, 2026
#4716) Adds four new SEC-1 helpers in `fast_io::dir_sandbox::at_syscalls`: - `openat(dirfd, name, flags, mode) -> File` raw libc wrapper. - `openat_via_sandbox_or_fallback(...)` adaptor that takes the sandbox fast path on a single-component leaf beneath `dest_dir` and falls back to `std::fs::OpenOptions` against `link_path` with best-effort `O_*` bit translation otherwise. - `readlinkat(dirfd, name) -> PathBuf` raw libc wrapper with a growing buffer (256B -> PATH_MAX, doubling each round trip). - `readlinkat_via_sandbox_or_fallback(...)` adaptor mirroring the openat shape but falling back to `std::fs::read_link`. The helpers follow the established SEC-1 pattern: pinning the parent via the sandbox dirfd closes the TOCTOU window between path walk and the kernel reaching the inode. The `*_via_sandbox_or_fallback` adaptors keep behaviour byte-identical for callers that have not yet plumbed a `DirSandbox`, so individual call sites can be cut over one at a time. This PR adds the helpers and re-exports them through `dir_sandbox::mod` and `fast_io::lib`. It deliberately does NOT wire any caller; per-site wiring lands in follow-up PRs so each cutover gets its own diff and review. Extends the existing tests module with 10 new tests covering: - raw `openat` success and ENOENT, - `openat_via_sandbox_or_fallback` fast path, multi-component fallback, and absent-sandbox fallback, - raw `readlinkat` success and EINVAL on a non-symlink, - `readlinkat_via_sandbox_or_fallback` fast path, EINVAL, and multi-component fallback. All helpers are `#[cfg(unix)]` (the `dir_sandbox` module is itself Unix-only); Windows continues to use path-based stdlib opens per the SEC-1.l NTFS handle audit. Closes (post-wire) 16+ GAPs from the SEC-1 path-syscall coverage audit in PR #4710: #4 (readlinkat) plus the 9 direct openat sites (#9-#17) and lays foundations for #5, #20 (open + readdir-loop) and #6, #27 (recursive *at peel). Refs PR #4710.
This was referenced May 22, 2026
oferchen
added a commit
that referenced
this pull request
May 22, 2026
#4729) Captures the receiver-side `--delete` wiring follow-up SEC-1.q (PR #4728) intentionally deferred. The merged engine-side work added a sandbox-aware DeleteFs trait surface plus the DeleteEmitter::with_sandbox carrier, but the receiver loop in crates/transfer/src/receiver/directory/deletion.rs still calls std::fs::remove_file / remove_dir_all / read_dir directly. Lays out three options (migrate receiver to DeleteEmitter, swap to fast_io *_via_sandbox_or_fallback helpers, defer behind Landlock) with LoC scope, risk, test cost, and cross-platform plan. Recommends Option B (direct helper swap) on effort-vs-risk grounds and because the SEC-1.r temp_guard / temp_cleanup PR (#4723) is the established precedent for exactly this carrier-threading shape. Closes audit rows #5-#7 in docs/audits/sec-1-path-syscall-audit-2026-05-22.md once the implementation PR lands. Docs-only.
3 of 4 tasks
oferchen
added a commit
that referenced
this pull request
May 22, 2026
…-1.q2) (#4732) * feat(transfer): thread DirSandbox through receiver --delete path (SEC-1.q2) Replace the three unanchored syscalls in delete_extraneous_files with their sandbox-anchored siblings so a TOCTOU symlink swap on a top-level extraneous entry cannot redirect the listing or the unlink to an attacker-chosen inode outside the destination tree. Adds fast_io::read_dir_via_sandbox_or_fallback (mirrors the existing *_via_sandbox_or_fallback shape: openat(O_DIRECTORY | O_NOFOLLOW) + fdopendir for single-component scans, std::fs::read_dir fallback otherwise). Closes audit rows #5, #6, #7 from the SEC-1 path-syscall audit. Mirrors the SEC-1.r temp_guard/temp_cleanup carrier-threading pattern (PR #4723): the Option<Arc<DirSandbox>> is cloned once into the map_blocking worker closure and forwarded to every helper call. Sandbox-off and multi-component paths take the documented identical- behaviour fallback. No transfer-crate unsafe is introduced; all unsafe stays behind the existing fast_io safe wrappers. Windows continues through std::fs::remove_file / remove_dir_all / read_dir (NTFS handle semantics already close the symlink-swap window per the SEC-1.l audit). * fix(engine): use Components::next() walk for plan_directory_to_relative SkipWhile<Components, _> has no as_path() method on stable Rust 1.88; the previous skip_while-then-as_path call introduced in SEC-1.q (#4728) slipped through that PR's CI but breaks fmt+clippy on every subsequent master CI run. Switch to a manual Components::next() walk that consumes the leading Prefix/RootDir/CurDir components, then calls as_path() on the unwrapped Components iterator. * fix(transfer): cfg-gate rel_for_unlink to unix to silence Windows unused-var
3 tasks
4 tasks
oferchen
added a commit
that referenced
this pull request
Jun 5, 2026
…5488) Reduce mimalloc's default 1 GiB virtual arena reservation to 128 MiB and set purge delay to 0 (immediate decommit). RSS-2 profiling identified the default arena reservation and deferred purge as root cause #5 of the 9.8x RSS gap vs upstream, contributing ~16 MiB of committed-but-purged page overhead. Environment variable defaults are set early in main() and respect user-supplied MIMALLOC_* overrides.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
#4716) Adds four new SEC-1 helpers in `fast_io::dir_sandbox::at_syscalls`: - `openat(dirfd, name, flags, mode) -> File` raw libc wrapper. - `openat_via_sandbox_or_fallback(...)` adaptor that takes the sandbox fast path on a single-component leaf beneath `dest_dir` and falls back to `std::fs::OpenOptions` against `link_path` with best-effort `O_*` bit translation otherwise. - `readlinkat(dirfd, name) -> PathBuf` raw libc wrapper with a growing buffer (256B -> PATH_MAX, doubling each round trip). - `readlinkat_via_sandbox_or_fallback(...)` adaptor mirroring the openat shape but falling back to `std::fs::read_link`. The helpers follow the established SEC-1 pattern: pinning the parent via the sandbox dirfd closes the TOCTOU window between path walk and the kernel reaching the inode. The `*_via_sandbox_or_fallback` adaptors keep behaviour byte-identical for callers that have not yet plumbed a `DirSandbox`, so individual call sites can be cut over one at a time. This PR adds the helpers and re-exports them through `dir_sandbox::mod` and `fast_io::lib`. It deliberately does NOT wire any caller; per-site wiring lands in follow-up PRs so each cutover gets its own diff and review. Extends the existing tests module with 10 new tests covering: - raw `openat` success and ENOENT, - `openat_via_sandbox_or_fallback` fast path, multi-component fallback, and absent-sandbox fallback, - raw `readlinkat` success and EINVAL on a non-symlink, - `readlinkat_via_sandbox_or_fallback` fast path, EINVAL, and multi-component fallback. All helpers are `#[cfg(unix)]` (the `dir_sandbox` module is itself Unix-only); Windows continues to use path-based stdlib opens per the SEC-1.l NTFS handle audit. Closes (post-wire) 16+ GAPs from the SEC-1 path-syscall coverage audit in PR #4710: #4 (readlinkat) plus the 9 direct openat sites (#9-#17) and lays foundations for #5, #20 (open + readdir-loop) and #6, #27 (recursive *at peel). Refs PR #4710.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
#4729) Captures the receiver-side `--delete` wiring follow-up SEC-1.q (PR #4728) intentionally deferred. The merged engine-side work added a sandbox-aware DeleteFs trait surface plus the DeleteEmitter::with_sandbox carrier, but the receiver loop in crates/transfer/src/receiver/directory/deletion.rs still calls std::fs::remove_file / remove_dir_all / read_dir directly. Lays out three options (migrate receiver to DeleteEmitter, swap to fast_io *_via_sandbox_or_fallback helpers, defer behind Landlock) with LoC scope, risk, test cost, and cross-platform plan. Recommends Option B (direct helper swap) on effort-vs-risk grounds and because the SEC-1.r temp_guard / temp_cleanup PR (#4723) is the established precedent for exactly this carrier-threading shape. Closes audit rows #5-#7 in docs/audits/sec-1-path-syscall-audit-2026-05-22.md once the implementation PR lands. Docs-only.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…-1.q2) (#4732) * feat(transfer): thread DirSandbox through receiver --delete path (SEC-1.q2) Replace the three unanchored syscalls in delete_extraneous_files with their sandbox-anchored siblings so a TOCTOU symlink swap on a top-level extraneous entry cannot redirect the listing or the unlink to an attacker-chosen inode outside the destination tree. Adds fast_io::read_dir_via_sandbox_or_fallback (mirrors the existing *_via_sandbox_or_fallback shape: openat(O_DIRECTORY | O_NOFOLLOW) + fdopendir for single-component scans, std::fs::read_dir fallback otherwise). Closes audit rows #5, #6, #7 from the SEC-1 path-syscall audit. Mirrors the SEC-1.r temp_guard/temp_cleanup carrier-threading pattern (PR #4723): the Option<Arc<DirSandbox>> is cloned once into the map_blocking worker closure and forwarded to every helper call. Sandbox-off and multi-component paths take the documented identical- behaviour fallback. No transfer-crate unsafe is introduced; all unsafe stays behind the existing fast_io safe wrappers. Windows continues through std::fs::remove_file / remove_dir_all / read_dir (NTFS handle semantics already close the symlink-swap window per the SEC-1.l audit). * fix(engine): use Components::next() walk for plan_directory_to_relative SkipWhile<Components, _> has no as_path() method on stable Rust 1.88; the previous skip_while-then-as_path call introduced in SEC-1.q (#4728) slipped through that PR's CI but breaks fmt+clippy on every subsequent master CI run. Switch to a manual Components::next() walk that consumes the leading Prefix/RootDir/CurDir components, then calls as_path() on the unwrapped Components iterator. * fix(transfer): cfg-gate rel_for_unlink to unix to silence Windows unused-var
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…5488) Reduce mimalloc's default 1 GiB virtual arena reservation to 128 MiB and set purge delay to 0 (immediate decommit). RSS-2 profiling identified the default arena reservation and deferred purge as root cause #5 of the 9.8x RSS gap vs upstream, contributing ~16 MiB of committed-but-purged page overhead. Environment variable defaults are set early in main() and respect user-supplied MIMALLOC_* overrides.
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
Testing