public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf 0/2] bpf: Fix arena VMA use-after-free on fork
@ 2026-04-11 11:20 Weiming Shi
  2026-04-11 11:20 ` [PATCH bpf 1/2] bpf: Fix use-after-free of arena VMA " Weiming Shi
  2026-04-11 11:20 ` [PATCH bpf 2/2] selftests/bpf: Add test for arena VMA use-after-free " Weiming Shi
  0 siblings, 2 replies; 3+ messages in thread
From: Weiming Shi @ 2026-04-11 11:20 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Barret Rhoden, bpf, linux-kernel, Xiang Mei, Weiming Shi

arena_vm_open() only increments a refcount on the shared vma_list entry
but never registers the new VMA. After fork + parent munmap, vml->vma
becomes a dangling pointer. bpf_arena_free_pages -> zap_pages then
dereferences it, causing a slab-use-after-free in zap_page_range_single.

Patch 1 fixes the bug by giving each VMA its own vma_list entry,
following the HugeTLB vma_lock pattern (hugetlb_vm_op_open).
Patch 2 adds a selftest that reproduces the issue.

Weiming Shi (2):
  bpf: Fix use-after-free of arena VMA on fork
  selftests/bpf: Add test for arena VMA use-after-free on fork

 kernel/bpf/arena.c                            | 26 ++++--
 .../selftests/bpf/prog_tests/arena_fork.c     | 86 +++++++++++++++++++
 .../testing/selftests/bpf/progs/arena_fork.c  | 41 +++++++++
 3 files changed, 148 insertions(+), 5 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/arena_fork.c
 create mode 100644 tools/testing/selftests/bpf/progs/arena_fork.c

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-11 11:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-11 11:20 [PATCH bpf 0/2] bpf: Fix arena VMA use-after-free on fork Weiming Shi
2026-04-11 11:20 ` [PATCH bpf 1/2] bpf: Fix use-after-free of arena VMA " Weiming Shi
2026-04-11 11:20 ` [PATCH bpf 2/2] selftests/bpf: Add test for arena VMA use-after-free " Weiming Shi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox