Skip to content

feat(fspy): detect nested fspy tracking across Linux, macOS, and Windows - #1034

Open
wan9chi wants to merge 7 commits into
fspy-linux/4-linux-elf-sigsys-trackerfrom
fspy-linux/5-nested-fspy-detection
Open

wan9chi wants to merge 7 commits into
fspy-linux/4-linux-elf-sigsys-trackerfrom
fspy-linux/5-nested-fspy-detection

Conversation

@wan9chi

@wan9chi wan9chi commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Motivation

When a cached vp run task invokes a nested vp run subprocess (for example, through a wrapper script or package script), attempting to install a second automatic file-access tracker inside an already-tracked process either fails (on Linux, where #1029 removes the Linux-only mincore/process_vm_readv probe and rejects nested fspy_preload_linux mappings with EEXIST) or duplicates interception and breaks outer tracking (on macOS and Windows).

Summary

  • Shared sentinel probe (fspy_shared::probe): Define hardcoded random-GUID sentinel paths beneath the OS null device (/dev/null/fspy_probe_92e41940-369e-42f1-876f-a8e2a614fbf2 on Linux and macOS, \??\NUL\fspy_probe_92e41940-369e-42f1-876f-a8e2a614fbf2 on Windows).
  • Preload short-circuiting across all platforms:
    • Linux (fspy_elf_loader + fspy_preload_linux): Add SyscallAction::Return(isize) and short-circuit Sysno::faccessat matching the sentinel path to Ok(SyscallAction::Return(0)) without recording a PathAccess.
    • macOS (fspy_preload_macos): Short-circuit faccessat matching the sentinel path to return 0 without recording a PathAccess.
    • Windows (fspy_preload_windows): Short-circuit NtQueryAttributesFile matching the sentinel path to zero-fill FILE_BASIC_INFORMATION and return STATUS_SUCCESS without recording a PathAccess.
  • Cached nested detection and clean delegation (fspy):
    • Probe the sentinel path directly via faccessat / NtQueryAttributesFile, cached process-wide in OnceLock<bool>.
    • When nested, run child commands directly without installing a second tracker (leaving the outer tracker to capture all nested accesses) and report UntrackedReason::Nested instead of UntrackedReason::Incomplete.
  • Dedicated user-facing cache-not-updated reason (vt):
    • Introduce CacheNotUpdatedReason::NestedTracking / SavedCacheNotUpdatedReason::NestedTracking explaining that automatic file tracking is already active in a parent task and that configuring input and output manually still enables caching on the nested task.
  • Note on mixed versions: If an older outer vp binary (without the sentinel probe interceptor) spawns a newer inner vp, the sentinel probe will not be intercepted and will fall back to the existing behavior.

Stacked on #1029.


Note

Medium Risk
Changes cross-platform syscall interception, seccomp SIGSYS handling, and cache eligibility for nested runs; mistakes could break automatic tracking or incorrectly cache nested tasks.

Overview
When a cached outer task spawns another vp run, the inner runner now detects an active outer file tracker and stops installing a second tracker, so nested work stays attributed to the parent and the outer task can still cache correctly.

Detection uses a shared null-device sentinel path (fspy_shared::probe). The outer preload short-circuits that probe on Linux (SyscallAction::Return), macOS (faccessat), and Windows (NtQueryAttributesFile) without logging it as a file access. Inner fspy caches the probe result, runs children untracked when nested, and surfaces UntrackedReason::Nested instead of treating the case as incomplete tracking.

vt maps that to NestedTracking, with a summary that tracking is already active in a parent and that manual input / output can still cache the nested task. TrackingIncomplete is folded into UntrackedReason::Incomplete for the remaining partial-trace cases.

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

@wan9chi
wan9chi force-pushed the fspy-linux/5-nested-fspy-detection branch from 297ebcc to ecbc3ce Compare November 28, 2026 04:49
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  +0.17%  [ -1.98% ..  +1.94%]  overhead  +110.97%
dynamic/access             change  -0.11%  [ -1.25% ..  +1.27%]  overhead  +382.19%
dynamic/access-relative    change  -2.27%  [ -4.13% ..  -0.47%]  overhead  +425.40%
dynamic/access-contended   change  +0.68%  [ -2.90% ..  +3.57%]  overhead  +170.53%
static/launch              change  -0.21%  [ -2.04% ..  +2.07%]  overhead  +249.40%
static/access              change  -0.51%  [ -1.59% ..  +0.75%]  overhead  +382.76%
static/access-relative     change  -2.87%  [ -4.48% ..  -1.09%]  overhead  +422.17%
static/access-contended    change  +1.89%  [ -2.57% ..  +4.49%]  overhead  +159.59%

macos

dynamic/launch             change  -0.19%  [ -2.25% ..  +2.83%]  overhead  +216.42%
dynamic/access             change  +0.00%  [ -1.60% ..  +2.30%]  overhead    +3.30%
dynamic/access-relative    change  -0.11%  [ -2.82% ..  +2.35%]  overhead  +261.05%
dynamic/access-contended   change  +0.76%  [ -1.40% ..  +2.25%]  overhead    +3.64%

windows

dynamic/launch             change  +0.37%  [ -0.77% ..  +1.40%]  overhead   +26.94%
dynamic/access             change  -0.19%  [ -1.12% ..  +0.39%]  overhead    +0.98%
dynamic/access-relative    change  +0.19%  [ -0.56% ..  +0.93%]  overhead    +0.76%
dynamic/access-contended   change  +0.18%  [ -0.72% ..  +1.26%]  overhead    +1.12%

@wan9chi
wan9chi force-pushed the fspy-linux/5-nested-fspy-detection branch 3 times, most recently from 2d67721 to 8c84032 Compare November 28, 2026 04:59
…-device sentinel probe

Co-authored-by: Gemini 4 Neon <noreply@google.com>
@wan9chi
wan9chi force-pushed the fspy-linux/5-nested-fspy-detection branch from 8c84032 to e970d5c Compare November 28, 2026 05:07
@wan9chi
wan9chi added this pull request to stack #1030 November 28, 2026 05:24
wan9chi and others added 6 commits November 29, 2026 02:20
Read the nested probe path with user_path and match the new loss tests
against UntrackedReason::Incomplete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…5-nested-fspy-detection

# Conflicts:
#	crates/fspy_preload_linux/src/main.rs
…5-nested-fspy-detection

# Conflicts:
#	crates/fspy/tests/macos_preload.rs
#	crates/fspy/tests/untracked_fallback.rs
#	crates/fspy_preload_linux/src/main.rs

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant