
* Fixes to main * Add librasan * Party like it's 2024 * Fix snapshot module to work with guest asan * Fix guest_asan module * Fixes to runner * Fix linking issues using a REL * Fix qemu_launcher * Change modify_mapping to a method * Fix gasan_test * Remove debug from Justfile * Optimize release build of librasan * Set ulimit for qasan and gasan tests * Tidy up symbol renaming * Add missing symbols for PPC * Change to support rustix 1.0.0 * Canonicalize the CUSTOM_ASAN_PATH * Review changes * Restructure backends * release_max_level_info * More review changes * Clippy fixes * Changes to reduce the burden on the CI * Fix macos clippy --------- Co-authored-by: Your Name <you@example.com>
66 lines
1.9 KiB
Rust
66 lines
1.9 KiB
Rust
#[cfg(test)]
|
|
#[cfg(all(feature = "guest", target_pointer_width = "64"))]
|
|
mod tests {
|
|
use std::sync::Mutex;
|
|
|
|
use asan::{
|
|
mmap::libc::LibcMmap,
|
|
shadow::{
|
|
PoisonType, Shadow,
|
|
guest::{DefaultShadowLayout, GuestShadow},
|
|
},
|
|
symbols::dlsym::{DlSymSymbols, LookupTypeNext},
|
|
};
|
|
use spin::Lazy;
|
|
|
|
type GS = GuestShadow<LibcMmap<DlSymSymbols<LookupTypeNext>>, DefaultShadowLayout>;
|
|
|
|
static INIT_ONCE: Lazy<Mutex<()>> = Lazy::new(|| {
|
|
{
|
|
env_logger::init();
|
|
};
|
|
Mutex::new(())
|
|
});
|
|
|
|
fn get_shadow() -> GS {
|
|
drop(INIT_ONCE.lock().unwrap());
|
|
GS::new().unwrap()
|
|
}
|
|
|
|
#[test]
|
|
fn test_poison_example1() {
|
|
let mut shadow = get_shadow();
|
|
// poison - start: 0x7fff2bffff00, len: 0x100, pioson: AsanUser
|
|
// is_poison - start: 0x7fff2bfffc01, len: 0x300
|
|
assert_eq!(
|
|
shadow.poison(0x7fff2bffff00, 0x100, PoisonType::AsanUser),
|
|
Ok(())
|
|
);
|
|
assert_eq!(shadow.is_poison(0x7fff2bfffc01, 0x300), Ok(true));
|
|
}
|
|
|
|
#[test]
|
|
fn test_poison_example2() {
|
|
let mut shadow = get_shadow();
|
|
// poison - start: 0x7dff13ffffff, len: 0x3b9, pioson: AsanUser
|
|
// is_poison - start: 0x7dff14000302, len: 0x2
|
|
assert_eq!(
|
|
shadow.poison(0x7dff13ffffff, 0x3b9, PoisonType::AsanUser),
|
|
Ok(())
|
|
);
|
|
assert_eq!(shadow.is_poison(0x7dff14000302, 0x2), Ok(true));
|
|
}
|
|
|
|
#[test]
|
|
fn test_poison_example3() {
|
|
let mut shadow = get_shadow();
|
|
// poison - start: 0x7fffffffff00, len: 0x100, pioson: AsanUser
|
|
// is_poison - start: 0x7fffffffff00, len: 0xff
|
|
assert_eq!(
|
|
shadow.poison(0x7fffffffff00, 0x100, PoisonType::AsanUser),
|
|
Ok(())
|
|
);
|
|
assert_eq!(shadow.is_poison(0x7fffffffff00, 0xff), Ok(true));
|
|
}
|
|
}
|