pub macro no_asan_shim {
($([$($tt:tt)*])?|$($i:ident:$ty:ty),*$(,)?| $(-> $ret:ty)? $e:block) => { ... },
($([$($tt:tt)*])?|$($i:ident:$ty:ty),*$(,)?| $e:expr) => { ... },
}Available on crate feature
full only.Expand description
Prevents the contained code from being checked with the address sanitizer.
This should be used when accessing memory known to be marked as poisoned, for example inside a heap allocator when reading internal metadata contained in a heap headers zone. This does not need to be used to wrap any functions in this module.
This macro should be called as a wrapper around closure-like syntax, either as
no_asan_shim!(|a: usize| -> usize { a + 1 }) or no_asan_shim!(|a: usize| a).
Generic arguments can be specified in square brackets before the closure, for example
no_asan_shim!([T: Add<usize>]|a: T| -> T::Output { a + 1 }).
All types including return types must be specified.
Arguments must correspond to existing in-scope bindings.
ยงExamples
use kernel_api::memory::asan::no_asan_shim;
for chunk in heap_chunks {
let allocated = no_asan_shim!(|chunk: *mut Chunk| -> bool {
unsafe { (&raw const (*chunk).allocated).read() }
});
if allocated { info!("allocated heap memory at {chunk:p}"); }
}