BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: expand BPF arena kernel fault handling
@ 2026-10-28  1:51 Emil Tsalapatis
  2026-10-28  1:51 ` [PATCH bpf 1/2] bpf: recover page faults across all arenas Emil Tsalapatis
  2026-10-28  1:51 ` [PATCH bpf 2/2] selftests/bpf: add arena fault recovery tests Emil Tsalapatis
  0 siblings, 2 replies; 9+ messages in thread
From: Emil Tsalapatis @ 2026-10-28  1:51 UTC (permalink / raw)
  To: bpf; +Cc: ast, andrii, eddyz87, memxor, daniel, Emil Tsalapatis, Tejun Heo

Currently, the BPF arena fault handler protects against
a misbehaving BPF program passing an arena pointer to a
kfunc then unmapping the backing pages, causing a kernel
fault. However, it does not handle errors where the now
unmapped arena address is instead accessed by a non-BPF
path, or by a BPF program that has a different arena.
The former case is already possible in sched-ext if a
BPF program removes from the arena pages allocated
from the genpool allocator.

Keep a list of all arenas in the system and attempt to match
the kernel fault to all of them. If the fault does fall in
an arena, handle it with the already established scratch
page technique and retry the access.

Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>

Emil Tsalapatis (2):
  bpf: recover page faults across all arenas
  selftests/bpf: add arena fault recovery tests

 kernel/bpf/arena.c                            | 54 +++++++----
 tools/testing/selftests/bpf/Makefile          |  2 +-
 .../selftests/bpf/prog_tests/arena_fault.c    | 91 +++++++++++++++++++
 .../testing/selftests/bpf/progs/arena_fault.c | 55 +++++++++++
 .../selftests/bpf/progs/arena_fault_noarena.c | 17 ++++
 .../testing/selftests/bpf/test_kmods/Makefile |  2 +-
 .../bpf/test_kmods/bpf_test_arena_fault.c     | 55 +++++++++++
 .../bpf/test_kmods/bpf_test_arena_fault.h     | 10 ++
 8 files changed, 265 insertions(+), 21 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/arena_fault.c
 create mode 100644 tools/testing/selftests/bpf/progs/arena_fault.c
 create mode 100644 tools/testing/selftests/bpf/progs/arena_fault_noarena.c
 create mode 100644 tools/testing/selftests/bpf/test_kmods/bpf_test_arena_fault.c
 create mode 100644 tools/testing/selftests/bpf/test_kmods/bpf_test_arena_fault.h

-- 
2.54.0


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

end of thread, other threads:[~2026-11-03  1:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-28  1:51 [PATCH bpf-next 0/2] bpf: expand BPF arena kernel fault handling Emil Tsalapatis
2026-10-28  1:51 ` [PATCH bpf 1/2] bpf: recover page faults across all arenas Emil Tsalapatis
2026-10-28  2:36   ` bot+bpf-ci
2026-11-02 22:58   ` Alexei Starovoitov
2026-11-02 23:35     ` Kumar Kartikeya Dwivedi
2026-11-03  1:47       ` Alexei Starovoitov
2026-10-28  1:51 ` [PATCH bpf 2/2] selftests/bpf: add arena fault recovery tests Emil Tsalapatis
2026-10-28  2:13   ` sashiko-bot
2026-11-02 22:59   ` Alexei Starovoitov

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