#bindings #interface #sanitizer #dfsan

sanitizers

FFI bindings for the sanitizers interfaces

2 releases

0.0.2 Feb 28, 2024
0.0.1 Feb 16, 2024

#8 in #sanitizer

Download history 138/week @ 2024-02-13 19/week @ 2024-02-20 202/week @ 2024-02-27 73/week @ 2024-03-05 3/week @ 2024-03-12 2/week @ 2024-03-26 16/week @ 2024-04-02

74 downloads per month

MIT/Apache

28KB
66 lines

sanitizers

Build Status

FFI bindings for the sanitizers interfaces.

Installation

To install the sanitizers crate:

  1. On a command prompt or terminal with your package root's directory as the current working directory, run the following command:

    cargo add sanitizers
    

Or:

  1. Add the sanitizers crate to your package root's Cargo.toml file:

    [dependencies]
    sanitizers = "0.0.1"
    
  2. On a command prompt or terminal with your package root's directory as the current working directory, run the following command:

    cargo fetch
    

Usage

To use the sanitizers crate:

  1. Import the sanitizer module or funtions from the sanitizers crate. E.g.:

    use sanitizers::dfsan::*;
    
  2. Use the provided interface for the sanitizer. E.g.:

    ...
    let mut i = 1i64;
    let i_ptr = &mut i as *mut i64;
    let i_label: dfsan_label = 1;
    unsafe {
        dfsan_set_label(i_label, i_ptr as *mut c_void, size_of::<i64>());
    }
    
    let new_label = unsafe { dfsan_get_label(i) };
    ...
    
  3. Build your package with the sanitizer enabled. It is recommended to rebuild the standard library with the sanitizer enabled by using the Cargo build-std feature (i.e., -Zbuild-std) when enabling the sanitizer. E.g.:

    RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=lld -Zsanitizer=dataflow \
      -Zsanitizer-dataflow-abilist=/path/to/abilist.txt" \
      cargo build -Zbuild-std -Zbuild-std-features \
      --target x86_64-unknown-linux
    

Contributing

See CONTRIBUTING.md.

License

Licensed under the Apache License, Version 2.0 or the MIT License. See LICENSE-APACHE or LICENSE-MIT for license text and copyright information.

No runtime deps