Introduce arena library and runtime
Subsystems (3)
Emil Tsalapatis
reviewerv9 cover Introduce arena library and runtime
Add a new subdirectory to tools/testing/selftests/bpf called libarena, along with programs useful for writing arena-based BPF code. This patchset adds the following:
1) libarena, a subdirectory where arena BPF code that is generally useful to BPF arena programs can be easily added and tested.
2) An ASAN runtime for BPF arena programs. BPF arenas allow for accessing memory after it has been freed or if it is out of bounds, making it more difficult to triage bugs combined to regular BPF. Use LLVM's recently added support for address-space based sanitization to selectively sanitize just the arena accesses.
3) A buddy memory allocator that can be reused by BPF programs to handle memory allocation/deletion. The allocator uses the ASAN runtime to add address sanitization if requested.
The patch includes testing for the new allocators and ASAN features that can be built from the top directory using "make libarena_test" and "make libarena_test_asan". The generated binaries reside in libarena/. The patch also adds test-progs-based selftests to the codebase for the libarena code, so the new tests are run by ./test_progs.
The patchset has the following stucture:
1-3: Create basic libarena scaffolding and refactor existing headers.
4-5: Add the ASAN runtime and associated scaffolding.
6-8: Add the new buddy memory allocator along with selftests.
HISTORY
=======
v8->v9 (https://lore.kernel.org/bpf/[email protected])
- Added Matt's Acked-by for Patch 1
- Replaced open coded fls with __builtin based calculation (Matt)
- Add comment explaining the reasoning behind the zero variable (Matt)
- Remove the self-contained runner and present selftests as examples (Kumar). The reasoning is that including selftests with the library is not effective because the library will be sync'ed outside the tree infrequently, so it would be ineffective in catching issues before they land.
- Adjust syscall API for clarity and forward compatibility (Matt)
- Reset asan_validate state after failed check (Sashiko)
- Fix printf format specifier (Sashiko)
- Rename syscall to be generic arena_info (Matt)
- Namespace libarena headers by moving them to their own directory
- Rename selftest_helpers to libarena/userspace.h to reflect it is not just for selftests.
v7->v8 (https://lore.kernel.org/bpf/[email protected])
- Duplicate READ_ONCE/WRITE_ONCE instead of moving it to bpf_experimental.h to keep libarena self-contained (Kumar)
- Add libarena_asan test to test_progs and conditionally compile it if suppported (Kumar)
- Add stderr parsing for buddy tests when run under test_progs (Kumar)
- Move all arena-related headers into libarena and add its include/ subdirectory in the standard include path (Kumar)
- Remove silent-by-default ASAN, add help message on test_libarena explaining that -v emits the messages (Kumar)
- Add run_prog_args as a libarena helper
- Add explanation on the use of __weak for the spinlock qnodes
v6->v7 (https://lore.kernel.org/bpf/[email protected])
- Modify patch 1 to allow operations between PTR_TO_ARENA src_reg and dst_reg of any type. Adjust selftests accordingly (Alexei)
- Remove unnecessary include in patch 5 (Song)
- Removed unused definitions/assignments in patches 8/9, update patch descriptions
v5->v6 (https://lore.kernel.org/bpf/[email protected])
- Fix subreg_def management for SCALAR += PTR_TO_ARENA operations (AI)
- Add more selftests for the SCALAR += PTR_TO_ARENA patch (Sashiko)
- Adjust fls() operation to be in line with the kernel version (Sashiko)
- Address Sashiko selftests and debugging nits
- Add ASAN loadN and storeN _noabort variants and associated BTF anchor
- Remove unnecessary bit freeing of buddies during block splitting
v4->v5 (https://lore.kernel.org/bpf/[email protected])
Omitting various nits and fixups.
- Properly adjust subreg_def for scalar += ptr_to_arena calls (Sashiko)
- Remove extraneous definition from prog_tests/arena_spin_lock.c (Song)
- Trim extraneous comments from ASAN and buddy (Alexei)
- Remove asan_dummy call and replace with function pointer array (Alexei)
- Remove usersapi.h header and merge it into common.h (Alexei)
- Replace ASAN macros with function calls (Alexei)
- Embed buddy lock into the struct and move the buddy allocator to __arena_global (Alexei)
- Add commenting for buddy allocator constants (Alexei)
- Add default buddy allocator directly in common.bpf.c, so that the user does not need to define it.
- Expand test harnesses to dynamically find individual selftests. Now the selftests also reports each test individually (e.g., 5 entries for the buddy allocator instead of 1). This brings them to par with the rest of the test_progs.
v3->v4 (https://lore.kernel.org/bpf/[email protected])
- Add Acks by Song to patches 1-4.
- Expand the verifier's handling of scalar/arena operations to include all 3-operand operations in Patch 1 (Alexei)
- Add additional tests for arena/arena (allowed) and arena/pointer (not allowed) operations in Patch 2
- Remove ASAN version of the library from default compilation since it requires LLVM 22 and up (CI)
- Rework buddy allocator locking for clarity and add comments
- Fix From: email to be consistent with SOB
- Address (most) Sashiko comments
v2->v3 (https://lore.kernel.org/bpf/[email protected])
Nonexhaustive due to significant patch rework.
- Do not duplicate WRITE_ONCE macro (Mykyta, Kumar)
- Add SPDX headers (Alexei)
- Remove bump/stack allocators (Alexei)
- Integrate testing with test_progs (Kumar)
- Add short description of ASAN algorithm at the top of the file (Alexei)
v1->v2 (https://lore.kernel.org/bpf/[email protected]/)
- Added missing format string argument (AI)
- Fix outdated selftests prog name check (AI)
- Fixed stack allocation check for segment creation (AI)
- Fix errors in non-ASAN bump allocator selftests (AI)
- Propagate error value from individual selftests in selftest.c
- Removed embedded metadata from bump allocator as it was needlessly complicating its behavior
Emil Tsalapatis (8):
selftests/bpf: Add ifdef guard for WRITE_ONCE macro in bpf_atomic.h selftests/bpf: Add basic libarena scaffolding selftests/bpf: Move arena-related headers into libarena selftests/bpf: Add arena ASAN runtime to libarena selftests/bpf: Add ASAN support for libarena selftests selftests/bpf: Add buddy allocator for libarena selftests/bpf: Add selftests for libarena buddy allocator selftests/bpf: Reuse stderr parsing for libarena ASAN tests
tools/testing/selftests/bpf/Makefile | 53 +-
tools/testing/selftests/bpf/bpf_arena_alloc.h | 2 +-
tools/testing/selftests/bpf/bpf_arena_list.h | 2 +-
.../selftests/bpf/bpf_arena_strsearch.h | 2 +-
.../testing/selftests/bpf/bpf_experimental.h | 84 +-
tools/testing/selftests/bpf/default.profraw | Bin 0 -> 160 bytes
tools/testing/selftests/bpf/libarena/Makefile | 94 ++
.../{ => libarena/include}/bpf_arena_common.h | 0
.../include}/bpf_arena_spin_lock.h | 11 +-
.../bpf/{ => libarena/include}/bpf_atomic.h | 4 +-
.../bpf/libarena/include/bpf_may_goto.h | 84 ++
.../bpf/libarena/include/libarena/asan.h | 103 ++
.../bpf/libarena/include/libarena/buddy.h | 92 ++
.../bpf/libarena/include/libarena/common.h | 94 ++
.../bpf/libarena/include/libarena/userspace.h | 132 +++
.../libarena/selftests/st_asan_buddy.bpf.c | 258 +++++
.../bpf/libarena/selftests/st_asan_common.h | 52 +
.../bpf/libarena/selftests/st_buddy.bpf.c | 209 ++++
.../libarena/selftests/test_progs_compat.h | 15 +
.../selftests/bpf/libarena/src/asan.bpf.c | 553 +++++++++++
.../selftests/bpf/libarena/src/buddy.bpf.c | 903 ++++++++++++++++++
.../selftests/bpf/libarena/src/common.bpf.c | 52 +
.../bpf/prog_tests/arena_spin_lock.c | 7 -
.../selftests/bpf/prog_tests/libarena.c | 66 ++
.../selftests/bpf/prog_tests/libarena_asan.c | 93 ++
.../selftests/bpf/progs/arena_atomics.c | 2 +-
.../selftests/bpf/progs/arena_spin_lock.c | 2 +-
.../bpf/progs/compute_live_registers.c | 2 +-
.../selftests/bpf/progs/lpm_trie_bench.c | 2 +-
tools/testing/selftests/bpf/progs/stream.c | 2 +-
.../selftests/bpf/progs/verifier_arena.c | 2 +-
.../bpf/progs/verifier_arena_globals1.c | 2 +-
.../bpf/progs/verifier_arena_globals2.c | 2 +-
.../bpf/progs/verifier_arena_large.c | 2 +-
.../selftests/bpf/progs/verifier_ldsx.c | 2 +-
tools/testing/selftests/bpf/test_loader.c | 51 +-
tools/testing/selftests/bpf/test_progs.h | 2 +
37 files changed, 2917 insertions(+), 121 deletions(-)
create mode 100644 tools/testing/selftests/bpf/default.profraw
create mode 100644 tools/testing/selftests/bpf/libarena/Makefile
rename tools/testing/selftests/bpf/{ => libarena/include}/bpf_arena_common.h (100%)
rename tools/testing/selftests/bpf/{progs => libarena/include}/bpf_arena_spin_lock.h (98%)
rename tools/testing/selftests/bpf/{ => libarena/include}/bpf_atomic.h (98%)
create mode 100644 tools/testing/selftests/bpf/libarena/include/bpf_may_goto.h
create mode 100644 tools/testing/selftests/bpf/libarena/include/libarena/asan.h
create mode 100644 tools/testing/selftests/bpf/libarena/include/libarena/buddy.h
create mode 100644 tools/testing/selftests/bpf/libarena/include/libarena/common.h
create mode 100644 tools/testing/selftests/bpf/libarena/include/libarena/userspace.h
create mode 100644 tools/testing/selftests/bpf/libarena/selftests/st_asan_buddy.bpf.c
create mode 100644 tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h
create mode 100644 tools/testing/selftests/bpf/libarena/selftests/st_buddy.bpf.c
create mode 100644 tools/testing/selftests/bpf/libarena/selftests/test_progs_compat.h
create mode 100644 tools/testing/selftests/bpf/libarena/src/asan.bpf.c
create mode 100644 tools/testing/selftests/bpf/libarena/src/buddy.bpf.c
create mode 100644 tools/testing/selftests/bpf/libarena/src/common.bpf.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/libarena.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/libarena_asan.cSignature · 1 line
2.53.0
Emil Tsalapatis
reviewerPATCH v9 1/8 selftests/bpf: Add ifdef guard for WRITE_ONCE macro in bpf_atomic.h
The WRITE_ONCE macro is identically defined both in bpf_atomic.h and in bpf_arena_common.h. However, the bpf_atomic.h definition has no ifdef guard. If bpf_atomic.h is included after bpf_arena.common.h, compilation fails because of the duplicate definition.
Guard the definiton in bpf_atomic.h with and ifdef to let programs include the two headers in any order. Duplicating the definition is the simplest solution out of all the alternatives:
- Keeping one of the two existing definitions is not possible because both BPF atomics and arena programs need the macro, and the two features are independent. Using one should not require the header for the other.
- Factoring out the definition into a new header that only includes it is more churn than just duplicating it.
- Factoring out the definition into bpf_experimental.h requires all users of WRITE_ONCE to include the header. However, the arena library introduced in subsequent commits must be self-contained, while bpf_experimental.h is in the base selftests/bpf directory.
Both headers are moved to the arena library in a subsequent patch.
--- tools/testing/selftests/bpf/bpf_atomic.h | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/bpf/bpf_atomic.h +2 -0
@@ -42,7 +42,9 @@ extern bool CONFIG_X86_64 __kconfig __weak;#define READ_ONCE (x) (*(volatile typeof(x) *)&(x)) +#ifndef WRITE_ONCE #define WRITE_ONCE (x, val) ((*(volatile typeof(x) *)&(x)) = (val)) +#endif #define cmpxchg (p, old, new) __sync_val_compare_and_swap((p), old, new)
Signature · 1 line
2.53.0
Emil Tsalapatis
reviewerPATCH v9 2/8 selftests/bpf: Add basic libarena scaffolding
In reply to Emil TsalapatisAdd initial code and a Makefile for an arena-based BPF library. Modules can be added just by including the source file in the library's src/ subdirectory. Future commits will introduce the library code itself.
The code includes workarounds that are removed in subsequent patches that ensure bisectability.
--- tools/testing/selftests/bpf/Makefile | 27 +++++ tools/testing/selftests/bpf/libarena/Makefile | 69 +++++++++++++ .../bpf/libarena/include/libarena/common.h | 79 +++++++++++++++ .../bpf/libarena/include/libarena/userspace.h | 99 +++++++++++++++++++ .../selftests/bpf/libarena/src/common.bpf.c | 29 ++++++ 5 files changed, 303 insertions(+) create mode 100644 tools/testing/selftests/bpf/libarena/Makefile create mode 100644 tools/testing/selftests/bpf/libarena/include/libarena/common.h create mode 100644 tools/testing/selftests/bpf/libarena/include/libarena/userspace.h create mode 100644 tools/testing/selftests/bpf/libarena/src/common.bpf.c
tools/testing/selftests/bpf/Makefile +27 -0
@@ -153,6 +153,7 @@ override define CLEAN $(Q)$(RM) -r $(TEST_KMODS) $(Q)$(RM) -r $(EXTRA_CLEAN) $(Q)$(MAKE) -C test_kmods clean + $(Q)$(MAKE) -C libarena clean $(Q)$(MAKE) docs-clean endef
@@ -525,6 +526,7 @@ LINKED_BPF_OBJS := $(foreach skel,$(LINKED_SKELS),$($(skel)-deps)) LINKED_BPF_SRCS := $(patsubst %.bpf.o,%.c,$(LINKED_BPF_OBJS)) HEADERS_FOR_BPF_OBJS := $(wildcard $(BPFDIR)/*.bpf.h) \ + $(wildcard $(CURDIR)/libarena/include/*.[ch]) \ $(addprefix $(BPFDIR)/, bpf_core_read.h \ bpf_endian.h \ bpf_helpers.h \
@@ -740,6 +742,29 @@ $(VERIFY_SIG_HDR): $(VERIFICATION_CERT) echo "};"; \ echo "unsigned int test_progs_verification_cert_len = $$(wc -c < $<);") > $@ +LIBARENA_MAKE_ARGS = \ + BPFTOOL="$(BPFTOOL)" \ + INCLUDE_DIR="$(INCLUDE_DIR)" \ + LIBBPF_INCLUDE="$(HOST_INCLUDE_DIR)" \ + BPFOBJ="$(BPFOBJ)" \ + LDLIBS="$(LDLIBS) -lzstd" \ + CLANG="$(CLANG)" \ + BPF_CFLAGS="$(BPF_CFLAGS) $(CLANG_CFLAGS)" \ + BPF_TARGET_ENDIAN="$(BPF_TARGET_ENDIAN)" \ + Q="$(Q)" + +LIBARENA_BPF_DEPS := $(wildcard libarena/Makefile \ + libarena/include/* \ + libarena/include/libarena/* \ + libarena/src/* \ + libarena/selftests/* \ + libarena/*.bpf.o) + +LIBARENA_SKEL := libarena/libarena.skel.h + +$(LIBARENA_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BPF_DEPS) + +$(MAKE) -C libarena libarena.skel.h $(LIBARENA_MAKE_ARGS) + # Define test_progs test runner. TRUNNER_TESTS_DIR := prog_tests TRUNNER_BPF_PROGS_DIR := progs
@@ -933,3 +958,5 @@ override define INSTALL_RULE rsync -a $(OUTPUT)/$$DIR/*.bpf.o $(INSTALL_PATH)/$$DIR;\ done endef + +libarena: $(LIBARENA_SKEL)
tools/testing/selftests/bpf/libarena/Makefile new file +69 -0
69 lines not on this page · raw message
tools/testing/selftests/bpf/libarena/include/libarena/common.h new file +79 -0
79 lines not on this page · raw message
tools/testing/selftests/bpf/libarena/include/libarena/userspace.h new file +99 -0
99 lines not on this page · raw message
tools/testing/selftests/bpf/libarena/src/common.bpf.c new file +29 -0
@@ -0,0 +1,29 @@ +// SPDX-License-Identifier: LGPL-2.1 OR BSD-2-Clause +/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */ +#include <libarena/common.h> + +const volatile u32 zero =0 ; + +int arena_fls (__u64 word) +{ +if (!word) +return 0 ; + +return 64 -__builtin_clzll (word); +} + +SEC("syscall") +__weak int arena_get_info (struct arena_get_info_args *args) +{ + args->arena_base =arena_base (&arena); + +return 0 ; +} + +SEC("syscall") +__weak int arena_alloc_reserve (struct arena_alloc_reserve_args *args) +{ +return bpf_arena_reserve_pages (&arena,NULL , args->nr_pages); +} + +char _license[] SEC("license") = "GPL";
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH bpf-next v9 2/8] selftests/bpf: Add basic libarena scaffolding
Sashiko AI review found 4 potential issue(s): - [Medium] Silent argument truncation in `arena_alloc_reserve` causing fewer pages to be reserved than requested. - [Medium] Buffer overflow in…
Sashiko AI review found 4 potential issue(s):
- [Medium] Silent argument truncation in arena_alloc_reserve causing fewer pages to be reserved than requested.
- [Medium] Buffer overflow in userspace mincore() array sizing if sysconf(_SC_PAGESIZE) differs from kernel PAGE_SIZE.
- [Low] Build Dependency Tracking Failure for libarena headers.
- [Low] Makefile logic flaw leading to silent test omission on name collision (vpath anti-pattern).
--
commit 7876e5868c676854bd421cbb98140a84f94fa226
Author: Emil Tsalapatis <[email protected]>
selftests/bpf: Add basic libarena scaffolding
Add initial code and a Makefile for an arena-based BPF library. Modules can be added just by including the source file in the library's src/ subdirectory.
Quoted 4 lines
tools/testing/selftests/bpf/Makefile +0
-0
[ ... ]
tools/testing/selftests/bpf/Makefile LINKED_BPF_OBJS := $(foreach skel,$(LINKED_SKELS),$($(skel)-deps)) · line 532
Quoted 8 lines
tools/testing/selftests/bpf/Makefile +1
-0@@ -525,6 +526,7 @@ LINKED_BPF_OBJS := $(foreach skel,$(LINKED_SKELS),$($(skel)-deps)) LINKED_BPF_SRCS := $(patsubst %.bpf.o,%.c,$(LINKED_BPF_OBJS)) HEADERS_FOR_BPF_OBJS := $(wildcard $(BPFDIR)/*.bpf.h) \ + $(wildcard $(CURDIR)/libarena/include/*.[ch]) \ $(addprefix $(BPFDIR)/, bpf_core_read.h \ bpf_endian.h \ bpf_helpers.h \
Does this code miss changes to the newly introduced headers?
The headers common.h and userspace.h are located in the nested libarena/include/libarena/ subdirectory. Since GNU Make's wildcard function does not perform recursive searches, this evaluates to empty.
Modifications to the headers might silently fail to trigger a rebuild.
[ ... ]
Quoted 5 lines
tools/testing/selftests/bpf/libarena/Makefile new file +0
-0
[ ... ]
tools/testing/selftests/bpf/libarena/Makefile line 32
Quoted 3 lines
tools/testing/selftests/bpf/libarena/Makefile new file +3
-0+# Scan src/ and selftests/ to generate the final binaries +LIBARENA_SOURCES = $(wildcard $(LIBARENA)/src/*.bpf.c) $(wildcard $(LIBARENA)/selftests/*.bpf.c) +LIBARENA_OBJECTS = $(notdir $(LIBARENA_SOURCES:.bpf.c=.bpf.o))
Could this cause test modules to be silently omitted on name collisions?
If a test module is added as selftests/foo.bpf.c when src/foo.bpf.c already exists, notdir creates duplicate object names. Because of the vpath directive used later in the Makefile, make will find the source file in src/ first and compile it.
The bpftool utility will link the identical object twice, completely ignoring the test file in selftests/.
[ ... ]
Quoted 5 lines
tools/testing/selftests/bpf/libarena/include/libarena/common.h new file +0
-0
[ ... ]
tools/testing/selftests/bpf/libarena/include/libarena/common.h line 76
Quoted 3 lines
tools/testing/selftests/bpf/libarena/include/libarena/common.h new file +3
-0+struct arena_alloc_reserve_args { +u64 nr_pages; +};
Will this silently truncate the number of requested pages?
The userspace API structure exposes a 64-bit nr_pages argument, which is passed directly to the bpf_arena_reserve_pages BPF kfunc. However, the internal BPF kfunc signature strictly takes a 32-bit integer.
If userspace requests a reservation exceeding 32 bits, the value will be truncated by the BPF calling convention.
[ ... ]
Quoted 5 lines
tools/testing/selftests/bpf/libarena/include/libarena/userspace.h new file +0
-0
[ ... ]
Quoted 12 lines
tools/testing/selftests/bpf/libarena/include/libarena/userspace.h new file +12
-0+static inline int libarena_get_globals_pages (int arena_get_globals_fd, +size_t arena_all_pages, +u64 *globals_pages) +{ +size_t pgsize =sysconf (_SC_PAGESIZE); +void *arena_base; +ssize_t i; +u8 *vec; +int ret; + + ret =libarena_get_arena_base (arena_get_globals_fd, &arena_base); +if (ret)
tools/testing/selftests/bpf/libarena/include/libarena/userspace.h line 84
Quoted 10 lines
tools/testing/selftests/bpf/libarena/include/libarena/userspace.h new file +10
-0+return ret; + +if (!arena_base) +return -EINVAL ; + + vec =calloc (arena_all_pages,sizeof (*vec)); +if (!vec) +return -ENOMEM ; + +if (mincore (arena_base, arena_all_pages * pgsize, vec) <0 ) {
Can this cause a buffer overflow in the vec array?
The vec buffer is allocated to hold arena_all_pages bytes. The length passed to the mincore syscall is calculated as arena_all_pages * sysconf(_SC_PAGESIZE).
However, the kernel's mincore implementation determines the number of output bytes by dividing the requested length by the kernel's internal page size. If the userspace environment reports a page size larger than the kernel's, the kernel could calculate a page count greater than arena_all_pages and write past the end of the vec buffer.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Emil Tsalapatis
reviewerPATCH v9 3/8 selftests/bpf: Move arena-related headers into libarena
In reply to Emil TsalapatisThe BPF selftest headers include functionality that is specific to arenas and is required by libarena. Keep libarena self-contained by moving all functionality into its include/ directory. Also add libarena/include to the standard include paths for the selftests to make the moved headers easy to access by existing selftests.
Some functionality is required by libarena but not strictly arena-related. We still move it to the libarena/include path, which is an upgrade from directly accessing them from the selftests/bpf directory using relative paths.
A new bpf_may_goto.h file is split off of bpf_experimental.h. bpf_arena_spin_lock.h and bpf_arena_common.h are moved to libarena/include. bpf_atomic.h is also moved to libarena because it is necessary for arena spinlocks.
For bpf_arena_spin_lock.h, mark the spinlock state array as __weak to define the spinlock state array in the header while also being compatible with multi-compilation unit programs. While we're at it, we remove unnecessary definitions from existing test programs.
---
tools/testing/selftests/bpf/Makefile | 4 +-
tools/testing/selftests/bpf/bpf_arena_alloc.h | 2 +-
tools/testing/selftests/bpf/bpf_arena_list.h | 2 +-
.../selftests/bpf/bpf_arena_strsearch.h | 2 +-
.../testing/selftests/bpf/bpf_experimental.h | 84 +------------------
.../{ => libarena/include}/bpf_arena_common.h | 0
.../include}/bpf_arena_spin_lock.h | 11 ++-
.../bpf/{ => libarena/include}/bpf_atomic.h | 2 +-
.../bpf/libarena/include/bpf_may_goto.h | 84 +++++++++++++++++++
.../bpf/libarena/include/libarena/common.h | 4 +-
.../bpf/prog_tests/arena_spin_lock.c | 7 --
.../selftests/bpf/progs/arena_atomics.c | 2 +-
.../selftests/bpf/progs/arena_spin_lock.c | 2 +-
.../bpf/progs/compute_live_registers.c | 2 +-
.../selftests/bpf/progs/lpm_trie_bench.c | 2 +-
tools/testing/selftests/bpf/progs/stream.c | 2 +-
.../selftests/bpf/progs/verifier_arena.c | 2 +-
.../bpf/progs/verifier_arena_globals1.c | 2 +-
.../bpf/progs/verifier_arena_globals2.c | 2 +-
.../bpf/progs/verifier_arena_large.c | 2 +-
.../selftests/bpf/progs/verifier_ldsx.c | 2 +-
21 files changed, 112 insertions(+), 110 deletions(-)
rename tools/testing/selftests/bpf/{ => libarena/include}/bpf_arena_common.h (100%)
rename tools/testing/selftests/bpf/{progs => libarena/include}/bpf_arena_spin_lock.h (98%)
rename tools/testing/selftests/bpf/{ => libarena/include}/bpf_atomic.h (99%)
create mode 100644 tools/testing/selftests/bpf/libarena/include/bpf_may_goto.htools/testing/selftests/bpf/Makefile +3 -1
@@ -56,7 +56,8 @@ CFLAGS += -g $(OPT_FLAGS) -rdynamic -std=gnu11 \ -Wno-unused-but-set-variable \ $(GENFLAGS) $(SAN_CFLAGS) $(LIBELF_CFLAGS) \ -I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR) \ - -I$(TOOLSINCDIR) -I$(TOOLSARCHINCDIR) -I$(APIDIR) -I$(OUTPUT) + -I$(TOOLSINCDIR) -I$(TOOLSARCHINCDIR) -I$(APIDIR) -I$(OUTPUT) \ + -I$(CURDIR)/libarena/include LDFLAGS += $(SAN_LDFLAGS) LDLIBS += $(LIBELF_LIBS) -lz -lrt -lpthread
@@ -447,6 +448,7 @@ endif CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) BPF_CFLAGS = -g -Wall -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) \ -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR) \ + -I$(CURDIR)/libarena/include \ -I$(abspath $(OUTPUT)/../usr/include) \ -std=gnu11 \ -fno-strict-aliasing \
tools/testing/selftests/bpf/bpf_arena_alloc.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ #pragma once -#include "bpf_arena_common.h" +#include <bpf_arena_common.h> #ifndef __round_mask#define __round_mask (x, y) ((__typeof__(x))((y)-1))
tools/testing/selftests/bpf/bpf_arena_list.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ #pragma once -#include "bpf_arena_common.h" +#include <bpf_arena_common.h> struct arena_list_node ;
tools/testing/selftests/bpf/bpf_arena_strsearch.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ /* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */ #pragma once -#include "bpf_arena_common.h" +#include <bpf_arena_common.h> __noinline int bpf_arena_strlen(const char __arena *s __arg_arena) {
tools/testing/selftests/bpf/bpf_experimental.h +1 -83
96 lines not on this page · raw message
tools/testing/selftests/bpf/libarena/include/bpf_arena_common.h renamed from tools/testing/selftests/bpf/bpf_arena_common.h +0 -0
tools/testing/selftests/bpf/libarena/include/bpf_arena_spin_lock.h renamed from tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h +8 -3
@@ -5,7 +5,7 @@#include <vmlinux.h> #include <bpf/bpf_helpers.h> -#include "bpf_atomic.h" +#include <bpf_atomic.h> #define arch_mcs_spin_lock_contended_label (l, label) smp_cond_load_acquire_label(l, VAL, label)#define arch_mcs_spin_unlock_contended (l) smp_store_release((l), 1)
@@ -107,7 +107,12 @@ struct arena_qnode {#define _Q_LOCKED_VAL (1U << _Q_LOCKED_OFFSET)#define _Q_PENDING_VAL (1U << _Q_PENDING_OFFSET) -struct arena_qnode __arena qnodes[_Q_MAX_CPUS][_Q_MAX_NODES]; +/* +* The qnodes are marked __weak so we can define them in the header +* while still ensuring all compilation units use the same struct +* instance. +*/ +struct arena_qnode __weak __arena __hidden qnodes[_Q_MAX_CPUS][_Q_MAX_NODES];static inline u32 encode_tail (int cpu,int idx) {
@@ -240,7 +245,7 @@ static __always_inline int arena_spin_trylock(arena_spinlock_t __arena *lock)return likely (atomic_try_cmpxchg_acquire (&lock->val, &val, _Q_LOCKED_VAL)); } -__noinline +__noinline __weak int arena_spin_lock_slowpath(arena_spinlock_t __arena __arg_arena *lock, u32 val) { struct arena_mcs_spinlock __arena *prev, *next, *node0, *node;
tools/testing/selftests/bpf/libarena/include/bpf_atomic.h renamed from tools/testing/selftests/bpf/bpf_atomic.h +1 -1
@@ -5,7 +5,7 @@#include <vmlinux.h> #include <bpf/bpf_helpers.h> -#include "bpf_experimental.h" +#include <bpf_may_goto.h> extern bool CONFIG_X86_64 __kconfig __weak;
tools/testing/selftests/bpf/libarena/include/bpf_may_goto.h new file +84 -0
84 lines not on this page · raw message
tools/testing/selftests/bpf/libarena/include/libarena/common.h +2 -2
@@ -6,8 +6,8 @@#include <vmlinux.h> -#include "../../bpf_arena_common.h" -#include "../../progs/bpf_arena_spin_lock.h" +#include <bpf_arena_common.h> +#include <bpf_arena_spin_lock.h> #include <asm-generic/errno.h>
tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c +0 -7
@@ -5,13 +5,6 @@#include <sys/sysinfo.h> struct __qspinlock {int val; }; -typedef struct __qspinlock arena_spinlock_t ; - -struct arena_qnode { -unsigned long next; -int count; -int locked; -};#include "arena_spin_lock.skel.h"
tools/testing/selftests/bpf/progs/arena_atomics.c +1 -1
@@ -5,7 +5,7 @@#include <bpf/bpf_tracing.h> #include <stdbool.h> #include <stdatomic.h> -#include "bpf_arena_common.h" +#include <bpf_arena_common.h> #include "../../../include/linux/filter.h" #include "bpf_misc.h"
tools/testing/selftests/bpf/progs/arena_spin_lock.c +1 -1
@@ -4,7 +4,7 @@#include <bpf/bpf_tracing.h> #include <bpf/bpf_helpers.h> #include "bpf_misc.h" -#include "bpf_arena_spin_lock.h" +#include <bpf_arena_spin_lock.h> struct { __uint(type, BPF_MAP_TYPE_ARENA);
tools/testing/selftests/bpf/progs/compute_live_registers.c +1 -1
@@ -3,7 +3,7 @@#include <linux/bpf.h> #include <bpf/bpf_helpers.h> #include "../../../include/linux/filter.h" -#include "bpf_arena_common.h" +#include <bpf_arena_common.h> #include "bpf_misc.h" struct {
tools/testing/selftests/bpf/progs/lpm_trie_bench.c +1 -1
@@ -7,7 +7,7 @@#include <bpf/bpf_helpers.h> #include <bpf/bpf_core_read.h> #include "bpf_misc.h" -#include "bpf_atomic.h" +#include <bpf_atomic.h> #include "progs/lpm_trie.h" #define BPF_OBJ_NAME_LEN 16U
tools/testing/selftests/bpf/progs/stream.c +1 -1
@@ -5,7 +5,7 @@#include <bpf/bpf_helpers.h> #include "bpf_misc.h" #include "bpf_experimental.h" -#include "bpf_arena_common.h" +#include <bpf_arena_common.h> struct arr_elem {struct bpf_res_spin_lock lock;
tools/testing/selftests/bpf/progs/verifier_arena.c +1 -1
@@ -8,7 +8,7 @@#include <bpf/bpf_tracing.h> #include "bpf_misc.h" #include "bpf_experimental.h" -#include "bpf_arena_common.h" +#include <bpf_arena_common.h> #define private (name) SEC(".bss." #name) __hidden __attribute__((aligned(8)))
tools/testing/selftests/bpf/progs/verifier_arena_globals1.c +1 -1
@@ -6,7 +6,7 @@#include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h> #include "bpf_experimental.h" -#include "bpf_arena_common.h" +#include <bpf_arena_common.h> #include "bpf_misc.h" #define ARENA_PAGES (1UL<< (32 - __builtin_ffs(__PAGE_SIZE) + 1))
tools/testing/selftests/bpf/progs/verifier_arena_globals2.c +1 -1
@@ -7,7 +7,7 @@#include <bpf/bpf_tracing.h> #include "bpf_misc.h" #include "bpf_experimental.h" -#include "bpf_arena_common.h" +#include <bpf_arena_common.h> #define ARENA_PAGES (32)
tools/testing/selftests/bpf/progs/verifier_arena_large.c +1 -1
@@ -7,7 +7,7 @@#include <bpf/bpf_tracing.h> #include "bpf_misc.h" #include "bpf_experimental.h" -#include "bpf_arena_common.h" +#include <bpf_arena_common.h> #define ARENA_SIZE (1ull << 32)
tools/testing/selftests/bpf/progs/verifier_ldsx.c +1 -1
@@ -3,7 +3,7 @@#include <linux/bpf.h> #include <bpf/bpf_helpers.h> #include "bpf_misc.h" -#include "bpf_arena_common.h" +#include <bpf_arena_common.h> #if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \ (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
Signature · 1 line
2.53.0
Emil Tsalapatis
reviewerPATCH v9 4/8 selftests/bpf: Add arena ASAN runtime to libarena
In reply to Emil TsalapatisAdd an address sanitizer (ASAN) runtime to the arena library. The ASAN runtime implements the functions injected into BPF binaries by LLVM sanitization when ASAN is enabled during compilation.
The runtime also includes functions called explicitly by memory allocation code to mark memory as poisoned/unpoisoned to ASAN. This code is a no-op when sanitization is turned off.
--- .../bpf/libarena/include/libarena/asan.h | 103 ++++ .../bpf/libarena/include/libarena/common.h | 1 + .../selftests/bpf/libarena/src/asan.bpf.c | 553 ++++++++++++++++++ 3 files changed, 657 insertions(+) create mode 100644 tools/testing/selftests/bpf/libarena/include/libarena/asan.h create mode 100644 tools/testing/selftests/bpf/libarena/src/asan.bpf.c
tools/testing/selftests/bpf/libarena/include/libarena/asan.h new file +103 -0
@@ -0,0 +1,103 @@ +// SPDX-License-Identifier: LGPL-2.1 OR BSD-2-Clause +/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */ +#pragma once + +struct asan_init_args { +u64 arena_all_pages; +u64 arena_globals_pages; +}; + +int asan_init (struct asan_init_args *args); + +extern volatile u64 __asan_shadow_memory_dynamic_address; +extern volatile u32 asan_reported; +extern volatile bool asan_inited; +extern volatile bool asan_report_once; + +#ifdef __BPF__ + +#define ASAN_SHADOW_SHIFT 3 +#define ASAN_SHADOW_SCALE (1ULL << ASAN_SHADOW_SHIFT) +#define ASAN_GRANULE_MASK ((1ULL << ASAN_SHADOW_SHIFT) - 1) +#define ASAN_GRANULE (addr) ((s8)((u32)(u64)((addr)) & ASAN_GRANULE_MASK)) + +#define __noasan __attribute__((no_sanitize("address"))) + +#ifdef BPF_ARENA_ASAN + +typedef s8 __arena s8a; + +static inline +s8a *mem_to_shadow(void __arena __arg_arena *addr) +{ +return (s8a *)(((u32 )(u64 )addr >>ASAN_SHADOW_SHIFT ) + + __asan_shadow_memory_dynamic_address); +} + +__weak __noasan +bool asan_ready(void) +{ +return __asan_shadow_memory_dynamic_address; +} + +int asan_poison(void __arena *addr, s8 val, size_t size); +int asan_unpoison(void __arena *addr, size_t size); +bool asan_shadow_set(void __arena *addr); + +/* +* Dummy calls to ensure the ASAN runtime's BTF information is present +* in every object file when compiling the runtime and local BPF code +* separately. The runtime calls are injected into the LLVM IR file +*/ +#define DECLARE_ASAN_LOAD_STORE_SIZE (size) \ + void __asan_store##size(intptr_t addr); \ + void __asan_store##size##_noabort(intptr_t addr); \ + void __asan_load##size(intptr_t addr); \ + void __asan_load##size##_noabort(intptr_t addr); \ + void __asan_report_store##size(intptr_t addr); \ + void __asan_report_store##size##_noabort(intptr_t addr); \ + void __asan_report_load##size(intptr_t addr); \ + void __asan_report_load##size##_noabort(intptr_t addr); + +DECLARE_ASAN_LOAD_STORE_SIZE (1 ); +DECLARE_ASAN_LOAD_STORE_SIZE (2 ); +DECLARE_ASAN_LOAD_STORE_SIZE (4 ); +DECLARE_ASAN_LOAD_STORE_SIZE (8 ); + +void __asan_storeN (intptr_t addr,ssize_t size); +void __asan_storeN_noabort (intptr_t addr,ssize_t size); +void __asan_loadN (intptr_t addr,ssize_t size); +void __asan_loadN_noabort (intptr_t addr,ssize_t size); + +/* +* Force LLVM to emit BTF information for the stubs, +* because the ASAN pass in LLVM by itself doesn't. +*/ +#define ASAN_LOAD_STORE_SIZE (size) \ + __asan_store##size, \ + __asan_store##size##_noabort, \ + __asan_load##size, \ + __asan_load##size##_noabort, \ + __asan_report_store##size, \ + __asan_report_store##size##_noabort, \ + __asan_report_load##size, \ + __asan_report_load##size##_noabort + +__attribute__((used)) +static void (*__asan_btf_anchors[])(intptr_t ) = { +ASAN_LOAD_STORE_SIZE (1 ), +ASAN_LOAD_STORE_SIZE (2 ), +ASAN_LOAD_STORE_SIZE (4 ), +ASAN_LOAD_STORE_SIZE (8 ), +}; + +#else /* BPF_ARENA_ASAN */ + +static inline int asan_poison(void __arena *addr, s8 val, size_t size) { return 0; } +static inline int asan_unpoison(void __arena *addr, size_t size) { return 0; } +static inline bool asan_shadow_set(void __arena *addr) { return 0; } +__weak bool asan_ready (void ) {return true; } + +#endif /* BPF_ARENA_ASAN */ + +#endif /* __BPF__ */
tools/testing/selftests/bpf/libarena/include/libarena/common.h +1 -0
@@ -44,6 +44,7 @@ struct {* the opaque volatile variable 0 instead of the constant 0. */ extern const volatile u32 zero; +extern volatile u64 asan_violated;int arena_fls (__u64 word);
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +553 -0
553 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH bpf-next v9 4/8] selftests/bpf: Add arena ASAN runtime to libarena
Sashiko AI review found 6 potential issue(s): - [Medium] Concurrent `asan_init` calls corrupt global ASAN state - [Medium] Early loop exit due to `can_loop` causes silent validation bypass and…
Sashiko AI review found 6 potential issue(s):
- [Medium] Concurrent asan_init calls corrupt global ASAN state
- [Medium] Early loop exit due to can_loop causes silent validation bypass and incomplete poisoning
- [Medium] Missing bounds checking in asan_poison and asan_unpoison allows out-of-bounds writes
- [Medium] Uninitialized ASAN state leads to silent memory corruption
- [Low] Compilation error due to missing argument for bpf_stream_print_stack
- [Low] Compilation and linking errors due to missing ASAN functions and BTF anchors --
commit 378c2bf4d6c7fb041761c5a5045f1680acbb2840
Author: Emil Tsalapatis <[email protected]>
selftests/bpf: Add arena ASAN runtime to libarena
This commit adds an ASAN runtime to the arena library for BPF selftests. It implements LLVM sanitization hooks and provides manual poison/unpoison functions.
Quoted 5 lines
tools/testing/selftests/bpf/libarena/include/libarena/asan.h new file +0
-0
[ ... ]
Quoted 1 line
tools/testing/selftests/bpf/libarena/include/libarena/asan.h new file +0
-0@@ -0,0 +1,103 @@
[ ... ]
Quoted 11 lines
tools/testing/selftests/bpf/libarena/include/libarena/asan.h new file +11
-0+/* +* Force LLVM to emit BTF information for the stubs, +* because the ASAN pass in LLVM by itself doesn't. +*/ +#define ASAN_LOAD_STORE_SIZE (size) \ + __asan_store##size, \ + __asan_store##size##_noabort, \ + __asan_load##size, \ + __asan_load##size##_noabort, \ + __asan_report_store##size, \ + __asan_report_store##size##_noabort, \
tools/testing/selftests/bpf/libarena/include/libarena/asan.h line 92
Quoted 10 lines
tools/testing/selftests/bpf/libarena/include/libarena/asan.h new file +10
-0+ __asan_report_load##size, \ + __asan_report_load##size##_noabort + +__attribute__((used)) +static void (*__asan_btf_anchors[])(intptr_t ) = { +ASAN_LOAD_STORE_SIZE (1 ), +ASAN_LOAD_STORE_SIZE (2 ), +ASAN_LOAD_STORE_SIZE (4 ), +ASAN_LOAD_STORE_SIZE (8 ), +};
Does this array need to include variable-sized hooks (like __asan_storeN), global handlers, and memory intrinsics? Without these in the anchors list, the compiler might not emit BTF data for them, potentially causing BPF load failures if LLVM instruments variable-sized accesses.
Quoted 5 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +0
-0
[ ... ]
Quoted 1 line
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +0
-0@@ -0,0 +1,553 @@
[ ... ]
Quoted 6 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +6
-0+/* +* BPF does not currently support the memset/memcpy/memcmp intrinsics. +* For large sequential copies, or assignments of large data structures, +* the frontend will generate an intrinsic that causes the BPF backend +* to exit due to a missing implementation. Provide a simple implementation +* just for memset to use it for poisoning/unpoisoning the map.
tools/testing/selftests/bpf/libarena/src/asan.bpf.c line 121
Quoted 10 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +10
-0+*/ +__weak int asan_memset(s8a __arg_arena *dst, s8 val, size_t size) +{ +size_t i; + +for (i = zero; i < size && can_loop; i++) + dst[i] = val; + +return 0 ; +}
Is can_loop defined anywhere? This looks like it might cause an undeclared identifier compilation error.
Also, if can_loop causes the loop to exit early due to instruction limits, does this result in incomplete poisoning? asan_memset would return 0, leaving the rest of the shadow memory uninitialized.
[ ... ]
tools/testing/selftests/bpf/libarena/src/asan.bpf.c line 176
Quoted 11 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +11
-0+static __always_inline u64 first_nonzero_byte(u64 addr, size_t size) +{ +while (size && can_loop) { +if (unlikely (*(s8a *)addr)) +return addr; + addr +=1 ; + size -=1 ; + } + +return SHADOW_ALL_ZEROES ; +}
Similarly, if can_loop terminates this loop early, could this falsely validate the remaining memory and allow large out-of-bounds accesses to bypass ASAN validation?
[ ... ]
Quoted 5 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +5
-0+__weak int asan_report(s8a __arg_arena *addr, size_t sz, u32 flags) +{ +u32 reported =__sync_val_compare_and_swap (&asan_reported, false, true); + +/* Only report the first ASAN violation. */
tools/testing/selftests/bpf/libarena/src/asan.bpf.c line 209
Quoted 10 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +10
-0+if (reported && asan_report_once) +return 0 ; + + asan_violated = (u64 )addr; + +arena_stderr ("Memory violation for address %p (0x%lx) for %s of size %ld\n" , + addr, (u64 )addr, + (flags &ASAN_WRITE ) ?"write" :"read" , + sz); +bpf_stream_print_stack (BPF_STDERR );
Is this missing an argument? The kernel definition of this kfunc is bpf_stream_print_stack(int stream_id, struct bpf_prog_aux *aux). Compiling this with vmlinux.h could result in a compilation error.
[ ... ]
Quoted 4 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +4
-0+__hidden __noasan int asan_poison(void __arena *addr, s8 val, size_t size) +{ +s8a *shadow; +size_t len;
[ ... ]
tools/testing/selftests/bpf/libarena/src/asan.bpf.c line 428
Quoted 7 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +7
-0+ shadow =mem_to_shadow (addr); + len = size >>ASAN_SHADOW_SHIFT ; + +asan_memset (shadow, val, len); + +return 0 ; +}
Does this code verify that asan_init() has been called before executing? If __asan_shadow_memory_dynamic_address is 0, mem_to_shadow() could resolve to the beginning of the user arena, causing asan_memset() to overwrite valid application data.
Additionally, is there a bounds check missing to ensure addr + size falls entirely within the valid user region? If size extends beyond the user boundaries, could this write past the shadow map and corrupt the arena's global variables?
[ ... ]
Quoted 5 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +5
-0+__hidden __noasan int asan_unpoison(void __arena *addr, size_t size) +{ +size_t partial = size &ASAN_GRANULE_MASK ; +s8a *shadow; +size_t len;
[ ... ]
tools/testing/selftests/bpf/libarena/src/asan.bpf.c line 466
Quoted 4 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +4
-0+ shadow =mem_to_shadow (addr); + len = size >>ASAN_SHADOW_SHIFT ; + +asan_memset (shadow,0 , len);
Does this unpoisoning function have the same uninitialized state and bounds checking concerns as asan_poison()?
[ ... ]
Quoted 10 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +10
-0+SEC("syscall") +__weak __noasan int asan_init(struct asan_init_args *args) +{ +u64 globals_pages = args->arena_globals_pages; +u64 all_pages = args->arena_all_pages; +u64 shadow_map, shadow_pgoff; +u64 shadow_pages; + +if (asan_inited) +return 0 ;
[ ... ]
Quoted 18 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +18
-0+ shadow_pgoff = all_pages - shadow_pages - globals_pages; + __asan_shadow_memory_dynamic_address = shadow_pgoff * __PAGE_SIZE; + +/* +* Allocate the last (1/ASAN_SHADOW_SCALE)th of an arena's pages for the map +* We find the offset and size from the arena map. +* +* The allocated map pages are zeroed out, meaning all memory is marked as valid +* even if it's not allocated already. This is expected: Since the actual memory +* pages are not allocated, accesses to it will trigger page faults and will be +* reported through BPF streams. Any pages allocated through bpf_arena_alloc_pages +* should be poisoned by the allocator right after the call succeeds. +*/ + shadow_map = (u64 )bpf_arena_alloc_pages ( + &arena, (void __arena *)__asan_shadow_memory_dynamic_address, + shadow_pages,NUMA_NO_NODE ,0 ); +if (!shadow_map) { +arena_stderr ("Could not allocate shadow map\n" );
tools/testing/selftests/bpf/libarena/src/asan.bpf.c line 547
Quoted 10 lines
tools/testing/selftests/bpf/libarena/src/asan.bpf.c new file +10
-0+ + __asan_shadow_memory_dynamic_address =0 ; + +return -ENOMEM ; + } + + asan_inited = true; + +return 0 ; +}
Can this code corrupt the global shadow memory base if invoked concurrently?
If two threads bypass the lockless asan_inited check, thread 1 could successfully allocate memory and set asan_inited = true. Thread 2 might then fail its allocation (since the pages are already mapped) and execute the error path, setting __asan_shadow_memory_dynamic_address = 0.
Would this permanently corrupt the global ASAN state for all subsequent checks in the arena?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Emil Tsalapatis
reviewerPATCH v9 5/8 selftests/bpf: Add ASAN support for libarena selftests
In reply to Emil TsalapatisExpand the arena library selftest infrastructure to support address sanitization. Add the compiler flags necessary to compile the library under ASAN when supported.
--- tools/testing/selftests/bpf/Makefile | 22 +++++++- tools/testing/selftests/bpf/libarena/Makefile | 25 ++++++++- .../bpf/libarena/include/libarena/userspace.h | 33 ++++++++++++ .../bpf/libarena/selftests/st_asan_common.h | 52 +++++++++++++++++++ .../selftests/bpf/libarena/src/common.bpf.c | 2 + 5 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h
tools/testing/selftests/bpf/Makefile +21 -1
@@ -79,6 +79,12 @@ ifneq ($(shell $(CLANG) --target=bpf -mcpu=help 2>&1 | grep 'v4'),) CLANG_CPUV4 := 1 endif +# Check whether clang supports BPF address sanitizer (requires LLVM 22+) +CLANG_HAS_ARENA_ASAN := $(shell echo 'int x;' | \ + $(CLANG) --target=bpf -fsanitize=kernel-address \ + -mllvm -asan-shadow-addr-space=1 \ + -x c -c - -o /dev/null 2>/dev/null && echo 1) + # Order correspond to 'make run_tests' order TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_progs \ test_sockmap \
@@ -767,6 +773,14 @@ LIBARENA_SKEL := libarena/libarena.skel.h $(LIBARENA_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BPF_DEPS) +$(MAKE) -C libarena libarena.skel.h $(LIBARENA_MAKE_ARGS) +ifneq ($(CLANG_HAS_ARENA_ASAN),) +LIBARENA_ASAN_SKEL := libarena/libarena_asan.skel.h +CFLAGS += -DHAS_BPF_ARENA_ASAN + +$(LIBARENA_ASAN_SKEL): $(INCLUDE_DIR)/vmlinux.h $(BPFOBJ) $(LIBARENA_BPF_DEPS) + +$(MAKE) -C libarena libarena_asan.skel.h $(LIBARENA_MAKE_ARGS) +endif + # Define test_progs test runner. TRUNNER_TESTS_DIR := prog_tests TRUNNER_BPF_PROGS_DIR := progs
@@ -791,7 +805,9 @@ TRUNNER_EXTRA_SOURCES := test_progs.c \ flow_dissector_load.h \ ip_check_defrag_frags.h \ bpftool_helpers.c \ - usdt_1.c usdt_2.c + usdt_1.c usdt_2.c \ + $(LIBARENA_SKEL) \ + $(LIBARENA_ASAN_SKEL) TRUNNER_LIB_SOURCES := find_bit.c TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read \ $(OUTPUT)/liburandom_read.so \
@@ -962,3 +978,7 @@ override define INSTALL_RULE endef libarena: $(LIBARENA_SKEL) + +ifneq ($(CLANG_HAS_ARENA_ASAN),) +libarena_asan: $(LIBARENA_ASAN_SKEL) +endif
tools/testing/selftests/bpf/libarena/Makefile +24 -1
@@ -30,6 +30,7 @@ LIBBPF_INCLUDE ?= $(INCLUDE_DIR) # Scan src/ and selftests/ to generate the final binaries LIBARENA_SOURCES = $(wildcard $(LIBARENA)/src/*.bpf.c) $(wildcard $(LIBARENA)/selftests/*.bpf.c) LIBARENA_OBJECTS = $(notdir $(LIBARENA_SOURCES:.bpf.c=.bpf.o)) +LIBARENA_OBJECTS_ASAN = $(notdir $(LIBARENA_SOURCES:.bpf.c=_asan.bpf.o)) INCLUDES = -I$(LIBARENA)/include -I$(BPFDIR) ifneq ($(INCLUDE_DIR),)
@@ -39,6 +40,13 @@ ifneq ($(LIBBPF_INCLUDE),) INCLUDES += -I$(LIBBPF_INCLUDE) endif +ASAN_FLAGS = -fsanitize=kernel-address -fno-stack-protector -fno-builtin +ASAN_FLAGS += -mllvm -asan-instrument-address-spaces=1 -mllvm -asan-shadow-addr-space=1 +ASAN_FLAGS += -mllvm -asan-use-stack-safety=0 -mllvm -asan-stack=0 +ASAN_FLAGS += -mllvm -asan-kernel=1 +ASAN_FLAGS += -mllvm -asan-constructor-kind=none +ASAN_FLAGS += -mllvm -asan-destructor-kind=none + # ENABLE_ATOMICS_TESTS required because we use arena spinlocks override BPF_CFLAGS += -DENABLE_ATOMICS_TESTS override BPF_CFLAGS += -O2 -g
@@ -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 + +libarena_asan.skel.h: libarena_asan.bpf.o + $(call msg,GEN-SKEL,libarena,$@) + $(Q)$(BPFTOOL) gen skeleton $< name "libarena_asan" > $@ + libarena.skel.h: libarena.bpf.o $(call msg,GEN-SKEL,libarena,$@) $(Q)$(BPFTOOL) gen skeleton $< name "libarena" > $@ +libarena_asan.bpf.o: $(LIBARENA_OBJECTS_ASAN) + $(call msg,GEN-OBJ,libarena,$@) + $(Q)$(BPFTOOL) gen object $@ $^ + libarena.bpf.o: $(LIBARENA_OBJECTS) $(call msg,GEN-OBJ,libarena,$@) $(Q)$(BPFTOOL) gen object $@ $^ +%_asan.bpf.o: %.bpf.c + $(call msg,CLNG-BPF,libarena,$@) + $(Q)$(CLANG) $(BPF_CFLAGS) $(ASAN_FLAGS) -DBPF_ARENA_ASAN $(BPF_TARGET_ENDIAN) -c $< -o $@ + %.bpf.o: %.bpf.c $(call msg,CLNG-BPF,libarena,$@) $(Q)$(CLANG) $(BPF_CFLAGS) $(BPF_TARGET_ENDIAN) -c $< -o $@ clean: - $(Q)rm -f *.skel.h *.bpf.o + $(Q)rm -f *.skel.h *.bpf.o *.linked*.o
tools/testing/selftests/bpf/libarena/include/libarena/userspace.h +33 -0
@@ -27,6 +27,11 @@ static inline bool libarena_is_test_prog(const char *name)return strstr (name,"test_" ) == name; } +static inline bool libarena_is_asan_test_prog (const char *name) +{ +return strstr (name,"asan_test" ) == name; +} +static inline int libarena_run_prog_args (int prog_fd,void *args,size_t argsize) {LIBBPF_OPTS (bpf_test_run_opts, opts);
@@ -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; +u64 globals_pages; +int ret; + + ret =libarena_get_globals_pages (arena_asan_init_fd, + arena_all_pages, &globals_pages); +if (ret) +return ret; + + args = (struct asan_init_args ){ + .arena_all_pages = arena_all_pages, + .arena_globals_pages = globals_pages, + }; + + opts.ctx_in = &args; + opts.ctx_size_in =sizeof (args); + + ret =bpf_prog_test_run_opts (asan_init_fd, &opts); +if (ret) +return ret; +return opts.retval; +}
tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h new file +52 -0
52 lines not on this page · raw message
tools/testing/selftests/bpf/libarena/src/common.bpf.c +2 -0
@@ -2,6 +2,8 @@/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */ #include <libarena/common.h> +#include <libarena/asan.h> +const volatile u32 zero =0 ;int arena_fls (__u64 word)
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH bpf-next v9 5/8] selftests/bpf: Add ASAN support for libarena selftests
The print_asan_map_state() function dereferences addr with `*(s8a *)(addr)`, which could be problematic. Could this trigger a secondary ASAN violation or BPF exception if addr points to unmapped…
Quoted 10 lines
tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h new file +4
-0@@ -0,0 +1,52 @@ +// SPDX-License-Identifier: LGPL-2.1 OR BSD-2-Clause +/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */ + +#pragma once
tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h line 14
Quoted 10 lines
tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h new file +10
-0+ +#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" ); +}
The print_asan_map_state() function dereferences addr with *(s8a *)(addr), which could be problematic. Could this trigger a secondary ASAN violation or BPF exception if addr points to unmapped memory outside the arena?
In v8, sashiko-bot noted that this dereference could terminate the test before the debug output is printed if addr is invalid. The suggestion was to use the __noasan attribute to avoid interception by ASAN instrumentation.
Reference: https://lore.kernel.org/bpf/[email protected]/
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/24964771851
[email protected]
AI reviewRe: [PATCH bpf-next v9 5/8] selftests/bpf: Add ASAN support for libarena selftests
In reply to Emil TsalapatisSashiko 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`…
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 <[email protected]>
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.
Quoted 4 lines
tools/testing/selftests/bpf/libarena/Makefile +0
-0
[ ... ]
tools/testing/selftests/bpf/libarena/Makefile CFLAGS += $(INCLUDES) · line 65
Quoted 6 lines
tools/testing/selftests/bpf/libarena/Makefile +2
-0@@ -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?
[ ... ]
Quoted 4 lines
tools/testing/selftests/bpf/libarena/include/libarena/userspace.h +0
-0
[ ... ]
tools/testing/selftests/bpf/libarena/include/libarena/userspace.h static inline int libarena_get_globals_pages(int arena_get_globals_fd, · line 111
Quoted 11 lines
tools/testing/selftests/bpf/libarena/include/libarena/userspace.h +7
-0@@ -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?
[ ... ]
tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h line 5
Quoted 11 lines
tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h new file +5
-0@@ -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>.
tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h line 14
Quoted 9 lines
tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h new file +9
-0+#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.
tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h line 22
Quoted 8 lines
tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h new file +8
-0+ +/* +* 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.
Quoted 3 lines
tools/testing/selftests/bpf/libarena/selftests/st_asan_common.h new file +3
-0+ asan_violated =0 ; +return 0 ; + }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Emil Tsalapatis
reviewerPATCH v9 6/8 selftests/bpf: Add buddy allocator for libarena
In reply to Emil TsalapatisAdd a byte-oriented buddy allocator for libarena. The buddy allocator provides an alloc/free interface for small arena allocations ranging from 16 bytes to 512 KiB. Lower allocations values are rounded up to 16 bytes. The buddy allocator does not handle larger allocations that can instead use the existing bpf_arena_{alloc, free}_pages() kfunc.
--- tools/testing/selftests/bpf/default.profraw | Bin 0 -> 160 bytes tools/testing/selftests/bpf/libarena/Makefile | 2 + .../bpf/libarena/include/libarena/buddy.h | 92 ++ .../bpf/libarena/include/libarena/common.h | 14 + .../selftests/bpf/libarena/src/buddy.bpf.c | 903 ++++++++++++++++++ .../selftests/bpf/libarena/src/common.bpf.c | 23 +- 6 files changed, 1033 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/bpf/default.profraw create mode 100644 tools/testing/selftests/bpf/libarena/include/libarena/buddy.h create mode 100644 tools/testing/selftests/bpf/libarena/src/buddy.bpf.c
tools/testing/selftests/bpf/default.profraw new file binary +0 -0
tools/testing/selftests/bpf/libarena/Makefile +2 -0
@@ -51,6 +51,8 @@ ASAN_FLAGS += -mllvm -asan-destructor-kind=none override BPF_CFLAGS += -DENABLE_ATOMICS_TESTS override BPF_CFLAGS += -O2 -g override BPF_CFLAGS += -Wno-incompatible-pointer-types-discards-qualifiers +# Required to define our own arena-based free() +override BPF_CFLAGS += -Wno-incompatible-library-redeclaration # Required for suppressing harmless vmlinux.h-related warnings. override BPF_CFLAGS += -Wno-missing-declarations override BPF_CFLAGS += $(INCLUDES)
tools/testing/selftests/bpf/libarena/include/libarena/buddy.h new file +92 -0
92 lines not on this page · raw message
tools/testing/selftests/bpf/libarena/include/libarena/common.h +14 -0
@@ -48,6 +48,20 @@ extern volatile u64 asan_violated;int arena_fls (__u64 word); +u64 malloc_internal (size_t size); +#define malloc (size) ((void __arena *)malloc_internal((size))) +void free(void __arena *ptr); + +/* +* The verifier associates arenas with programs by checking LD.IMM +* instruction operands for an arena and populating the program state +* with the first instance it finds. This requires accessing our global +* arena variable, but subprogs do not necessarily do so while still +* using pointers from that arena. Insert an LD.IMM instruction to +* access the arena and help the verifier. +*/ +#define arena_subprog_init () do { asm volatile ("" :: "r"(&arena)); } while (0) +#else /* ! __BPF__ */ #include <stdint.h>
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c new file +903 -0
903 lines not on this page · raw message
tools/testing/selftests/bpf/libarena/src/common.bpf.c +22 -1
@@ -1,11 +1,13 @@// SPDX-License-Identifier: LGPL-2.1 OR BSD-2-Clause /* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */ #include <libarena/common.h> -#include <libarena/asan.h> +#include <libarena/buddy.h> const volatile u32 zero =0 ; +buddy_t buddy; +int arena_fls (__u64 word) {if (!word)
@@ -28,4 +30,23 @@ __weak int arena_alloc_reserve(struct arena_alloc_reserve_args *args)return bpf_arena_reserve_pages (&arena,NULL , args->nr_pages); } +SEC("syscall") +__weak int arena_buddy_reset (void ) +{ +buddy_destroy (&buddy); + +return buddy_init (&buddy); +} + +__weak u64 malloc_internal (size_t size) +{ +return buddy_alloc_internal (&buddy, size); +} + +__weak void free(void __arg_arena __arena *ptr) +{ +buddy_free_internal (&buddy, (u64 )ptr); +} + + char _license[] SEC("license") = "GPL";
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH bpf-next v9 6/8] selftests/bpf: Add buddy allocator for libarena
In v4, Alexei Starovoitov requested a mathematical analysis of the memory savings from using u32 indices instead of pointers in this structure:
Quoted 5 lines
tools/testing/selftests/bpf/libarena/include/libarena/buddy.h new file +0
-0
[ ... ]
tools/testing/selftests/bpf/libarena/include/libarena/buddy.h line 56
Quoted 4 lines
tools/testing/selftests/bpf/libarena/include/libarena/buddy.h new file +4
-0+struct buddy_header { +u32 prev_index;/* "Pointer" to the previous available allocation of the same size. */ +u32 next_index;/* Same for the next allocation. */ +};
In v4, Alexei Starovoitov requested a mathematical analysis of the memory savings from using u32 indices instead of pointers in this structure:
"BUDDY_CHUNK_ITEMS is used like NULL? The header is u32 + u32. Is it really worth saving 8 bytes? Use two proper pointers? How many headers are there? ... if everything is a pointer the whole algorithm would be so much easier to understand. Is it worth it to keep indices vs pointers? Please do the math and explain the savings."
https://lore.kernel.org/bpf/CAADnVQKnHXg0YnuLvzfXjszMaqugpMNWD5=ipffWS4GVNg6rFQ@mail.gmail.com/
The response explained the rationale for ASAN effectiveness and memory corruption protection (headers in free blocks offset at byte 8 to catch off-by-one errors), but did not provide the quantitative memory savings analysis that was explicitly requested.
The bot in v8 also flagged this as unaddressed:
https://lore.kernel.org/bpf/f6f35b4cb34724773df4e2f2d5014f64048931cd6eeb747875a84f3a9d1db4ed@mail.kernel.org/
Would it be possible to add a comment documenting the mathematical trade-off analysis, or include it in the commit message?
[ ... ]
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/24964771851
[email protected]
AI reviewRe: [PATCH bpf-next v9 6/8] selftests/bpf: Add buddy allocator for libarena
In reply to Emil TsalapatisSashiko AI review found 4 potential issue(s): - [High] Permanent memory leaks of newly allocated chunks and freed blocks when allocator lock acquisition fails. - [Medium] Unnecessary global lock…
Sashiko AI review found 4 potential issue(s):
- [High] Permanent memory leaks of newly allocated chunks and freed blocks when allocator lock acquisition fails.
- [Medium] Unnecessary global lock contention during thread-local chunk initialization.
- [Medium] Missing rollback of virtual address space reservation on initialization failure.
- [Low] Accidental inclusion of default.profraw binary file.
--
commit d3559de018f16408b8163bc0362e7b5fdd94366e
Author: Emil Tsalapatis <[email protected]>
selftests/bpf: Add buddy allocator for libarena
Add a byte-oriented buddy allocator for libarena. The buddy allocator provides an alloc/free interface for small arena allocations ranging from 16 bytes to 512 KiB.
tools/testing/selftests/bpf/default.profraw
Quoted 4 lines
tools/testing/selftests/bpf/default.profraw new file binary +0
-0
This isn't a bug, but it looks like a binary LLVM profile data file was accidentally included in the patch.
Quoted 5 lines
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c new file +0
-0
[ ... ]
Quoted 2 lines
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c new file +2
-0+static buddy_chunk_t *buddy_chunk_get (buddy_t *buddy) +{
[ ... ]
Quoted 17 lines
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c new file +17
-0+ chunk = bpf_arena_alloc_pages(&arena, (void __arena *)vaddr, +BUDDY_CHUNK_PAGES ,NUMA_NO_NODE ,0 ); +if (!chunk) { +arena_stderr ("[ALLOC FAILED]" ); +return NULL ; + } + +if (buddy_lock (buddy)) { +/* +* We cannot reclaim the vaddr space, but that is ok - this +* operation should always succeed. The error path is to catch +* accidental deadlocks that will cause -ENOMEMs to the program as +* the allocator fails to refill itself, in which case vaddr usage +* is the least of our worries. +*/ + bpf_arena_free_pages(&arena, (void __arena *)vaddr, BUDDY_CHUNK_PAGES); +return NULL ;
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c line 438
Quoted 10 lines
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c new file +10
-0+ } + +asan_poison (chunk,BUDDY_POISONED ,BUDDY_CHUNK_PAGES * __PAGE_SIZE); + +/* Unpoison the chunk itself. */ +asan_unpoison (chunk,sizeof (*chunk)); + +/* Mark all freelists as empty. */ +for (ord = zero; ord <BUDDY_CHUNK_NUM_ORDERS && can_loop; ord++) + chunk->freelists[ord] =BUDDY_CHUNK_ITEMS ;
Does holding the global allocator lock here create unnecessary contention?
Since this newly allocated chunk is not yet linked to the global allocator state (which happens later in buddy_alloc_from_new_chunk()), could the memory poisoning, unpoisoning, and freelist initialization loop be done before acquiring the global lock?
[ ... ]
Quoted 12 lines
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c new file +12
-0+__weak int buddy_init(buddy_t __arg_arena *buddy) +{ +buddy_chunk_t *chunk; +int ret; + +if (!asan_ready ()) +return -EINVAL ; + +/* Reserve enough address space to ensure allocations are aligned. */ + ret =buddy_reserve_arena_vaddr (buddy); +if (ret) +return ret;
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c line 585
Quoted 10 lines
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c new file +10
-0+ +_Static_assert (BUDDY_CHUNK_PAGES >0 , +"chunk must use one or more pages" ); + + chunk =buddy_chunk_get (buddy); + +if (buddy_lock (buddy)) { +bpf_arena_free_pages (&arena, chunk,BUDDY_CHUNK_PAGES ); +return -EINVAL ; + }
If buddy_chunk_get() or buddy_lock() fails, does this permanently leak the virtual address space reserved earlier?
It looks like buddy_unreserve_arena_vaddr() should be called in these error paths to prevent exhaustion of the reserved range.
[ ... ]
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c line 736
Quoted 6 lines
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c new file +6
-0+static u64 buddy_alloc_from_new_chunk (buddy_t *buddy,buddy_chunk_t *chunk,int order) +{ +u64 address; + +if (buddy_lock (buddy)) +return (u64 )NULL ;
If the allocator lock cannot be acquired, does this drop the newly allocated chunk without linking it or freeing it?
Since bpf_arena_free_pages() isn't called on the chunk, it appears this could permanently leak physical and virtual arena memory.
[ ... ]
Quoted 4 lines
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c new file +4
-0+__weak int buddy_free_internal(buddy_t __arg_arena *buddy, u64 addr) +{ +int ret; +
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c line 894
Quoted 10 lines
tools/testing/selftests/bpf/libarena/src/buddy.bpf.c new file +10
-0+if (!buddy) +return -EINVAL ; + +/* Freeing NULL is a valid no-op. */ +if (!addr) +return 0 ; + + ret =buddy_lock (buddy); +if (ret) +return ret;
If lock acquisition fails here, does the block get permanently leaked?
Since the user-facing free() wrapper returns void, the caller has no way of knowing the free failed, resulting in silently swallowed errors and lost memory.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Emil Tsalapatis
reviewerPATCH v9 7/8 selftests/bpf: Add selftests for libarena buddy allocator
In reply to Emil TsalapatisIntroduce selftests for the buddy allocator with and without ASAN. Add the libarena selftests both to the libarena test runner and to test_progs, so that they are a) available when libarena is pulled as a standalone library, and b) exercised along with all other test programs in this directory.
ASAN for libarena requires LLVM 22. Add logic in the top-level selftests Makefile to only compile the ASAN variant if the compiler supports it, otherwise skip the test.
--- .../libarena/selftests/st_asan_buddy.bpf.c | 240 ++++++++++++++++++ .../bpf/libarena/selftests/st_buddy.bpf.c | 209 +++++++++++++++ .../selftests/bpf/prog_tests/libarena.c | 66 +++++ .../selftests/bpf/prog_tests/libarena_asan.c | 91 +++++++ 4 files changed, 606 insertions(+) create mode 100644 tools/testing/selftests/bpf/libarena/selftests/st_asan_buddy.bpf.c create mode 100644 tools/testing/selftests/bpf/libarena/selftests/st_buddy.bpf.c create mode 100644 tools/testing/selftests/bpf/prog_tests/libarena.c create mode 100644 tools/testing/selftests/bpf/prog_tests/libarena_asan.c
tools/testing/selftests/bpf/libarena/selftests/st_asan_buddy.bpf.c new file +240 -0
@@ -0,0 +1,240 @@ +// SPDX-License-Identifier: LGPL-2.1 OR BSD-2-Clause +/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */ + +#include <libarena/common.h> +#include <libarena/asan.h> +#include <libarena/buddy.h> + +extern buddy_t buddy; + +#ifdef BPF_ARENA_ASAN + +#include "st_asan_common.h" + +static __always_inline int asan_test_buddy_oob_single(size_t alloc_size) +{ + u8 __arena *mem; +int ret, i; + + ret =asan_validate (); +if (ret <0 ) +return ret; + + mem =buddy_alloc (&buddy, alloc_size); +if (!mem) { +arena_stdout ("buddy_alloc failed for size %lu" , alloc_size); +return -ENOMEM ; + } + + ret =asan_validate (); +if (ret <0 ) +return ret; + +for (i = zero; i < alloc_size && can_loop; i++) { + mem[i] =0xba ; + ret =asan_validate_addr (false, &mem[i]); +if (ret <0 ) +return ret; + } + + mem[alloc_size] =0xba ; + ret =asan_validate_addr (true, &mem[alloc_size]); +if (ret <0 ) +return ret; + +buddy_free (&buddy, mem); + +return 0 ; +} + +/* +* Factored out because asan_validate_addr is complex enough to cause +* verification failures if verified with the rest of asan_test_buddy_uaf_single. +*/ +__weak int asan_test_buddy_byte(u8 __arena __arg_arena *mem, int i, bool freed) +{ +int ret; + +/* The header in freed blocks doesn't get poisoned. */ +if (freed &&BUDDY_HEADER_OFF <= i && + i <BUDDY_HEADER_OFF +sizeof (struct buddy_header )) +return 0 ; + + mem[i] =0xba ; + ret =asan_validate_addr (freed, &mem[i]); +if (ret <0 ) +return ret; + +return 0 ; +} + +__weak int asan_test_buddy_uaf_single (size_t alloc_size) +{ + u8 __arena *mem; +int ret; +int i; + + mem =buddy_alloc (&buddy, alloc_size); +if (!mem) { +arena_stdout ("buddy_alloc failed for size %lu" , alloc_size); +return -ENOMEM ; + } + + ret =asan_validate (); +if (ret <0 ) +return ret; + +for (i = zero; i < alloc_size && can_loop; i++) { + ret =asan_test_buddy_byte (mem, i, false); +if (ret) +return ret; + } + + ret =asan_validate (); +if (ret <0 ) +return ret; + +buddy_free (&buddy, mem); + +for (i = zero; i < alloc_size && can_loop; i++) { + ret =asan_test_buddy_byte (mem, i, true); +if (ret) +return ret; + } + +return 0 ; +} + +struct buddy_blob { +volatile u8 mem[48 ]; +u8 oob; +}; + +static __always_inline int asan_test_buddy_blob_single(void) +{ + volatile struct buddy_blob __arena *blob; +const size_t alloc_size =sizeof (struct buddy_blob ) -1 ; +int ret; + + blob =buddy_alloc (&buddy, alloc_size); +if (!blob) +return -ENOMEM ; + + blob->mem[0 ] =0xba ; + ret =asan_validate_addr (false, &blob->mem[0 ]); +if (ret <0 ) +return ret; + + blob->mem[47 ] =0xba ; + ret =asan_validate_addr (false, &blob->mem[47 ]); +if (ret <0 ) +return ret; + + blob->oob =0 ; + ret =asan_validate_addr (true, &blob->oob); +if (ret <0 ) +return ret; + + buddy_free(&buddy, (void __arena *)blob); + +return 0 ; +} + +SEC("syscall") +__weak int asan_test_buddy_oob (void ) +{ +size_t sizes[] = { +7 ,8 ,17 ,18 ,64 ,256 ,317 ,512 ,1024 , + }; +int ret, i; + + ret =buddy_init (&buddy); +if (ret) { +arena_stdout ("buddy_init failed with %d" , ret); +return ret; + } + +for (i = zero; i <sizeof (sizes) /sizeof (sizes[0 ]) && can_loop; i++) { + ret =asan_test_buddy_oob_single (sizes[i]); +if (ret) { +arena_stdout ("%s:%d Failed for size %lu" , __func__, + __LINE__, sizes[i]); +buddy_destroy (&buddy); +return ret; + } + } + +buddy_destroy (&buddy); + + ret =asan_validate (); +if (ret <0 ) +return ret; + +return 0 ; +} + +SEC("syscall") +__weak int asan_test_buddy_uaf (void ) +{ +size_t sizes[] = {16 ,32 ,64 ,128 ,256 ,512 ,1024 ,16384 }; +int ret, i; + + ret =buddy_init (&buddy); +if (ret) { +arena_stdout ("buddy_init failed with %d" , ret); +return ret; + } + +for (i = zero; i <sizeof (sizes) /sizeof (sizes[0 ]) && can_loop; i++) { + ret =asan_test_buddy_uaf_single (sizes[i]); +if (ret) { +arena_stdout ("%s:%d Failed for size %lu" , __func__, + __LINE__, sizes[i]); +buddy_destroy (&buddy); +return ret; + } + } + +buddy_destroy (&buddy); + + ret =asan_validate (); +if (ret <0 ) +return ret; + +return 0 ; +} + +SEC("syscall") +__weak int asan_test_buddy_blob (void ) +{ +const int iters =10 ; +int ret, i; + + ret =buddy_init (&buddy); +if (ret) { +arena_stdout ("buddy_init failed with %d" , ret); +return ret; + } + +for (i = zero; i < iters && can_loop; i++) { + ret =asan_test_buddy_blob_single (); +if (ret) { +arena_stdout ("%s:%d Failed on iteration %d" , __func__, + __LINE__, i); +buddy_destroy (&buddy); +return ret; + } + } + +buddy_destroy (&buddy); + + ret =asan_validate (); +if (ret <0 ) +return ret; + +return 0 ; +} + +#endif + +__weak char _license[] SEC("license") = "GPL";
tools/testing/selftests/bpf/libarena/selftests/st_buddy.bpf.c new file +209 -0
209 lines not on this page · raw message
tools/testing/selftests/bpf/prog_tests/libarena.c new file +66 -0
66 lines not on this page · raw message
tools/testing/selftests/bpf/prog_tests/libarena_asan.c new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH bpf-next v9 7/8] selftests/bpf: Add selftests for libarena buddy allocator
Sashiko AI review found 1 potential issue(s): - [Medium] Commit message claims to add Makefile logic that is actually missing from the patch (added in a previous patch). --
Sashiko AI review found 1 potential issue(s):
- [Medium] Commit message claims to add Makefile logic that is actually missing from the patch (added in a previous patch). --
commit 1b0628e5609c4e162f40fb718876176d30532a33
Author: Emil Tsalapatis <[email protected]>
selftests/bpf: Add selftests for libarena buddy allocator
This commit introduces selftests for the libarena buddy allocator, including both ASAN and non-ASAN variants. It integrates these tests into both the standalone libarena test runner and the broader test_progs suite.
Quoted 3 lines
ASAN for libarena requires LLVM 22. Add logic in the top-level selftests
Makefileto only compile the ASAN variant if the compiler supports it, otherwise skip the test.
This isn't a bug, but the commit message mentions adding logic in the Makefile to conditionally compile the ASAN variant. However, the diff for this patch only contains additions for C source files and does not include any Makefile modifications.
Was this Makefile logic perhaps already included in an earlier patch in the series? If so, should the commit message be updated to accurately reflect only the changes introduced by this specific patch?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Emil Tsalapatis
reviewerPATCH v9 8/8 selftests/bpf: Reuse stderr parsing for libarena ASAN tests
In reply to Emil TsalapatisAdd code to directly test the output of libarena ASAN tests. The code reuses testing infrastructure originally for BPF streams to verify that ASAN emits call stacks when the selftests trigger a memory error.
Since stderr() testing uses logic from test_progs, it is only available on the test_progs-based selftest runner. The standalone runner still uses internal ASAN state to verify access errors are triaged as expected.
--- .../libarena/selftests/st_asan_buddy.bpf.c | 18 +++++++ .../libarena/selftests/test_progs_compat.h | 15 ++++++ .../selftests/bpf/prog_tests/libarena_asan.c | 2 + tools/testing/selftests/bpf/test_loader.c | 51 ++++++++++++++----- tools/testing/selftests/bpf/test_progs.h | 2 + 5 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 tools/testing/selftests/bpf/libarena/selftests/test_progs_compat.h
tools/testing/selftests/bpf/libarena/selftests/st_asan_buddy.bpf.c +18 -0
@@ -5,6 +5,9 @@#include <libarena/asan.h> #include <libarena/buddy.h> +/* Required for parsing the ASAN call stacks. */ +#include "test_progs_compat.h" +extern buddy_t buddy;#ifdef BPF_ARENA_ASAN
@@ -141,6 +144,11 @@ static __always_inline int asan_test_buddy_blob_single(void) } SEC("syscall") +__stderr("Memory violation for address {{.*}} for write of size 1") +__stderr("CPU: {{[0-9]+}} UID: 0 PID: {{[0-9]+}} Comm: {{.*}}") +__stderr ("Call trace:\n" +"{{([a-zA-Z_][a-zA-Z0-9_]*\\+0x[0-9a-fA-F]+/0x[0-9a-fA-F]+\n" +"|[ \t]+[^\n]+\n)*}}")__weak int asan_test_buddy_oob (void ) {size_t sizes[] = {
@@ -174,6 +182,11 @@ __weak int asan_test_buddy_oob(void) } SEC("syscall") +__stderr("Memory violation for address {{.*}} for write of size 1") +__stderr("CPU: {{[0-9]+}} UID: 0 PID: {{[0-9]+}} Comm: {{.*}}") +__stderr ("Call trace:\n" +"{{([a-zA-Z_][a-zA-Z0-9_]*\\+0x[0-9a-fA-F]+/0x[0-9a-fA-F]+\n" +"|[ \t]+[^\n]+\n)*}}")__weak int asan_test_buddy_uaf (void ) {size_t sizes[] = {16 ,32 ,64 ,128 ,256 ,512 ,1024 ,16384 };
@@ -205,6 +218,11 @@ __weak int asan_test_buddy_uaf(void) } SEC("syscall") +__stderr("Memory violation for address {{.*}} for write of size 1") +__stderr("CPU: {{[0-9]+}} UID: 0 PID: {{[0-9]+}} Comm: {{.*}}") +__stderr ("Call trace:\n" +"{{([a-zA-Z_][a-zA-Z0-9_]*\\+0x[0-9a-fA-F]+/0x[0-9a-fA-F]+\n" +"|[ \t]+[^\n]+\n)*}}")__weak int asan_test_buddy_blob (void ) {const int iters =10 ;
tools/testing/selftests/bpf/libarena/selftests/test_progs_compat.h new file +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: LGPL-2.1 OR BSD-2-Clause +/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */ +#pragma once + +#ifdef __BPF__ + +/* Selftests use these tags for compatibility with test_progs. */ +#define __test_tag (tag) __attribute__((btf_decl_tag("comment:" XSTR(__COUNTER__) ":" tag))) +#define __stderr (msg) __test_tag("test_expect_stderr=" msg) +#define __stderr_unpriv (msg) __test_tag("test_expect_stderr_unpriv=" msg) + +#define XSTR (s) STR(s) +#define STR (s) #s + +#endif
tools/testing/selftests/bpf/prog_tests/libarena_asan.c +2 -0
@@ -25,6 +25,8 @@ static void run_libarena_asan_test(struct libarena_asan *skel, ret =libarena_run_prog (bpf_program__fd (prog));ASSERT_OK (ret, name); + +verify_test_stderr (skel->obj, prog); }static void run_test (void )
tools/testing/selftests/bpf/test_loader.c +39 -12
69 lines not on this page · raw message
tools/testing/selftests/bpf/test_progs.h +2 -0
@@ -563,5 +563,7 @@ struct expected_msgs {void validate_msgs (const char *log_buf,struct expected_msgs *msgs,void (*emit_fn)(const char *buf,bool force)); +void free_msgs (struct expected_msgs *msgs); +void verify_test_stderr (struct bpf_object *obj,struct bpf_program *prog);#endif /* __TEST_PROGS_H */
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH bpf-next v9 8/8] selftests/bpf: Reuse stderr parsing for libarena ASAN tests
The verify_test_stderr() function hardcodes the use of &spec.priv.stderr. Since it lacks an unprivileged parameter to select the unprivileged spec, any expected messages specified via…
Quoted 4 lines
tools/testing/selftests/bpf/test_loader.c +0
-0
[ ... ]
Quoted 31 lines
tools/testing/selftests/bpf/test_loader.c +27
-0@@ -789,6 +789,43 @@ static void emit_stderr(const char *stderr, bool force)fprintf (stdout,"STDERR:\n=============\n%s=============\n" , stderr); } +static void verify_stderr (int prog_fd,struct expected_msgs *msgs) +{ +LIBBPF_OPTS (bpf_prog_stream_read_opts, ropts); +char *buf; +int ret; + +if (!msgs->cnt) +return ; + + buf =malloc (TEST_LOADER_LOG_BUF_SZ ); +if (!ASSERT_OK_PTR (buf,"malloc" )) +return ; + + ret =bpf_prog_stream_read (prog_fd,2 , buf,TEST_LOADER_LOG_BUF_SZ -1 , + &ropts); +if (ret >0 ) { + buf[ret] ='\0' ; +emit_stderr (buf, false); +validate_msgs (buf, msgs, emit_stderr); + }else { +ASSERT_GT (ret,0 ,"stderr stream read" ); + } + +free (buf); +} + +void verify_test_stderr (struct bpf_object *obj,struct bpf_program *prog)
tools/testing/selftests/bpf/test_loader.c static void emit_stderr(const char *stderr, bool force) · line 828
Quoted 10 lines
tools/testing/selftests/bpf/test_loader.c +10
-0+{ +struct test_spec spec = {}; + +if (parse_test_spec (NULL , obj, prog, &spec)) +return ; + +verify_stderr (bpf_program__fd (prog), &spec.priv.stderr); +free_test_spec (&spec); +} +
The verify_test_stderr() function hardcodes the use of &spec.priv.stderr. Since it lacks an unprivileged parameter to select the unprivileged spec, any expected messages specified via __stderr_unpriv() might be silently ignored.
While this doesn't affect current libarena tests (which don't run in unprivileged mode), it creates an API inconsistency. The function defines __stderr_unpriv macro in test_progs_compat.h but doesn't actually verify those expectations.
This concern was previously raised in v8 by Sashiko AI:
https://lore.kernel.org/bpf/[email protected]
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/24964771851
[email protected]
AI reviewRe: [PATCH bpf-next v9 8/8] selftests/bpf: Reuse stderr parsing for libarena ASAN tests
In reply to Emil TsalapatisSashiko AI review found 2 potential issue(s): - [Low] Unnecessary export of `free_msgs` to the global namespace. - [Low] Use of a magic number for the BPF stream ID. --
Sashiko AI review found 2 potential issue(s):
- [Low] Unnecessary export of free_msgs to the global namespace.
- [Low] Use of a magic number for the BPF stream ID.
--
commit 49cffc0bea9678ea2577c634e093c46121bf87fd
Author: Emil Tsalapatis <[email protected]>
selftests/bpf: Reuse stderr parsing for libarena ASAN tests
This commit adds code to directly test the output of libarena ASAN tests. It reuses testing infrastructure originally for BPF streams to verify that ASAN emits call stacks when memory errors occur.
tools/testing/selftests/bpf/test_loader.c void test_loader_fini(struct test_loader *tester) · line 96
Quoted 10 lines
tools/testing/selftests/bpf/test_loader.c +1
-1@@ -93,7 +93,7 @@ void test_loader_fini(struct test_loader *tester)free (tester->log_buf); } -static void free_msgs (struct expected_msgs *msgs) +void free_msgs (struct expected_msgs *msgs)
Are there any callers outside of test_loader.c that need this function?
It appears the newly added verify_test_stderr() encapsulates the cleanup internally by calling free_test_spec(), leaving free_msgs() without any external callers. Could this function remain static to avoid unnecessary namespace pollution?
[ ... ]
Quoted 9 lines
tools/testing/selftests/bpf/test_loader.c +5
-0@@ -789,6 +789,43 @@ static void emit_stderr(const char *stderr, bool force)fprintf (stdout,"STDERR:\n=============\n%s=============\n" , stderr); } +static void verify_stderr (int prog_fd,struct expected_msgs *msgs) +{ +LIBBPF_OPTS (bpf_prog_stream_read_opts, ropts); +char *buf; +int ret;
tools/testing/selftests/bpf/test_loader.c static void emit_stderr(const char *stderr, bool force) · line 806
Quoted 10 lines
tools/testing/selftests/bpf/test_loader.c +10
-0+ +if (!msgs->cnt) +return ; + + buf =malloc (TEST_LOADER_LOG_BUF_SZ ); +if (!ASSERT_OK_PTR (buf,"malloc" )) +return ; + + ret =bpf_prog_stream_read (prog_fd,2 , buf,TEST_LOADER_LOG_BUF_SZ -1 , + &ropts);
Would it be better to use the BPF_STREAM_STDERR macro here instead of hardcoding the value 2?
Using the macro defined in include/uapi/linux/bpf.h might improve readability and stay consistent with other stream testing code.
[ ... ]
tools/testing/selftests/bpf/test_progs.h struct expected_msgs { · line 566
Quoted 9 lines
tools/testing/selftests/bpf/test_progs.h +1
-0@@ -563,5 +563,7 @@ struct expected_msgs {void validate_msgs (const char *log_buf,struct expected_msgs *msgs,void (*emit_fn)(const char *buf,bool force)); +void free_msgs (struct expected_msgs *msgs);
If free_msgs() can remain static, should this declaration be removed?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 8 lines · On Sun, 26 Apr 2026 15:03:30 -0400 you wrote:
Add a new subdirectory to
tools/testing/selftests/bpfcalled libarena, along with programs useful for writing arena-based BPF code. This patchset adds the following:1) libarena, a subdirectory where arena BPF code that is generally useful to BPF arena programs can be easily added and tested.
[...]
Here is the summary with links:
- [bpf-next,v9,1/8] selftests/bpf: Add ifdef guard for WRITE_ONCE macro in bpf_atomic.h
https://git.kernel.org/bpf/bpf-next/c/1fb8e9b32e19 - [bpf-next,v9,2/8] selftests/bpf: Add basic libarena scaffolding https://git.kernel.org/bpf/bpf-next/c/d5327480a12a - [bpf-next,v9,3/8] selftests/bpf: Move arena-related headers into libarena https://git.kernel.org/bpf/bpf-next/c/8c1e1c33fe5a - [bpf-next,v9,4/8] selftests/bpf: Add arena ASAN runtime to libarena https://git.kernel.org/bpf/bpf-next/c/9ab78691eb5f - [bpf-next,v9,5/8] selftests/bpf: Add ASAN support for libarena selftests https://git.kernel.org/bpf/bpf-next/c/cfc00618b9df - [bpf-next,v9,6/8] selftests/bpf: Add buddy allocator for libarena https://git.kernel.org/bpf/bpf-next/c/86426a28c52d - [bpf-next,v9,7/8] selftests/bpf: Add selftests for libarena buddy allocator https://git.kernel.org/bpf/bpf-next/c/b1487dc1b181 - [bpf-next,v9,8/8] selftests/bpf: Reuse stderr parsing for libarena ASAN tests https://git.kernel.org/bpf/bpf-next/c/554e4eb9e4b7
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html