selftests/bpf: Disable ASAN instrumentation for mmap()'ed memory read

AddressSanitizer assumes that all memory dereferences are done against memory
allocated by sanitizer's malloc()/free() code and not touched by anyone else.
Seems like this doesn't hold for perf buffer memory. Disable instrumentation
on perf buffer callback function.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200429012111.277390-10-andriin@fb.com
This commit is contained in:
Andrii Nakryiko 2020-04-28 18:21:09 -07:00 committed by Alexei Starovoitov
parent 3521ffa2ee
commit 36d0b6159f
1 changed files with 5 additions and 0 deletions

View File

@ -6,6 +6,11 @@
#include <test_progs.h>
#include "bpf/libbpf_internal.h"
/* AddressSanitizer sometimes crashes due to data dereference below, due to
* this being mmap()'ed memory. Disable instrumentation with
* no_sanitize_address attribute
*/
__attribute__((no_sanitize_address))
static void on_sample(void *ctx, int cpu, void *data, __u32 size)
{
int cpu_data = *(int *)data, duration = 0;