]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, arm64: fix stack_depth tracking in combination with tail calls
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 16 Jan 2018 02:46:08 +0000 (03:46 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 16 Jan 2018 19:29:15 +0000 (11:29 -0800)
commit9c7b0fc23923004a6d1ffbbf5dccd571d8657c55
tree03aea207e0887441cad8e42550fc6fbf3475ae8c
parenta40564118d01182c8119832fb32d76461097a204
bpf, arm64: fix stack_depth tracking in combination with tail calls

Using dynamic stack_depth tracking in arm64 JIT is currently broken in
combination with tail calls. In prologue, we cache ctx->stack_size and
adjust SP reg for setting up function call stack, and tearing it down
again in epilogue. Problem is that when doing a tail call, the cached
ctx->stack_size might not be the same.

One way to fix the problem with minimal overhead is to re-adjust SP in
emit_bpf_tail_call() and properly adjust it to the current program's
ctx->stack_size. Tested on Cavium ThunderX ARMv8.

Fixes: 84aca9be0ee7 ("bpf, arm64: take advantage of stack_depth tracking")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/arm64/net/bpf_jit_comp.c