linux/arch/arm64
Donggeun Yoo ef1fb82f12 bpf, arm64: set up the frame pointer for the exception callback
A program acting as exception boundary saves all callee-saved registers,
so build_prologue() takes the exception_cb path and never calls
push_callee_regs(). That is the only place find_used_callee_regs() runs,
and with it the only place ctx->fp_used is set, so the callback prologue
does not emit the

  mov x25, sp

that points BPF_REG_FP at the frame the callback runs on. x25 keeps
whatever it held when bpf_throw() was called. If the throw came from a
subprogram that uses its own BPF stack, that is the subprogram's frame
pointer, and since the subprogram never returns it never restores x25
either.

Stack accesses through BPF_REG_FP are rewritten to be stack pointer
relative, so those still land in the callback's own frame. Materializing
the register does not: a callback that passes the address of a local
variable to a helper hands over an address in the dead subprogram's
frame. That address is below the callback's stack pointer by then, and
the helper's own call chain covers it, so the helper can write over its
own return address. 0x1234 below is the value the helper was asked to
store:

  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

Set ctx->fp_used on the exception callback path so that the existing code
further down sets x25 from the stack pointer. The epilogue restores it
from the main program's save area along with the other callee-saved
registers, as it already does. x86 sets the frame pointer for the
callback from the argument it is passed, and powerpc computes it from
the stack pointer.

Fixes: 5d4fa9ec56 ("bpf, arm64: Avoid blindly saving/restoring all callee-saved registers")
Acked-by: Xu Kuohai <xukuohai@huawei.com>
Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Link: https://lore.kernel.org/r/20260907130624.611942-2-donggeunyoo.kernel@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2026-09-13 21:59:21 -07:00
..
boot Mostly the usual clk driver updates and new SoC additions plus non-critical 2026-08-26 11:14:30 -07:00
configs This update includes the following changes: 2026-08-19 17:25:42 -07:00
crypto treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
hyperv
include arm64: Don't read GMID_EL1 when MTE is disabled 2026-09-03 13:03:23 +00:00
kernel arm64: Don't read GMID_EL1 when MTE is disabled 2026-09-03 13:03:23 +00:00
kvm treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
lib Major changes: 2026-08-20 07:36:20 -07:00
mm arm64: mm: Fix the lockless page-table walk in show_pte() 2026-09-03 12:58:12 +00:00
net bpf, arm64: set up the frame pointer for the exception callback 2026-09-13 21:59:21 -07:00
tools Arm: 2026-08-25 11:48:04 -07:00
xen
Kbuild
Kconfig pci-v7.3-changes 2026-08-23 12:44:10 -07:00
Kconfig.debug
Kconfig.platforms soc: arm code changes for 7.2 2026-06-17 11:28:10 -07:00
Makefile rust: arm64: set uwtable llvm module flag for CONFIG_UNWIND_TABLES 2026-05-30 09:25:22 +02:00