Repository navigation
feat(fspy_elf_loader): add SIGSYS syscall interception, signal virtualization, and /proc/exe rewriting - #1028
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>
c34be75 to
17f3396
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 17f3396. Configure here.
| Sysno::openat as u32, | ||
| Sysno::openat2 as u32, | ||
| Sysno::stat as u32, | ||
| Sysno::lstat as u32, |
There was a problem hiding this comment.
Unnecessary trapping of lstat without rewrite handling
Medium Severity
Sysno::lstat is included in BASE_TRAPPED_SYSCALLS for x86_64 but has no corresponding handler in rewrite_path_arg or dispatch_phase1. Every lstat from outside the launcher's PF_X range triggers a SIGSYS trap, runs through Phase 1 dispatch, falls through all match arms, and gets replayed unchanged via PHASE2_REPLAY. Since lstat never follows symlinks, /proc/*/exe rewriting is intentionally inapplicable, making the trap pure overhead. It's the only path-based syscall in the base set without rewrite logic.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 17f3396. Configure here.
| let bump = fspy_nostd_alloc::pooled_bump(); | ||
| let Ok(Some(base)) = fspy_nostd_alloc::fs::fd_path(&bump, borrowed_dirfd) else { | ||
| return (false, Some(raw)); | ||
| }; |
There was a problem hiding this comment.
Relative /proc/*/exe paths with AT_FDCWD undetected
Low Severity
The comment at line 406 says "resolve dirfd (or cwd for AT_FDCWD)" but BorrowedFd::try_borrow_raw(AT_FDCWD) returns None for the negative sentinel value -100, causing the function to return (false, Some(raw)) without matching. Relative paths like "../self/exe" from within /proc/ are never detected as /proc/*/exe references when dirfd is AT_FDCWD. A getcwd-based fallback is needed to resolve the working directory for AT_FDCWD, similar to what resolve_exe_path_for_fd already does for relative fallback paths.
Reviewed by Cursor Bugbot for commit 17f3396. Configure here.


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(including AArch64EXTRA_MAGIC/GCS and x86-64fpregs/CET), and masked-wait deferred-SIGSYShandling (with unit tests).sigsys/proc_exe.rsandsigsys/usermem.rs:/proc/*/exepath rewriting and fault-safe user memory copy/probe helpers with sandbox fallbacks (with unit tests).fspy_elf_loader_test_launcherandfspy_elf_loader_tests: wire--test-interceptorand add the 39-test Linux virtualization integration suite infixtures/virtualization.candtests/exec_elf.rs.Stack created with GitHub Stacks CLI • Give Feedback 💬
Note
High Risk
Large changes to seccomp, signal delivery, vfork/posix_spawn, and exec/syscall interception—bugs here can crash processes, break threading, or mis-report process identity.
Overview
Adds a full in-process
SIGSYS+ seccomp-BPF runtime tofspy_elf_loaderso tracked Linux targets can be intercepted withoutLD_PRELOADorseccomp_unotify.exec_elfnow validates the launcher's fixedPF_Xrange, callssigsys::installbefore entry, and accepts an optionalSyscallInterceptorthat can replay, short-circuit, or trigger a replacementexecve.The new
sigsysmodule wires arch-specific trampolines (x86-64 / AArch64), a static BPF program (IP allowlist, idempotent filter probe, conditionalclone/ masked-wait traps,ENOSYSforclone3/io_uring_setup), virtualrt_sigaction/rt_sigprocmask/ fork / vfork** handling with a pooled private handler stack, **/proc/*/exerewriting** on path-following syscalls, and **fault-safe user memory** copies. Tests gain a **--test-interceptor` launcher path and virtualization ELF fixtures.Reviewed by Cursor Bugbot for commit 17f3396. Bugbot is set up for automated code reviews on this repo. Configure here.