From: sashiko-bot@kernel.org
To: "Emil Tsalapatis" <emil@etsalapatis.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v9 5/8] selftests/bpf: Add ASAN support for libarena selftests
Date: Sun, 26 Apr 2026 20:28:16 +0000 [thread overview]
Message-ID: <20260426202816.F38FAC2BCB6@smtp.kernel.org> (raw)
In-Reply-To: <20260426190338.4615-6-emil@etsalapatis.com>
Sashiko AI review found 4 potential issue(s):
- [Medium] Logic error in `asan_validate_addr` fails to validate the ASAN violation address.
- [Medium] `print_asan_map_state` missing `__noasan` attribute triggers secondary ASAN violations.
- [Low] Missing header includes in `userspace.h` and `st_asan_common.h` cause compilation errors.
- [Low] Standalone builds in the `libarena/` directory fail unconditionally on older Clang versions.
--
commit 7f45bd9cc6e3fb019a16a17f2e11b1f1ab5702ad
Author: Emil Tsalapatis <emil@etsalapatis.com>
selftests/bpf: Add ASAN support for libarena selftests
Expand the arena library selftest infrastructure to support
address sanitization. Add the compiler flags necessary to
compile the library under ASAN when supported.
> diff --git a/tools/testing/selftests/bpf/libarena/Makefile b/tools/testing/selftests/bpf/libarena/Makefile
> index e85b3ad96890..5e2ab514805e 100644
> --- a/tools/testing/selftests/bpf/libarena/Makefile
> +++ b/tools/testing/selftests/bpf/libarena/Makefile
[ ... ]
> @@ -53,17 +61,32 @@ CFLAGS += $(INCLUDES)
> vpath %.bpf.c $(LIBARENA)/src $(LIBARENA)/selftests
> vpath %.c $(LIBARENA)/src $(LIBARENA)/selftests
>
> +skeletons: libarena.skel.h libarena_asan.skel.h
> +.PHONY: skeletons
Will this unconditionally build libarena_asan.skel.h when running make
directly in the libarena/ directory? The parent BPF Makefile guards ASAN
compilation with CLANG_HAS_ARENA_ASAN, but that guard is missing here. Could
this cause the build to fail on older Clang versions?
[ ... ]
> diff --git a/tools/testing/selftests/bpf/libarena/include/libarena/userspace.h b/tools/testing/selftests/bpf/libarena/include/libarena/userspace.h
> index 0438a751d5fd..88b68ac73cca 100644
> --- a/tools/testing/selftests/bpf/libarena/include/libarena/userspace.h
> +++ b/tools/testing/selftests/bpf/libarena/include/libarena/userspace.h
[ ... ]
> @@ -97,3 +102,31 @@ static inline int libarena_get_globals_pages(int arena_get_globals_fd,
> free(vec);
> return 0;
> }
> +
> +static inline int libarena_asan_init(int arena_asan_init_fd,
> + int asan_init_fd,
> + size_t arena_all_pages)
> +{
> + LIBBPF_OPTS(bpf_test_run_opts, opts);
> + struct asan_init_args args;
This isn't a bug, but struct asan_init_args is instantiated here without
including <libarena/asan.h>. Could this cause compilation errors if the
header is included independently?
[ ... ]
> diff --git a/tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h b/tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h
> new file mode 100644
> index 000000000000..1d3edc4372ac
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h
> @@ -0,0 +1,52 @@
> +// SPDX-License-Identifier: LGPL-2.1 OR BSD-2-Clause
> +/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
> +
> +#pragma once
> +
Similar to the above, this header uses macros and variables like
asan_violated, ASAN_GRANULE, and arena_stdout but does not include
<libarena/common.h> or <libarena/asan.h>.
> +#define ST_PAGES 64
> +
> +static inline void print_asan_map_state(void __arena *addr)
> +{
> + arena_stdout("%s:%d ASAN %p -> (val: %x gran: %x set: [%s])",
> + __func__, __LINE__, addr,
> + *(s8a *)(addr), ASAN_GRANULE(addr),
> + asan_shadow_set(addr) ? "yes" : "no");
> +}
Since addr is an address that triggered an ASAN violation, does this need
the __noasan attribute? Otherwise, the memory read *(s8a *)(addr) will trigger
another ASAN violation.
> +
> +/*
> + * Emit an error and force the current function to exit if the ASAN
> + * violation state is unexpected. Reset the violation state after.
> + */
> +static inline int asan_validate_addr(bool cond, void __arena *addr)
> +{
> + if ((asan_violated != 0) == cond) {
If a violation is expected when cond is true, does this code also need to
check if asan_violated == (u64)addr? It looks like it only verifies that
any violation occurred, which could allow tests to erroneously pass if a
completely unrelated ASAN violation happens.
> + asan_violated = 0;
> + return 0;
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260426190338.4615-1-emil@etsalapatis.com?part=5
next prev parent reply other threads:[~2026-04-26 20:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-26 19:03 [PATCH bpf-next v9 0/8] Introduce arena library and runtime Emil Tsalapatis
2026-04-26 19:03 ` [PATCH bpf-next v9 1/8] selftests/bpf: Add ifdef guard for WRITE_ONCE macro in bpf_atomic.h Emil Tsalapatis
2026-04-26 19:03 ` [PATCH bpf-next v9 2/8] selftests/bpf: Add basic libarena scaffolding Emil Tsalapatis
2026-04-26 19:34 ` sashiko-bot
2026-04-26 19:03 ` [PATCH bpf-next v9 3/8] selftests/bpf: Move arena-related headers into libarena Emil Tsalapatis
2026-04-26 19:03 ` [PATCH bpf-next v9 4/8] selftests/bpf: Add arena ASAN runtime to libarena Emil Tsalapatis
2026-04-26 20:12 ` sashiko-bot
2026-04-26 19:03 ` [PATCH bpf-next v9 5/8] selftests/bpf: Add ASAN support for libarena selftests Emil Tsalapatis
2026-04-26 19:33 ` bot+bpf-ci
2026-04-26 20:28 ` sashiko-bot [this message]
2026-04-26 19:03 ` [PATCH bpf-next v9 6/8] selftests/bpf: Add buddy allocator for libarena Emil Tsalapatis
2026-04-26 19:46 ` bot+bpf-ci
2026-04-26 20:54 ` sashiko-bot
2026-04-26 19:03 ` [PATCH bpf-next v9 7/8] selftests/bpf: Add selftests for libarena buddy allocator Emil Tsalapatis
2026-04-26 21:09 ` sashiko-bot
2026-04-26 19:03 ` [PATCH bpf-next v9 8/8] selftests/bpf: Reuse stderr parsing for libarena ASAN tests Emil Tsalapatis
2026-04-26 19:46 ` bot+bpf-ci
2026-04-26 21:38 ` sashiko-bot
2026-04-27 1:20 ` [PATCH bpf-next v9 0/8] Introduce arena library and runtime patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260426202816.F38FAC2BCB6@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=emil@etsalapatis.com \
--cc=sashiko@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox