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().
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -562,6 +562,10 @@ static long arena_alloc_pages(struct bpf_arena *arena, long uaddr, long page_cnt · 561 unmodified lines | |||
| 562 | u32 uaddr32; | 562 | u32 uaddr32; |
| 563 | int ret, i; | 563 | int ret, i; |
| 564 | 564 | ||
| 565 | if (node_id != NUMA_NO_NODE && | ||
| 566 | ((unsigned int)node_id >= nr_node_ids || !node_online(node_id))) | ||
| 567 | return 0; | ||
| 568 | |||
| 565 | if (page_cnt > page_cnt_max) | 569 | if (page_cnt > page_cnt_max) |
| 566 | return 0; | 570 | return 0; |
| 567 | 571 | ||