From: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
To: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Mark Rutland <mark.rutland@arm.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Puranjay Mohan <puranjay@kernel.org>,
Shuah Khan <shuah@kernel.org>, Song Liu <song@kernel.org>,
Will Deacon <will@kernel.org>,
Xu Kuohai <xukuohai@huaweicloud.com>,
Yonghong Song <yonghong.song@linux.dev>
Cc: bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
Xu Kuohai <xukuohai@huawei.com>,
Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Subject: [PATCH bpf 0/2] bpf, arm64: fix the exception callback's frame pointer
Date: Fri, 4 Sep 2026 16:02:08 +0900 [thread overview]
Message-ID: <20260904070210.4163193-1-donggeunyoo.kernel@gmail.com> (raw)
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. 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
With patch 1 applied the whole group passes:
#116/11 exceptions/exception_throw_subprog_stack_cb:OK
#116 exceptions:OK
Summary: 1/118 PASSED, 0 SKIPPED, 0/0 FAILED
Not tested on other architectures.
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 | 29 +++++++++++++++++++
3 files changed, 32 insertions(+)
--
2.53.0
next reply other threads:[~2026-09-04 7:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 7:02 Donggeun Yoo [this message]
2026-09-04 7:02 ` [PATCH bpf 1/2] bpf, arm64: set up the frame pointer for the exception callback Donggeun Yoo
2026-09-04 7:02 ` [PATCH bpf 2/2] selftests/bpf: cover the exception callback using its own BPF stack Donggeun Yoo
2026-09-04 8:09 ` bot+bpf-ci
2026-09-04 9:27 ` Donggeun Yoo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260904070210.4163193-1-donggeunyoo.kernel@gmail.com \
--to=donggeunyoo.kernel@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=catalin.marinas@arm.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=puranjay@kernel.org \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=will@kernel.org \
--cc=xukuohai@huawei.com \
--cc=xukuohai@huaweicloud.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox