public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf v4 0/2] bpf: Fix arena VMA use-after-free on fork
@ 2026-04-12  2:27 Weiming Shi
  2026-04-12  2:27 ` [PATCH bpf v4 1/2] bpf: Fix use-after-free of arena VMA " Weiming Shi
  2026-04-12  2:27 ` [PATCH bpf v4 2/2] selftests/bpf: Add test for arena VMA use-after-free " Weiming Shi
  0 siblings, 2 replies; 5+ messages in thread
From: Weiming Shi @ 2026-04-12  2:27 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, Emil Tsalapatis, 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 tracking each child VMA separately in
arena_vm_open, and adds arena_vm_may_split() to prevent VMA splitting.
Patch 2 adds a selftest that reproduces the issue (requires KASAN to
detect the UAF).

v4:
- Fixed commit message: OOM case description, may_split rationale

v3:
- Added arena_vm_may_split() to prevent VMA splitting
- Reuse remember_vma() in arena_vm_open(), removed HugeTLB references
- selftests: fixed copyright, trimmed comments, use sysconf()

v2:
- Added missing Reported-by tag

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                            | 23 ++++--
 .../selftests/bpf/prog_tests/arena_fork.c     | 80 +++++++++++++++++++
 .../testing/selftests/bpf/progs/arena_fork.c  | 41 ++++++++++
 3 files changed, 138 insertions(+), 6 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] 5+ messages in thread

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-12  2:27 [PATCH bpf v4 0/2] bpf: Fix arena VMA use-after-free on fork Weiming Shi
2026-04-12  2:27 ` [PATCH bpf v4 1/2] bpf: Fix use-after-free of arena VMA " Weiming Shi
2026-04-12 17:50   ` Emil Tsalapatis
2026-04-12 21:30     ` Alexei Starovoitov
2026-04-12  2:27 ` [PATCH bpf v4 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