Skip to content

fix(runtime): keep preload shims transparent on failure - #606

Open
yunwei37 wants to merge 6 commits into
masterfrom
fix/preload-shim-transparency
Open

fix(runtime): keep preload shims transparent on failure#606
yunwei37 wants to merge 6 commits into
masterfrom
fix/preload-shim-transparency

Conversation

@yunwei37

@yunwei37 yunwei37 commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

  • make syscall-server, agent, and transformer failures fall back without terminating the host
  • keep preload logging off stdout/stderr by default and make logger sink failures silent
  • preserve entry errno, relative openat semantics, and single-call mmap fallback behavior
  • restore transformed text permissions on every exit path and keep partially initialized hooks delegated to the original syscall
  • clean up partially initialized agent context, PID, and shared-memory state without racing the IPC thread
  • route runtime trace output through the configured logger and remove teardown stderr writes
  • record the preload safety contract in the root maintenance instructions, with AGENTS.md linked to the existing instruction file and no root docs/ directory
  • add failure-injection regression coverage for shared-memory exhaustion, logger write failure, mmap/openat fallback, missing agent state, transformer cleanup, host exit status, and host stdio preservation

Validation

  • cmake --build build --target bpftime-agent bpftime-syscall-server bpftime_runtime_tests bpftime-shm-allocation-test-helper -j2
  • build/runtime/unit-test/bpftime_runtime_tests '[allocation],[preload]' (7 test cases, 42 assertions)
  • 74 runtime test cases that do not require the LLVM VM backend (8,575,172 assertions)
  • local example/minimal uprobe end-to-end run with the repository test driver: server startup, agent attach, and target_func called. assertion passed
  • local privileged example/minimal syscall-transformer end-to-end run with the repository test driver: text rewrite, agent install, and syscall write called. assertion passed
  • integrated examples workflow on the reviewed code head: 120/120 jobs successful
  • independent review of the final code diff found no blocking issues

The local build used the ubpf backend, so the eight attach/tail-call cases that require the LLVM VM backend were excluded from the broader local runtime-test run. Console logging was explicitly selected only for the two example assertions.

Fixes #605

@yunwei37

Copy link
Copy Markdown
Member Author

Addressed the final review findings in 796c895:

  • removed the duplicate original mmap call and preserved relative openat fallback semantics;
  • captured caller errno at every wrapper boundary and restored it on successful fallback;
  • made spdlog sink write/flush failures silent;
  • added RAII cleanup for text permissions and Capstone state;
  • added deterministic preload regressions for /dev/full, exact-once mmap, relative openat, errno preservation, and RX -> RWX -> RX transformer fault cleanup.

The focused suite now passes 7 test cases / 42 assertions, and the broader non-LLVM run passes 74 test cases / 8,575,172 assertions. Final independent review found no blocking issues. I will continue monitoring checks and review feedback.

@yunwei37
yunwei37 force-pushed the fix/preload-shim-transparency branch from 69f5113 to 3d54f8b Compare July 22, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LD_PRELOAD shims must remain transparent on internal failures

2 participants