s390/bpf: Fix indirect trampoline generation
Subsystems (5)
PATCH 1/1 s390/bpf: Fix indirect trampoline generation
From: Alexei Starovoitov <[email protected]>
The func_addr used to be NULL for indirect trampolines used by struct_ops. Now func_addr is a valid function pointer.
Hence use BPF_TRAMP_F_INDIRECT flag to detect such condition.
--- arch/s390/net/bpf_jit_comp.c | 3 ++- tools/testing/selftests/bpf/DENYLIST.s390x | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-)
arch/s390/net/bpf_jit_comp.c +2 -1
@@ -2362,7 +2362,8 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,return -ENOTSUPP ;/* Return to %r14, since func_addr and %r0 are not available. */ -if (!func_addr && !(flags &BPF_TRAMP_F_ORIG_STACK )) +if ((!func_addr && !(flags &BPF_TRAMP_F_ORIG_STACK )) || + (flags &BPF_TRAMP_F_INDIRECT )) flags |=BPF_TRAMP_F_SKIP_FRAME ;/*
tools/testing/selftests/bpf/DENYLIST.s390x +0 -2
@@ -1,7 +1,5 @@ # TEMPORARY # Alphabetical order -dummy_st_ops/dummy_init_ret_value -dummy_st_ops/dummy_init_ptr_arg exceptions # JIT does not support calling kfunc bpf_throw (exceptions) get_stack_raw_tp # user_stack corrupted user stack (no backchain userspace) stacktrace_build_id # compare_map_keys stackid_hmap vs. stackmap err -2 errno 2 (?)
Signature · 1 line
2.34.1
Quoted 6 lines · Alexei Starovoitov
From: Alexei Starovoitov <[email protected]>
The
func_addrused to be NULL for indirect trampolines used bystruct_ops. Nowfunc_addris a valid function pointer.
Hence useBPF_TRAMP_F_INDIRECTflag to detect such condition.
Quoted 6 lines
Fixes 2cd3e3772e41 ("x86/cfi,bpf: Fix bpf_struct_ops CFI")Signed-off-by Alexei Starovoitov <[email protected]>--- arch/s390/net/bpf_jit_comp.c | 3 ++- tools/testing/selftests/bpf/DENYLIST.s390x | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-)
IIUC F_INDIRECT trampolines are called via C function pointers, and func_addr does not participate in any call chains, but is rather used as a source of CFI information. So returning to %r14 is the right thing to do.
Thanks!
Quoted 15 lines · Ilya Leoshkevich
Quoted 6 lines · Alexei Starovoitov
From: Alexei Starovoitov <[email protected]>
The
func_addrused to be NULL for indirect trampolines used bystruct_ops. Nowfunc_addris a valid function pointer.
Hence useBPF_TRAMP_F_INDIRECTflag to detect such condition.Quoted 6 lines
Fixes 2cd3e3772e41 ("x86/cfi,bpf: Fix bpf_struct_ops CFI")Signed-off-by Alexei Starovoitov <[email protected]>--- arch/s390/net/bpf_jit_comp.c | 3 ++- tools/testing/selftests/bpf/DENYLIST.s390x | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-)
Quoted 3 lines
IIUC
F_INDIRECTtrampolines are called via C function pointers, andfunc_addrdoes not participate in any call chains, but is rather used as a source of CFI information.
Yes.
Quoted 6 lines
So returning to %r14 is the right
thing to do.Thanks!
Reviewed-by Ilya Leoshkevich <[email protected]>
Thank you for the quick review.
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Quoted 10 lines · On Fri, 15 Dec 2023 16:45:49 -0800 you wrote:
From: Alexei Starovoitov <[email protected]>
The
func_addrused to be NULL for indirect trampolines used bystruct_ops. Nowfunc_addris a valid function pointer.
Hence useBPF_TRAMP_F_INDIRECTflag to detect such condition.Fixes 2cd3e3772e41 ("x86/cfi,bpf: Fix bpf_struct_ops CFI")Signed-off-by Alexei Starovoitov <[email protected]>[...]
Here is the summary with links:
- [bpf-next] s390/bpf: Fix indirect trampoline generation
https://git.kernel.org/bpf/bpf-next/c/0c970ed2f87c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html