Thread (5 messages) 5 messages, 5 authors, 2025-09-25

Re: [PATCH] tracing: Fix the bug where bpf_get_stackid returns -EFAULT on the ARM64

From: Will Deacon <will@kernel.org>
Date: 2025-09-25 15:32:14
Also in: bpf, linux-arm-kernel, lkml

On Thu, 25 Sep 2025 10:08:22 +0800, Feng Yang wrote:
When using bpf_program__attach_kprobe_multi_opts on ARM64 to hook a BPF program
that contains the bpf_get_stackid function, the BPF program fails
to obtain the stack trace and returns -EFAULT.

This is because ftrace_partial_regs omits the configuration of the pstate register,
leaving pstate at the default value of 0. When get_perf_callchain executes,
it uses user_mode(regs) to determine whether it is in kernel mode.
This leads to a misjudgment that the code is in user mode,
so perf_callchain_kernel is not executed and the function returns directly.
As a result, trace->nr becomes 0, and finally -EFAULT is returned.

[...]
Applied to arm64 (for-next/core), thanks!

[1/1] tracing: Fix the bug where bpf_get_stackid returns -EFAULT on the ARM64
      https://git.kernel.org/arm64/c/fd2f74f8f3d3

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help