Skip to content

feat(fspy): replace Linux LD_PRELOAD and seccomp_unotify with freestanding ELF/SIGSYS tracker - #1029

Open
wan9chi wants to merge 41 commits into
fspy-linux/3-elf-loader-sigsysfrom
fspy-linux/4-linux-elf-sigsys-tracker
Open

wan9chi wants to merge 41 commits into
fspy-linux/3-elf-loader-sigsysfrom
fspy-linux/4-linux-elf-sigsys-tracker

Conversation

@wan9chi

@wan9chi wan9chi commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Motivation

On Linux, fspy previously maintained two separate tracking backends: LD_PRELOAD for dynamically linked glibc binaries and seccomp_unotify for static/musl binaries, leaving gaps for direct-syscall runtimes (such as Bun), preexisting LD_PRELOAD interference, and out-of-process supervisor complexity. Switching Linux to a single freestanding target_os = "none" ELF/SIGSYS launcher (fspy_preload_linux) unifies tracking across glibc, musl, static binaries, and direct-syscall runtimes, eliminates seccomp_unotify, and shares #![no_std] Unix exec/shebang resolution with macOS.

Changes

  • fspy_shared_unix: rewrite Unix exec/shebang/path resolution to #![no_std] shared by fspy_preload_linux and fspy_preload_macos, with unit tests.
  • fspy_preload_linux: add freestanding bare-metal ELF/SIGSYS launcher binary for x86_64-unknown-none and aarch64-unknown-none-softfloat (checked in .github/workflows/ci.yml).
  • fspy_preload_macos: replace fspy_preload_unix and fspy_client_unix with a macOS-only cdylib, and remove fspy_seccomp_unotify.
  • fspy: split src/unix/ into src/linux/ and src/macos/, add tests/linux_hardening.rs, and update tests/untracked_fallback.rs and existing suites.
  • vt_bin: update preexisting_ld_preload snapshot and add 10 JS ecosystem E2E cache fixtures (biome, deno, esbuild, miniflare, oxfmt, rspack, sass-embedded, sharp, tailwindcss-v4, tsx).
  • vt_bin: run the vitest_browser_cache E2E case with Chromium's sandbox on, so the tracker runs alongside the sandboxed renderer's own seccomp filter.
  • CHANGELOG.md: add user-facing changelog entry referencing PRs feat(fspy_nostd): add Unix filesystem, I/O, and path-resolution primitives #1026–feat(fspy): replace Linux LD_PRELOAD and seccomp_unotify with freestanding ELF/SIGSYS tracker #1029.

Stack created with GitHub Stacks CLI • Give Feedback 💬


Note

High Risk
This rewrites Linux task spawn, seccomp, and exec chaining—core cache fingerprinting behavior—with new failure modes (untracked fallback, no_new_privs, ELF-only targets).

Overview
Replaces Linux automatic file tracking: LD_PRELOAD, fspy_preload_unix, and the fspy_seccomp_unotify supervisor are removed in favor of spawning embedded fspy_preload_linux (freestanding ELF on fspy_elf_loader) with SECCOMP_RET_TRAP / SIGSYS tracking in-process. fspy splits src/unix/ into src/linux/ (bootstrap env, seccomp probe, untracked fallback) and src/macos/ (fspy_preload_macos cdylib only).

Workspace deps drop seccompiler, passfd, assertables, memmap2, and fspy_client_unix. CI adds test-linux-arm64, release linux_hardening / linux_syscalls / untracked_fallback tests, clippy for fspy_preload_linux, musl Bun install, and benchmark cleans for cross-target launcher artifacts. Large new/integration suites cover Linux hardening, syscall edge cases, macOS preload behavior, and Bun on Linux in node_fs tests.

Reviewed by Cursor Bugbot for commit 85e8dd8. Bugbot is set up for automated code reviews on this repo. Configure here.

@socket-security

socket-security Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

@wan9chi
wan9chi added this pull request to stack #1030 November 27, 2026 00:33
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change +31.83%  [+17.95% .. +42.15%]  overhead  +115.54%
dynamic/access             change +286.84%  [+147.49% .. +362.81%]  overhead  +368.06%
dynamic/access-relative    change +214.84%  [+123.78% .. +329.91%]  overhead  +381.18%
dynamic/access-contended   change +107.56%  [+80.56% .. +151.23%]  overhead  +142.08%
static/launch              change +12.75%  [ +4.84% .. +19.16%]  overhead  +247.94%
static/access              change -68.58%  [-82.67% .. -63.33%]  overhead  +319.86%
static/access-relative     change -74.14%  [-79.83% .. -61.79%]  overhead  +385.63%
static/access-contended    change -83.38%  [-86.93% .. -78.22%]  overhead  +116.59%

macos

dynamic/launch             change  -5.27%  [ -7.72% ..  -2.47%]  overhead  +209.83%
dynamic/access             change  +1.57%  [ -0.34% ..  +4.17%]  overhead    +0.40%
dynamic/access-relative    change  +0.10%  [ -3.63% ..  +4.26%]  overhead  +241.35%
dynamic/access-contended   change  -0.80%  [ -3.92% ..  +1.20%]  overhead    +1.97%

windows

dynamic/launch             change  +0.47%  [ -0.93% ..  +2.00%]  overhead   +26.98%
dynamic/access             change  +0.18%  [ -0.38% ..  +0.93%]  overhead    +1.30%
dynamic/access-relative    change  +0.18%  [ -1.10% ..  +0.74%]  overhead    +0.76%
dynamic/access-contended   change  +0.36%  [ -0.86% ..  +1.23%]  overhead    +1.23%

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/fspy_preload_linux/src/main.rs Resolved
Comment thread crates/fspy_preload_linux/src/main.rs Resolved
wan9chi and others added 2 commits November 27, 2026 08:45
…nding ELF/SIGSYS tracker

Switch Linux file-access tracking from `LD_PRELOAD` + `seccomp_unotify`
to the freestanding `target_os = "none"` ELF launcher + `SIGSYS`
backend (`fspy_preload_linux`), unify Unix exec/shebang resolution in
`no_std` `fspy_shared_unix`, simplify macOS into `fspy_preload_macos`,
and add Linux hardening and JS ecosystem E2E cache tests:

- `fspy_shared_unix`: rewrite exec/shebang/path resolution to `#![no_std]`
  shared across `fspy_preload_linux` and `fspy_preload_macos`, with unit
  tests for Linux, macOS, and `nostd_exec`.
- `fspy_preload_linux`: freestanding bare-metal ELF/`SIGSYS` launcher
  binary built for `x86_64-unknown-none` and
  `aarch64-unknown-none-softfloat` (checked in CI).
- `fspy_preload_macos`: macOS-only `cdylib` replacing `fspy_preload_unix`
  and `fspy_client_unix`; remove `fspy_seccomp_unotify`.
- `fspy`: split `src/unix/` into `src/linux/` and `src/macos/`, add
  `tests/linux_hardening.rs` and update `tests/untracked_fallback.rs` and
  existing suites.
- `vt_bin`: update `preexisting_ld_preload` snapshot and add 10 JS
  ecosystem E2E cache fixtures (`biome`, `deno`, `esbuild`, `miniflare`,
  `oxfmt`, `rspack`, `sass-embedded`, `sharp`, `tailwindcss-v4`, `tsx`).
- `CHANGELOG.md`: add user-facing entry referencing all 4 PRs in the stack.

Co-authored-by: Gemini 4 Neon <noreply@google.com>
Co-authored-by: Gemini 4 Neon <noreply@google.com>
@wan9chi
wan9chi force-pushed the fspy-linux/4-linux-elf-sigsys-tracker branch from e620865 to 0adff27 Compare November 27, 2026 00:46

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/fspy_preload_linux/src/main.rs Resolved
wan9chi and others added 2 commits November 27, 2026 10:45
Playwright passes `--no-sandbox` by default. Keep the sandbox on so the
Linux tracker runs alongside the sandboxed renderer's own seccomp filter,
which used to trap the tracker's `process_vm_readv` and crash the
renderer.

Also mark the launcher's `copy_user_cstr` calls `unsafe`, matching the
`fspy_elf_loader` API, which now assumes trapped syscall pointers are
valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/fspy_preload_linux/src/main.rs Resolved
Comment thread crates/fspy_preload_linux/src/main.rs Resolved
wan9chi and others added 2 commits November 27, 2026 11:02
…euse resolve_path_at

Now that `fspy_elf_loader` exposes zero-copy `user_cstr` instead of
`copy_user_cstr` / `cached_cstr`:

- Simplify `report_path_at` to borrow the trapped syscall's path string
  directly (zero copies and no arena acquire for absolute paths) and
  delegate relative paths to `fspy_nostd_alloc::fs::resolve_path_at`,
  matching `fspy_preload_macos`.
- Simplify `copy_user_cstr_vec` to use `user_cstr` directly without a
  4 KiB chunk buffer loop while keeping the `MAX_EXEC_STRING_LEN`
  `E2BIG` guard.

Co-authored-by: Gemini 4 Neon <noreply@google.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/fspy_shared_unix/src/macos.rs Resolved
wan9chi and others added 2 commits November 27, 2026 11:17
…alization

Remove defences against cases real programs don't hit:

- Exec scratch: drop the 64-slot pool, generation counter, and the
  `kcmp` / `kill(pid, 0)` detachment probe. Each re-routed exec gets one
  scratch node; only `CLONE_VM` children park theirs after a successful
  prepare, and the kernel's `set_tid_address` clear lets a later exec
  trap free it.
- argv/envp: copy with `RawExec::to_exec` instead of hand-rolled loops
  with a 2 MiB `E2BIG` cap; the kernel enforces its own limits on the
  re-exec.
- Launcher materialization: drop the `XDG_RUNTIME_DIR` / `XDG_CACHE_HOME`
  / `~/.cache` / `/var/tmp` fallback chain. A `noexec` temp directory now
  warns with a `TMPDIR` hint and runs tasks untracked, as before.
- Tests: remove the `kcmp`-denied overflow test and the garbage-pointer
  `EFAULT` test; the posix_spawn RSS test still guards against leaks.

The changelog no longer lists a non-executable stack as a requirement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/fspy_preload_linux/src/main.rs Resolved
Comment thread crates/fspy_preload_linux/src/main.rs Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/fspy_preload_linux/src/main.rs Resolved
wan9chi and others added 3 commits November 27, 2026 12:42
… match main's SIP paths

- Child execs always pass the already-validated descriptor to the new
  launcher image instead of a pathname to reopen. The file can be
  replaced or unlinked in between, and `execve("/proc/self/fd/N")` on an
  `O_CLOEXEC` descriptor closed it on exec, which made the launcher panic.
- A relative path whose directory is too long to name (`ENAMETOOLONG`) or
  can't be allocated now marks the trace incomplete instead of being
  dropped silently. Lookups a sandbox blocks, such as `/proc/self/fd` in
  Chromium's PID namespace, still stay silent.
- macOS: ignore `.` components when matching `/bin` and `/usr/bin` for
  SIP substitution, as `Path::parent` did on main (`/bin/./sh`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ive paths

f624e33 marked a trace incomplete when a relative path's directory was
too long to name (`ENAMETOOLONG`) or naming it ran out of memory. Real
tasks don't hit either: a workspace directory more than 4 KiB deep doesn't
occur, paths outside the workspace are discarded anyway, and a failed
page allocation leaves the process in trouble regardless. Restore the
silent skip, as main's seccomp path did, and drop the test that built an
artificial deep cwd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/fspy_preload_linux/src/main.rs Resolved
Comment thread crates/fspy/src/linux/mod.rs Resolved
wan9chi and others added 2 commits November 27, 2026 13:13
Add `pagefind@1.6.0` to `packages/tools` and a `pagefind_cache` E2E
snapshot fixture (`site/index.html` -> `dist/pagefind/`). On Linux
x86-64, `@pagefind/linux-x64` ships a static-PIE (`ET_DYN`, no
`PT_INTERP`) executable with no `musl` libc restriction, closing the
remaining executable-kind cell alongside dynamic PIE (`biome`/`deno`/
`workerd`/`sass-embedded`), dynamic non-PIE (`bun`/`node`), and static
non-PIE (`esbuild`/`typescript` 7).

Co-authored-by: Gemini 4 Neon <noreply@google.com>
…before spawn

- In `fspy_preload_linux`, record the target path via `report_path_at`
  (honoring `AT_EMPTY_PATH`) before replaying `execveat(AT_EXECVE_CHECK)`
  so Linux 6.14+ executability probes are tracked like `faccessat2`.
- In `fspy::linux`, construct the tokio `pipe::Receiver` before spawning
  the launcher child so a setup failure cannot leave an orphaned child.

Co-authored-by: Gemini 4 Neon <noreply@google.com>
@wan9chi wan9chi added the ci: full Run the slow CI jobs (macOS x64, musl) on this pull request label Nov 27, 2026
wan9chi and others added 2 commits November 27, 2026 13:21
On Alpine Linux (musl), `/bin/sh` is a multi-call BusyBox binary that
dispatches based on `argv[0]`'s basename, so symlinking `/bin/sh` to
`.../xxxx...` failed with `applet not found`. Put the length padding in
the parent directory and keep the symlink named `sh`.

Co-authored-by: Gemini 4 Neon <noreply@google.com>
Now that Bun tests run on Linux (including Alpine musl via
`@oven/bun-linux-x64-musl`), run `pnpm --filter vite-task-tools rebuild bun`
in `test-musl` before running ignored tests. Narrowed to `bun` so `deno`
and `workerd` (which do not ship musl binaries) do not fail postinstall.

Co-authored-by: Gemini 4 Neon <noreply@google.com>
wan9chi and others added 9 commits November 27, 2026 17:43
…d arm64 CI

Harden the Linux ELF/SIGSYS tracker across fspy, fspy_preload_linux, and fspy_shared_unix:
- Probe seccomp availability on a short-lived OS thread using SECCOMP_RET_TRAP instead of fork()
- Remove local noexec checks in favor of vt_materialized_artifact and lazily re-materialize on ENOENT
- Avoid error-pipe FD < 3 collisions and kill/wait child on cancellation mid-handshake
- Use fspy_elf_loader::try_exec_elf on_ready to eliminate error-pipe TOCTOU and scrub __FSPY_BOOTSTRAP from /proc/self/environ
- Reclaim CLONE_VM ExecScratch via on_vfork_return and kcmp(KCMP_VM) with set_tid_address fallback
- Fix O_PATH shebang execveat(AT_EMPTY_PATH), O_RDONLY|(O_CREAT|O_TRUNC) open_mode, renameat2(RENAME_EXCHANGE), and ensure_env/RawExec::to_exec hardening
- Add Linux hardening and syscall integration tests plus release-mode and linux-arm64 CI jobs

Co-authored-by: Gemini 4 Neon <noreply@google.com>
…wExec second pass

Co-authored-by: Gemini 4 Neon <noreply@google.com>
Co-authored-by: Gemini 4 Neon <noreply@google.com>
…enOptions does not mask it

Co-authored-by: Gemini 4 Neon <noreply@google.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/fspy_preload_linux/src/main.rs Resolved
…_tid_address fallback

Co-authored-by: Gemini 4 Neon <noreply@google.com>
wan9chi added a commit to voidzero-dev/vite-plus that referenced this pull request Nov 27, 2026
Reset preview branch onto main and update vite-task dependencies to
74fe011e039832bdab2ac156c8ea1c3e87d0910d (voidzero-dev/vite-task#1029).

- Add bare-metal targets (aarch64-unknown-none-softfloat,
  x86_64-unknown-none) to rust-toolchain.toml for fspy_preload_linux
- Adapt vp_app_target to vt_select::select_interactive / SelectOutcome

Co-authored-by: Gemini 4 Neon <noreply@google.com>
wan9chi and others added 2 commits November 28, 2026 00:38
…S SPAWN_CHDIRS fork-safe

Co-authored-by: Gemini 4 Neon <noreply@google.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/fspy_preload_linux/src/main.rs Resolved
wan9chi and others added 2 commits November 28, 2026 01:10
…t, and deferred macOS spawn chdir

Co-authored-by: Gemini 4 Neon <noreply@google.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/fspy/src/linux/mod.rs Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Comment thread crates/fspy_preload_linux/src/main.rs Resolved
wan9chi and others added 2 commits November 28, 2026 01:30
…rify launcher-vanished spawn error

Co-authored-by: Gemini 4 Neon <noreply@google.com>
… document /proc/self/exe caveats

- macOS posix_spawn: add `EncodedPayload::inject_env` and `ResolvedChdir::Unresolvable` so relative programs with an unresolvable `addfchdir_np(fd)` still inject tracking env and forward directly to `original` instead of resolving against the parent CWD; also rekey `SPAWN_CHDIRS` when libsystem reallocates `*file_actions` across subsequent `addopen`/`addclose`/`adddup2`/`addinherit_np`/`add*chdir_np` calls.
- Linux preload: re-probe `kcmp(my_pid, my_pid, KCMP_VM)` on unexpected `shares_vm_with` errors and flip `KCMP_VM_AVAILABLE` off if blocked so subsequent `CLONE_VM` children fall back to `set_tid_address`.
- `fspy_elf_loader`: document `/proc/self/exe` nuances for memfd/unlinked and in-place replaced targets in `README.md`.

Co-authored-by: Gemini 4 Neon <noreply@google.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

wan9chi and others added 2 commits November 28, 2026 12:29
Co-authored-by: Gemini 4 Neon <noreply@google.com>
Co-authored-by: Gemini 4 Neon <noreply@google.com>
wan9chi and others added 3 commits November 28, 2026 12:55

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 415f56c. Configure here.

Comment thread crates/fspy_shared_unix/src/linux.rs Resolved
… to prevent ETXTBSY

Co-authored-by: Gemini 4 Neon <noreply@google.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: full Run the slow CI jobs (macOS x64, musl) on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant