bpf/arena: Add kfunc for reserving arena memory
Emil Tsalapatis
reviewerv3 cover bpf/arena: Add kfunc for reserving arena memory
Add a new kfunc for BPF arenas that reserves a region of the mapping to prevent it from being mapped. These regions serve as guards against out-of-bounds accesses and are useful for debugging arena-related code.
CHANGELOG
=========
Quoted 1 line
From v2 ([email protected])
------------------------------------------------------
- Removed -EALREADY and replaced with -EINVAL to bring error handling in line with the rest of the BPF code (Alexei).
Quoted 1 line
From v1 ([email protected])
------------------------------------------------------
- Removed the additional guard range tree. Adjusted tests accordingly. Reserved regions now behave like allocated regions, and can be unreserved using bpf_arena_free_pages(). They can also be allocated from userspace through minor faults. It is up to the user to prevent erroneous frees and/or use the BPF_F_SEGV_ON_FAULT flag to catch stray userspace accesses (Alexei).
- Changed terminology from guard pages to reserved pages (Alexei, Kartikeya).
Emil Tsalapatis (2):
bpf/arena: add bpf_arena_reserve_pages kfunc selftests/bpf: add selftests for bpf_arena_reserve_pages
kernel/bpf/arena.c | 43 +++++++ .../testing/selftests/bpf/bpf_arena_common.h | 3 + .../selftests/bpf/progs/verifier_arena.c | 106 ++++++++++++++++++ .../bpf/progs/verifier_arena_large.c | 95 ++++++++++++++++ 4 files changed, 247 insertions(+)
Signature · 1 line
2.49.0