1 #ifndef _included_clib_sanitizer_h 2 #define _included_clib_sanitizer_h 4 #ifdef CLIB_SANITIZE_ADDR 6 #include <sanitizer/asan_interface.h> 9 #define CLIB_NOSANITIZE_ADDR __attribute__((no_sanitize_address)) 10 #define CLIB_MEM_POISON(a, s) ASAN_POISON_MEMORY_REGION((a), (s)) 11 #define CLIB_MEM_UNPOISON(a, s) ASAN_UNPOISON_MEMORY_REGION((a), (s)) 13 #define CLIB_MEM_OVERFLOW(f, src, n) \ 15 typeof (f) clib_mem_overflow_ret__; \ 16 const void *clib_mem_overflow_src__ = (src); \ 17 size_t clib_mem_overflow_n__ = (n); \ 18 const void *clib_mem_overflow_start__ = __asan_region_is_poisoned((void *)clib_mem_overflow_src__, clib_mem_overflow_n__); \ 19 clib_mem_overflow_n__ -= (size_t)(clib_mem_overflow_start__ - clib_mem_overflow_src__); \ 20 if (clib_mem_overflow_start__) \ 21 CLIB_MEM_UNPOISON(clib_mem_overflow_start__, clib_mem_overflow_n__); \ 22 clib_mem_overflow_ret__ = f; \ 23 if (clib_mem_overflow_start__) \ 24 CLIB_MEM_POISON(clib_mem_overflow_start__, clib_mem_overflow_n__); \ 25 clib_mem_overflow_ret__; \ 28 #define CLIB_MEM_OVERFLOW_LOAD(f, src) \ 30 typeof(src) clib_mem_overflow_load_src__ = (src); \ 31 CLIB_MEM_OVERFLOW(f(clib_mem_overflow_load_src__), clib_mem_overflow_load_src__, sizeof(typeof(f(clib_mem_overflow_load_src__)))); \ 39 else if (newlen > oldlen)
45 #define CLIB_NOSANITIZE_ADDR 46 #define CLIB_MEM_POISON(a, s) (void)(a) 47 #define CLIB_MEM_UNPOISON(a, s) (void)(a) 48 #define CLIB_MEM_OVERFLOW(a, b, c) a 49 #define CLIB_MEM_OVERFLOW_LOAD(f, src) f(src) 50 #define CLIB_MEM_POISON_LEN(a, b, c) #define CLIB_MEM_UNPOISON(a, s)
#define CLIB_MEM_POISON_LEN(a, b, c)
#define static_always_inline
#define CLIB_MEM_POISON(a, s)