[PATCH bpf] bpf, arm64: Fix stack frame construction for struct_ops trampoline
Puranjay Mohan
puranjay at kernel.org
Mon Oct 21 01:44:59 PDT 2024
Xu Kuohai <xukuohai at huaweicloud.com> writes:
> From: Xu Kuohai <xukuohai at huawei.com>
>
> The callsite layout for arm64 fentry is:
>
> mov x9, lr
> nop
>
> When a bpf prog is attached, the nop instruction is patched to a call
> to bpf trampoline:
>
> mov x9, lr
> bl <bpf trampoline>
>
> This passes two return addresses to bpf trampoline: the return address
> for the traced function/prog, stored in x9, and the return address for
> the bpf trampoline, stored in lr. To ensure stacktrace works properly,
> the bpf trampoline constructs two fake function stack frames using x9
> and lr.
>
> However, struct_ops progs are used as function callbacks and are invoked
> directly, without x9 being set as the fentry callsite does. Therefore,
> only one stack frame should be constructed using lr for struct_ops.
>
> Fixes: efc9909fdce0 ("bpf, arm64: Add bpf trampoline for arm64")
> Signed-off-by: Xu Kuohai <xukuohai at huawei.com>
Acked-by: Puranjay Mohan <puranjay at kernel.org>
> ---
> arch/arm64/net/bpf_jit_comp.c | 47 +++++++++++++++++++++++------------
> 1 file changed, 31 insertions(+), 16 deletions(-)
>
[...]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 255 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20241021/3ecda3d7/attachment.sig>
More information about the linux-arm-kernel
mailing list