public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/13] bpf: Add arena ASAN runtime and BPF library
@ 2026-01-22 16:01 Emil Tsalapatis
  2026-01-22 16:01 ` [PATCH 01/13] bpf: Add bpf_stream_print_stack stack dumping kfunc Emil Tsalapatis
                   ` (12 more replies)
  0 siblings, 13 replies; 22+ messages in thread
From: Emil Tsalapatis @ 2026-01-22 16:01 UTC (permalink / raw)
  To: bpf
  Cc: ast, andrii, eddyz87, daniel, memxor, puranjay, song,
	Emil Tsalapatis, Emil Tsalapatis (Meta)

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 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 set of memory allocators that can be reused by BPF programs to handle 
memory allocation/deletion. The allocators use 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 structure of this patch is:

1-2: Add BPF Streams kfunc for dumping the current program stack, and
allow BPF Streams kfuncs to be callable while holding a lock.

3-4: Minor changes to the /testing/selftests/bpf directory headers to
prepare for the introduction of libarena.

5-7: Add the base libarena directory and testing scaffolding, and
introduce the ASAN runtime.

8-9: Add a arena memory bump allocator along with testing. This
allocator is used for permanent allocations during program init.

10-11: Add a stack page-oriented allocator along with testing. This 
allocator is used for repeated large allocations to avoid constant
bpf_arena_{alloc,free}_pages calls.

12-13: Add a buddy allocator along with testing. The allocator acts as a
general allocator for arena-based BPF programs.

Signed-off-by: Emil Tsalapatis (Meta) <emil@etsalapatis.com>

Emil Tsalapatis (13):
  bpf: Add bpf_stream_print_stack stack dumping kfunc
  bpf: Allow BPF stream kfuncs while holding a lock
  selftests: bpf: Move bpf_arena_spin_lock.h to the top level
  selftests: bpf: Make WRITE_ONCE macro in bpf_atomic.h conditional
  selftests: bpf: Add basic libarena scaffolding
  selftests: bpf: Add arena ASAN runtime to libarena
  selftests: bpf: Add ASAN support for libarena selftests
  selftest: bpf: Add bump allocator for libarena
  selftests: bpf: Add libarena selftests for the bump allocator
  selftest: bpf: Add libarena stack allocator
  selftests: bpf: Add selftests for the libarena stack allocator
  selftests: bpf: Add buddy allocator for libarena
  selftests: bpf: Add selftests for the libarena buddy allocator

 kernel/bpf/helpers.c                          |   1 +
 kernel/bpf/stream.c                           |  13 +
 kernel/bpf/verifier.c                         |  13 +-
 tools/lib/bpf/bpf_helpers.h                   |   2 +
 tools/testing/selftests/bpf/.gitignore        |   2 +
 tools/testing/selftests/bpf/Makefile          |  24 +
 .../bpf/{progs => }/bpf_arena_spin_lock.h     |   4 +-
 tools/testing/selftests/bpf/bpf_atomic.h      |   2 +
 tools/testing/selftests/bpf/libarena/Makefile |  69 ++
 .../selftests/bpf/libarena/include/asan.h     | 133 +++
 .../selftests/bpf/libarena/include/buddy.h    |  62 ++
 .../selftests/bpf/libarena/include/bump.h     |  20 +
 .../selftests/bpf/libarena/include/common.h   | 118 +++
 .../selftests/bpf/libarena/include/stack.h    |  44 +
 .../selftests/bpf/libarena/include/userapi.h  |  23 +
 .../bpf/libarena/selftests/selftest.c         | 328 ++++++++
 .../bpf/libarena/selftests/selftest.h         |  17 +
 .../libarena/selftests/st_asan_buddy.bpf.c    | 238 ++++++
 .../bpf/libarena/selftests/st_asan_bump.bpf.c | 193 +++++
 .../bpf/libarena/selftests/st_asan_common.h   |  49 ++
 .../libarena/selftests/st_asan_stack.bpf.c    | 253 ++++++
 .../bpf/libarena/selftests/st_buddy.bpf.c     | 231 ++++++
 .../bpf/libarena/selftests/st_bump.bpf.c      | 275 ++++++
 .../selftests/bpf/libarena/src/asan.bpf.c     | 463 +++++++++++
 .../selftests/bpf/libarena/src/buddy.bpf.c    | 784 ++++++++++++++++++
 .../selftests/bpf/libarena/src/bump.bpf.c     | 212 +++++
 .../selftests/bpf/libarena/src/stack.bpf.c    | 338 ++++++++
 .../selftests/bpf/progs/arena_spin_lock.c     |   2 +-
 28 files changed, 3909 insertions(+), 4 deletions(-)
 rename tools/testing/selftests/bpf/{progs => }/bpf_arena_spin_lock.h (99%)
 create mode 100644 tools/testing/selftests/bpf/libarena/Makefile
 create mode 100644 tools/testing/selftests/bpf/libarena/include/asan.h
 create mode 100644 tools/testing/selftests/bpf/libarena/include/buddy.h
 create mode 100644 tools/testing/selftests/bpf/libarena/include/bump.h
 create mode 100644 tools/testing/selftests/bpf/libarena/include/common.h
 create mode 100644 tools/testing/selftests/bpf/libarena/include/stack.h
 create mode 100644 tools/testing/selftests/bpf/libarena/include/userapi.h
 create mode 100644 tools/testing/selftests/bpf/libarena/selftests/selftest.c
 create mode 100644 tools/testing/selftests/bpf/libarena/selftests/selftest.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_bump.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_asan_stack.bpf.c
 create mode 100644 tools/testing/selftests/bpf/libarena/selftests/st_buddy.bpf.c
 create mode 100644 tools/testing/selftests/bpf/libarena/selftests/st_bump.bpf.c
 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/bump.bpf.c
 create mode 100644 tools/testing/selftests/bpf/libarena/src/stack.bpf.c

-- 
2.47.3


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2026-01-23  3:00 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22 16:01 [PATCH 00/13] bpf: Add arena ASAN runtime and BPF library Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 01/13] bpf: Add bpf_stream_print_stack stack dumping kfunc Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 02/13] bpf: Allow BPF stream kfuncs while holding a lock Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 03/13] selftests: bpf: Move bpf_arena_spin_lock.h to the top level Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 04/13] selftests: bpf: Make WRITE_ONCE macro in bpf_atomic.h conditional Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 05/13] selftests: bpf: Add basic libarena scaffolding Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 06/13] selftests: bpf: Add arena ASAN runtime to libarena Emil Tsalapatis
2026-01-22 16:58   ` bot+bpf-ci
2026-01-23  2:56     ` Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 07/13] selftests: bpf: Add ASAN support for libarena selftests Emil Tsalapatis
2026-01-22 16:58   ` bot+bpf-ci
2026-01-23  3:00     ` Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 08/13] selftest: bpf: Add bump allocator for libarena Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 09/13] selftests: bpf: Add libarena selftests for the bump allocator Emil Tsalapatis
2026-01-22 16:58   ` bot+bpf-ci
2026-01-23  2:55     ` Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 10/13] selftest: bpf: Add libarena stack allocator Emil Tsalapatis
2026-01-22 17:12   ` bot+bpf-ci
2026-01-23  2:59     ` Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 11/13] selftests: bpf: Add selftests for the " Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 12/13] selftests: bpf: Add buddy allocator for libarena Emil Tsalapatis
2026-01-22 16:01 ` [PATCH 13/13] selftests: bpf: Add selftests for the libarena buddy allocator Emil Tsalapatis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox