Skip to content

Commit 2845989

Browse files
puranjaymohanAlexei Starovoitov
authored andcommitted
bpf: Validate node_id in arena_alloc_pages()
arena_alloc_pages() accepts a plain int node_id and forwards it through the entire allocation chain without any bounds checking. Validate node_id before passing it down the allocation chain in arena_alloc_pages(). Fixes: 3174603 ("bpf: Introduce bpf_arena.") Signed-off-by: Puranjay Mohan <puranjay@kernel.org> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> Link: https://lore.kernel.org/r/20260417152135.1383754-1-puranjay@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 380044c commit 2845989

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

kernel/bpf/arena.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ static long arena_alloc_pages(struct bpf_arena *arena, long uaddr, long page_cnt
562562
u32 uaddr32;
563563
int ret, i;
564564

565+
if (node_id != NUMA_NO_NODE &&
566+
((unsigned int)node_id >= nr_node_ids || !node_online(node_id)))
567+
return 0;
568+
565569
if (page_cnt > page_cnt_max)
566570
return 0;
567571

0 commit comments

Comments
 (0)