Re: [PATCH bpf-next v1 00/14] selftests/bpf: Fixes for userspace ASAN

From: Eduard Zingerman

Date: Thu Feb 12 2026 - 17:00:55 EST


On Wed, 2026-02-11 at 17:13 -0800, Ihor Solodrai wrote:
> This series includes various fixes aiming to enable test_progs run
> with userspace address sanitizer on BPF CI.
>
> The first patch fixes the selftests/bpf/test_progs build with:
>
>     SAN_CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
>
> The subsequent patches fix bugs reported by the address sanitizer on
> attempt to run the tests.
>
> The series is a pre-requisite for enabling "test_progs with ASAN"
> workflow on BPF CI.

I did an experiment:
- applied the diff as at the bottom of the email;
- compiled with export SAN_CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
(using gcc 15.2.1);
- double-checked that resulting executable depends on libasan;
- did a test run: ./test_progs -a verifier_and.

The error report looks as follows:

Caught signal #11!
Stack trace:
/lib64/libasan.so.8(+0x525e7) [0x7f6a506525e7]
./test_progs(crash_handler+0xb5) [0xd152c9]
/lib64/libc.so.6(+0x19c30) [0x7f6a50427c30]
/lib64/libasan.so.8(+0xdf4a) [0x7f6a5060df4a]
/lib64/libasan.so.8(+0xe5bba) [0x7f6a506e5bba]
./test_progs() [0xd19ccc]
./test_progs(main+0xcf6) [0xd1aa79]
/lib64/libc.so.6(+0x35f5) [0x7f6a504115f5]
/lib64/libc.so.6(__libc_start_main+0x88) [0x7f6a504116a8]
./test_progs(_start+0x25) [0x401935]

Am I doing something wrong, or does test_progs signal handler
interfere with ASAN reporting?

[...]

---

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index a0a594de9007..3820077e74e4 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -46,7 +46,7 @@ srctree := $(patsubst %/,%,$(dir $(srctree)))
endif

CFLAGS += -g $(OPT_FLAGS) -rdynamic -std=gnu11 \
- -Wall -Werror -fno-omit-frame-pointer \
+ -Wall -fno-omit-frame-pointer \
-Wno-unused-but-set-variable \
$(GENFLAGS) $(SAN_CFLAGS) $(LIBELF_CFLAGS) \
-I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR) \
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index 02a85dda30e6..8839e00167fa 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -1924,7 +1924,7 @@ static void free_test_states(void)
free_subtest_state(&test_state->subtest_states[j]);

free(test_state->subtest_states);
- free(test_state->log_buf);
+ free(test_state->log_buf + 10);
test_state->subtest_states = NULL;
test_state->log_buf = NULL;