Repository navigation
Conversation
fspy benchmarklinuxmacoswindows |
…lization, and /proc/exe rewriting Add the in-process SIGSYS syscall virtualization engine to `fspy_elf_loader`, wire it into the freestanding test launcher, and add unit and Linux virtualization integration tests: - `sigsys/filter.rs`: seccomp-BPF filter construction allowlisting the launcher's `PF_X` range, rejecting `io_uring_setup` with `ENOSYS`, and trapping signal/exec/`/proc/exe` and caller-supplied syscalls. - `sigsys/signal.rs` & `sigsys/arch.rs`: per-thread virtual `SIGSYS` disposition/mask virtualization, pooled SIGSYS stacks, `vfork` / `posix_spawn` altstack handoff with `rt_sigreturn` (including AArch64 `EXTRA_MAGIC`/GCS and x86-64 `fpregs`/CET handling), and masked-wait deferred-SIGSYS handling. - `sigsys/proc_exe.rs` & `sigsys/usermem.rs`: `/proc/*/exe` path rewriting and fault-safe user memory copy/probe helpers. - `fspy_elf_loader_tests`: 39-test Linux integration suite in `fixtures/virtualization.c` and `tests/exec_elf.rs`. Co-authored-by: Gemini 4 Neon <noreply@google.com>
Co-authored-by: Gemini 4 Neon <noreply@google.com>
…lter Co-authored-by: Gemini 4 Neon <noreply@google.com>
wan9chi
force-pushed
the
fspy-linux/3-elf-loader-sigsys
branch
from
November 27, 2026 00:46
c34be75 to
17f3396
Compare
… of via process_vm_readv The SIGSYS runtime copied every user pointer it read or wrote (paths, `struct sigaction`, signal sets, `open_how`, timeouts, the `/proc/self/exe` readlink buffer) through `process_vm_readv` / `process_vm_writev` on its own pid, so a bad pointer returned `EFAULT` instead of crashing the handler. That costs a `getpid` plus a copy syscall per pointer, and it breaks under filters the target installs itself: Chromium's sandboxed renderer traps `process_vm_readv`, and the trap reached Chromium's handler, which crashed the renderer. Assume the pointers are valid, as the macOS and Windows preloads already do for the calls they interpose, and access them directly. Addresses in the first page (`NULL`, small integers) still fail with `EFAULT` without being touched. The copy helpers become `unsafe fn` with that contract. Abseil's `rt_sigprocmask(~0, addr)` address probe already goes straight to the kernel, so it keeps returning `EFAULT`/`EINVAL` as before. Tests that checked fault-safe copies of bad pointers, including the `process_vm_*`-denied fallback, are removed; the Abseil probe cases stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ched_cstr Now that `usermem` reads trapped syscall arguments directly instead of copying through `process_vm_readv`, copying path arguments into a 4 KiB stack buffer in `dispatch_phase1` / `proc_exe::rewrite_path_arg` and caching that slice on `Syscall` is unnecessary: - Replace `usermem::read_user_cstr` / `copy_user_cstr` with zero-copy `user_cstr(addr) -> Result<CStr<'_, Thin>>` (still rejecting page 0 with `Error::FAULT`). - Remove `Prefetched::path`, `Syscall::cached_cstr`, and the 4 KiB `path_buf` from `dispatch_phase1` and `proc_exe::rewrite_path_arg`. - Update `fspy_elf_loader_test_launcher` to use `user_cstr` directly. Co-authored-by: Gemini 4 Neon <noreply@google.com>
…ux/3-elf-loader-sigsys # Conflicts: # crates/fspy_elf_loader/src/lib.rs
…om the vfork path The vfork/posix_spawn child returns through a copied signal frame. The copy also disabled an x86 CET shadow stack or an Arm GCS in the child (with a hand-written register restore when either was locked), cleared the GCS record, and relocated SVE/SME `EXTRA_MAGIC` payloads. None of that runs for real programs: userspace CET shadow stacks are opt-in, GCS needs hardware that isn't deployed, and the kernel discards SVE state on syscall entry, so a trapped frame only outgrows `__reserved` with live SME `ZA` state. Copy the fixed-size frame and return via `rt_sigreturn` instead; such processes are documented as unsupported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The typos check rejects the bare abbreviation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…roc/*/exe comment `lstat` never follows `/proc/self/exe`, so trapping it in the base set only added a SIGSYS round trip. The `/proc/*/exe` matcher does not resolve paths relative to the cwd; say so instead of claiming it does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_exe `AT_FDCWD` is `-100` on Linux, not `-1`, so `BorrowedFd::try_borrow_raw` returns `Some(CWD)` and `fd_path` resolves `getcwd`. Restore the comment to match the actual behavior. Co-authored-by: Gemini 4 Neon <noreply@google.com>
… expand integration tests - Add execve and execveat to BASE_TRAPPED_SYSCALLS for standalone /proc/*/exe virtualization - Drop SA_NODEFER on the loader SIGSYS handler so async SIGSYS cannot preempt Phase 1 on stack_pool - Clear pending virtual SIGSYS across all threads in the process on rt_sigaction(SIGSYS, SIG_IGN) - Write masked-wait syscall results into ucontext before deliver_sigsys_now and deliver deferred SIGSYS on handler return - Stop lexically collapsing '..' in proc_exe::normalize_abs_path and skip rewriting non-readlink syscalls for ' (deleted)' executables - Expose fallible try_exec_elf(..., on_ready) and SyscallInterceptor::on_vfork_return validated inside PF_X - Add usermem::user_cstr_bounded bounded at PATH_MAX for /proc/*/exe matching - Replace ACTION_LOCK and waitid(WNOWAIT) lock-stealing with a lock-free SeqAction seqlock - Simplify replay_masked_wait_deferring_sigsys by removing MAX_ZERO_POLL_RETRIES, clear_pselect_fdsets, and masked_wait_return_pc - Simplify BPF filter with symbolic jump patching and assert!(start_hi == end_hi), add PROT_NONE guard pages and Relaxed load guard to stack_pool, and remove dead stores/fallbacks - Add integration tests for AArch64 x28, raw current_sp vfork save_top + separate altstack, io_uring_setup ENOSYS, SyscallAction::Execve failure/cleanup, inherited SIGSYS state, sigqueue/SA_NODEFER/SIG_IGN/epoll_pwait edge cases, raw SYS_fork + mismatched-fingerprint re-exec, /proc/*/exe edge cases, stack pool overflow, and blocking openat2 FIFO EINTR Co-authored-by: Gemini 4 Neon <noreply@google.com>
…ux/3-elf-loader-sigsys # Conflicts: # crates/fspy_elf_loader/src/lib.rs # crates/fspy_elf_loader/src/mapping.rs # crates/fspy_elf_loader/src/stack.rs
…ux/3-elf-loader-sigsys
…ux/3-elf-loader-sigsys
…ad INFO_LOCK_BIT leak Co-authored-by: Gemini 4 Neon <noreply@google.com>
…D_SLOTS unit tests Co-authored-by: Gemini 4 Neon <noreply@google.com>
…roc/self/exe re-exec Co-authored-by: Gemini 4 Neon <noreply@google.com>
…ux/3-elf-loader-sigsys
…ux/3-elf-loader-sigsys
…and preserve CLONE_VM SIGSYS overrides Co-authored-by: Gemini 4 Neon <noreply@google.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit da112b1. Configure here.
…ux/3-elf-loader-sigsys # Conflicts: # crates/fspy_elf_loader/Cargo.toml # crates/fspy_elf_loader/src/image.rs
Co-authored-by: Gemini 4 Neon <noreply@google.com>
…ux/3-elf-loader-sigsys
This branch has not been deployed
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.



Motivation
To track filesystem accesses uniformly across glibc, musl, static binaries, and direct-syscall runtimes on Linux without
LD_PRELOADorseccomp_unotify, the userland ELF loader needs an in-process seccomp-BPFSECCOMP_RET_TRAP(SIGSYS) virtualization runtime that transparently preserves target signal semantics,vfork/posix_spawn, multithreading, and/proc/*/exeidentity while exposing a clean syscall-interception hook.Changes
sigsys/filter.rs: seccomp-BPF filter allowlisting the launcher's fixedPF_Xrange, rejectingio_uring_setupandclone3withENOSYS, and trapping signal,exec,/proc/*/exe, and caller-supplied syscalls (with unit tests).sigsys/signal.rs,sigsys/arch.rs, andsigsys/stack_pool.rs: per-thread virtualSIGSYSdisposition/mask virtualization, pooled privateSIGSYSstacks,vfork/posix_spawnaltstack handoff returning viart_sigreturn(relocating x86-64fpregs; CET shadow stacks, Arm GCS, and SMEEXTRA_MAGICframes are unsupported), and masked-wait deferred-SIGSYShandling (with unit tests).sigsys/proc_exe.rsandsigsys/usermem.rs:/proc/*/exepath rewriting (with unit tests) and user memory copies that, like the macOS and Windows preloads, assume the pointers passed to syscalls are valid.fspy_elf_loader_test_launcherandfspy_elf_loader_tests: wire--test-interceptorand add the 38-test Linux virtualization integration suite infixtures/virtualization.candtests/exec_elf.rs.Stack created with GitHub Stacks CLI • Give Feedback 💬
Note
High Risk
Introduces seccomp filtering, signal virtualization, and exec/fork/vfork handling on the critical path into untrusted target code; bugs could crash processes, break threading/spawn, or mis-report process identity.
Overview
Adds a freestanding
SIGSYS+ seccomp-BPF runtime tofspy_elf_loaderso tracked Linux processes can intercept syscalls withoutLD_PRELOADorseccomp_unotify.exec_elf(and newtry_exec_elf) now install this layer before entry, accept an optionalSyscallInterceptorfor extra trapped syscalls, and validate interceptor hooks live in the launcher’sPF_Xrange.The
sigsysstack includes a cBPF filter (launcher IP allowlist, conditionalclone/vforkand masked-wait traps,clone3/io_uring_setup→ENOSYS, idempotent filter fingerprint), architecture-specific naked trampolines with a pooled private handler stack, virtualizedrt_sigaction/rt_sigprocmask/rt_sigpending/ fork paths, and/proc/*/exerewriting plus directreadlinkhandling so the target sees its real executable path.ELF mapping and reservation move from panicking
map/reserveto fallibletry_map/try_reserve_*. Tests gainvirtualization.cfixtures and expandedfspy_elf_loader_tests/ launcher wiring for interception coverage.Reviewed by Cursor Bugbot for commit e3e7500. Bugbot is set up for automated code reviews on this repo. Configure here.