mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf v3 0/2] bpf, arm64: fix the exception callback's frame pointer
@ 2026-09-07 13:06 Donggeun Yoo
  2026-09-07 13:06 ` [PATCH bpf v3 1/2] bpf, arm64: set up the frame pointer for the exception callback Donggeun Yoo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Donggeun Yoo @ 2026-09-07 13:06 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Catalin Marinas,
	Daniel Borkmann, Eduard Zingerman, Emil Tsalapatis,
	Ihor Solodrai, Jiri Olsa, Kumar Kartikeya Dwivedi, Mark Rutland,
	Martin KaFai Lau, Puranjay Mohan, Shuah Khan, Song Liu,
	Will Deacon, Xu Kuohai, Yonghong Song
  Cc: bpf, linux-arm-kernel, linux-kernel, linux-kselftest, donggeunyoo.kernel

The arm64 JIT does not set BPF_REG_FP in the prologue of an exception
callback, so the callback runs with whatever x25 held when bpf_throw()
was called. A callback that materializes the register, for instance to
pass the address of a local variable to a helper, then works on the
frame of the subprogram that threw.

Patch 1 sets ctx->fp_used on that path, the same fix commit b114fcee766d
("bpf, arm64: Fix fp initialization for exception boundary") made for
the exception boundary. Patch 2 adds a selftest that reaches the case.

Tested on aarch64 under QEMU with vmtest.sh, on the base below. Without
patch 1 the new test panics the kernel, because the address handed to
the helper lands on the helper's own saved return address:

  pc : 0x1234
  lr : 0x1234
  Call trace:
   0x1234 (P)
   bpf_test_run+0x188/0x3e0
   bpf_prog_test_run_skb+0x47c/0x998
   __sys_bpf+0xbdc/0xdd8
  Kernel panic - not syncing: Oops: Fatal exception in interrupt

0x1234 is the value the callback reads, so the helper wrote it over its
own return address. With patch 1 applied the whole group passes:

  #117/11  exceptions/exception_throw_subprog_stack_cb:OK
  #117     exceptions:OK
  Summary: 1/118 PASSED, 0 SKIPPED, 0/0 FAILED

Not tested on other architectures.

v1: https://lore.kernel.org/bpf/20260904070210.4163193-1-donggeunyoo.kernel@gmail.com/
v2: https://lore.kernel.org/bpf/20260907054235.473103-1-donggeunyoo.kernel@gmail.com/

v2 -> v3:
 - patch 2: use the standard multi-line comment style
 - patch 1: no change, added the Acked-by

Nothing compiled changed, so the numbers above are still v2's.

v1 -> v2:
 - rebase onto bpf/master; CI could not apply v1
 - spell the three new declarations u64 rather than __u64, to match the
   rest of progs/exceptions.c
 - no change to patch 1

Donggeun Yoo (2):
  bpf, arm64: set up the frame pointer for the exception callback
  selftests/bpf: cover the exception callback using its own BPF stack

 arch/arm64/net/bpf_jit_comp.c                 |  2 ++
 .../selftests/bpf/prog_tests/exceptions.c     |  1 +
 .../testing/selftests/bpf/progs/exceptions.c  | 30 +++++++++++++++++++
 3 files changed, 33 insertions(+)


base-commit: df2908090cda368b01ff43709f51890076c56157
-- 
2.53.0


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

end of thread, other threads:[~2026-09-07 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-07 13:06 [PATCH bpf v3 0/2] bpf, arm64: fix the exception callback's frame pointer Donggeun Yoo
2026-09-07 13:06 ` [PATCH bpf v3 1/2] bpf, arm64: set up the frame pointer for the exception callback Donggeun Yoo
2026-09-07 13:06 ` [PATCH bpf v3 2/2] selftests/bpf: cover the exception callback using its own BPF stack Donggeun Yoo
2026-09-07 13:43 ` [PATCH bpf v3 0/2] bpf, arm64: fix the exception callback's frame pointer Donggeun Yoo

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

all inboxes | Powered by JetHome®