aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/prog_tests/perf_buffer.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <[email protected]>2020-04-29 01:21:09 +0000
committerAlexei Starovoitov <[email protected]>2020-04-29 02:48:05 +0000
commit36d0b6159f6a6f51f600bf1777702f7036fb9839 (patch)
tree1c5155a79da98960060508bf5fa5b464b4ee3fcc /tools/testing/selftests/bpf/prog_tests/perf_buffer.c
parentlibbpf: Fix huge memory leak in libbpf_find_vmlinux_btf_id() (diff)
downloadkernel-36d0b6159f6a6f51f600bf1777702f7036fb9839.tar.gz
kernel-36d0b6159f6a6f51f600bf1777702f7036fb9839.zip
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 <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/perf_buffer.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/perf_buffer.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/perf_buffer.c b/tools/testing/selftests/bpf/prog_tests/perf_buffer.c
index 1450ea2dd4cc..a122ce3b360e 100644
--- a/tools/testing/selftests/bpf/prog_tests/perf_buffer.c
+++ b/tools/testing/selftests/bpf/prog_tests/perf_buffer.c
@@ -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;