[PATCH bpf-next v3 0/3] bpf, arena: fix range_tree consistency on allocation failure
From: chenyuan_fl
Date: Mon Aug 10 2026 - 09:52:22 EST
From: Yuan Chen <chenyuan@xxxxxxxxxx>
The arena range tree can be left inconsistent when kmalloc_nolock()
fails mid-operation. Patch 1 fixes range_tree_clear(), patch 2 fixes
range_tree_set(), patch 3 makes the arena free paths handle
range_tree_set() failures and checks the return value in
arena_alloc_pages()'"'"'s partial-allocation error path.
Changes in v3:
- Check range_tree_set() return value in arena_alloc_pages()'"'"'s error
path, which restores the unpopulated tail of a partially allocated
range (previously ignored), as pointed out in review.
Changes in v2:
- Fix multi-line comment style in patches 1 and 3 (opening /* on its
own line), as pointed out in review.
Note: arena_vm_fault()'s two recovery paths (restoring the range to the
free tree after allocation/mapping failure) also call range_tree_set()
without checking the return value; that is addressed in a separate
series.
Yuan Chen (3):
bpf, arena: fix range_tree_clear inconsistency on kmalloc_nolock
failure
bpf, arena: fix range_tree_set inconsistency on kmalloc_nolock failure
bpf, arena: check range_tree_set return in arena_free_pages and
arena_free_worker
kernel/bpf/arena.c | 22 ++++++++++++---
kernel/bpf/range_tree.c | 61 ++++++++++++++++++++++++++++++-----------
2 files changed, 63 insertions(+), 20 deletions(-)
--
2.54.0