bpf: Add arena ASAN runtime and BPF library
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest13 patches 4 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/13 | bpf: Add bpf_stream_print_stack stack dumping kfunckernel/ kernel/ tools/ | +16 | 0 replies | |
| 2/13 | bpf: Allow BPF stream kfuncs while holding a lockkernel/ | +12 | 0 replies | |
| 3/13 | selftests: bpf: Move bpf_arena_spin_lock.h to the top leveltools/ tools/ | +3 | 0 replies | |
| 4/13 | selftests: bpf: Make WRITE_ONCE macro in bpf_atomic.h conditionaltools/ | +2 | 0 replies | |
| 5/13 | selftests: bpf: Add basic libarena scaffoldingtools/ tools/ tools/ +4 more | +460 | 0 replies | |
| 6/13 | selftests: bpf: Add arena ASAN runtime to libarenatools/ tools/ tools/ | +597 | 1 reply | |
| 7/13 | selftests: bpf: Add ASAN support for libarena selfteststools/ tools/ tools/ +2 more | +155 | 1 reply | |
| 8/13 | selftest: bpf: Add bump allocator for libarenatools/ tools/ | +232 | 0 replies | |
| 9/13 | selftests: bpf: Add libarena selftests for the bump allocatortools/ tools/ tools/ | +480 | 1 reply | |
| 10/13 | selftest: bpf: Add libarena stack allocatortools/ tools/ | +382 | 1 reply | |
| 11/13 | selftests: bpf: Add selftests for the libarena stack allocatortools/ tools/ | +255 | 0 replies | |
| 12/13 | selftests: bpf: Add buddy allocator for libarenatools/ tools/ | +846 | 0 replies | |
| 13/13 | selftests: bpf: Add selftests for the libarena buddy allocatortools/ tools/ tools/ | +473 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 00/13] bpf: Add arena ASAN runtime and BPF library
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.
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.cSignature · 1 line
2.47.3