Skip to content

Expanded API & added common interceptors. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 3, 2025
Merged

Conversation

icmccorm
Copy link

@icmccorm icmccorm commented Mar 25, 2025

The goal here is to expand our API so that it can be semi-stable moving forward. This is the first of a series of two PRs. Once this and #9 are merged, the second PR will be created for the Rust runtime.

LLVM Runtime

  • Adds an internal API (bsan_internal.h and bsan_internal.cpp) with new endpoints for loading and storing provenance, reading, writing, allocating, deallocating, pushing and popping stack frames, and copying provenance in shadow memory. None have return values; instead, we use return pointers.
  • Expands the external API (bsan.h and bsan.cpp) to include matching functions for the internal API.
  • Adds initial support for common interceptors.
  • Our set of allocation functions is now BsanHooks. Both malloc and free are stored in a separate struct member, BsanAllocHooks. This could remove an additional memory access when accessing the Allocator in the Rust runtime. Also, instead of implementing Allocator for & 'static GlobalContext, we can implement it for BsanAllocHooks and have it be Copy. This lets us implement functions like fn(&'a GlobalState) -> Self where Self is something like Vec<u8, BsanAllocHooks> without having requiring 'a to be 'static.
  • Adds a print function and an exit function to control output from

Instrumentation Pass

  • Adds the corresponding API function declarations to the LLVM module.
  • Adds BorrowVisitor, which will collect and instrument relevant instructions in depth-first order, mirroring patterns used in ASAN and MSAN.
  • Adds thread-local storage (__bsan_retval_tls and __bsan_param_tls) for the provenance of parameters and return values.

@icmccorm icmccorm requested a review from obraunsdorf March 25, 2025 03:07
@obraunsdorf obraunsdorf merged commit 8ae57a6 into bsan Apr 3, 2025
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.

2 participants