> selftests/bpf: test arena allocation after a short mmap TL;DR: Test-only nit: the comment in arena_mmap_alloc.c claiming an offset-zero allocation can return NULL looks inaccurate, so the first allocation's result could be checked instead of ignored. > diff --git a/tools/testing/selftests/bpf/progs/arena_mmap_alloc.c b/tools/testing/selftests/bpf/progs/arena_mmap_alloc.c > new file mode 100644 > index 000000000000..3854afbebc45 > --- /dev/null > +++ b/tools/testing/selftests/bpf/progs/arena_mmap_alloc.c [ ... ] > +SEC("syscall") > +int alloc_beyond_vma(void *ctx) > +{ > + void __arena *page; > + > + /* A successful allocation at offset zero can return a NULL pointer. */ > + bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0); > + page = bpf_arena_alloc_pages(&arena, NULL, 2, NUMA_NO_NODE, 0); This isn't a bug, but is the comment about offset zero accurate? arena_alloc_pages() returns the full user address: addr = clear_lo32(arena->user_vm_start) + uaddr32; For pgoff 0 this is arena->user_vm_start, which cannot be zero since arena_map_mmap() sets it from vma->vm_start. The kfunc return is treated as an unknown scalar by the verifier and the JIT does not truncate it, so "if (!page)" is a full 64-bit compare. The offset-0-looks-like-NULL behavior seems to apply to nullable kfunc arguments (see progs/arena_kfunc.c), not to this return value. Also, prog_tests/arena_mem_usage.c asserts ASSERT_OK_PTR() on an offset-0 allocation. Could the first result be checked like the others, for example with "if (!page) return 4;", so an allocation failure here is distinguishable from a VMA-bound regression, and the comment dropped or corrected? > + if (!page) > + return 1; [ ... ] --- AI reviewed your patch. Please fix the bug or email reply why it's not a bug. See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md CI run summary: https://github.com/kernel-patches/bpf/actions/runs/45018621389