Message ID | 20230919060258.3237176-2-song@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Commit | cf094baa3e0f19f1f80ceaf205c80402b024386c |
Delegated to: | BPF |
Headers | show |
Series | s390/bpf: Fix arch_prepare_bpf_trampoline | expand |
On Mon, 2023-09-18 at 23:02 -0700, Song Liu wrote: > arch_prepare_bpf_trampoline() for s390 currently returns 0 on > success. This > is not a problem for regular trampoline. However, struct_ops relies > on the > return value to advance "image" pointer: > > bpf_struct_ops_map_update_elem() { > ... > for_each_member(i, t, member) { > ... > err = bpf_struct_ops_prepare_trampoline(); > ... > image += err; > } > } > > When arch_prepare_bpf_trampoline returns 0 on success, all members of > the > struct_ops will point to the same trampoline (the last one). > > Fix this by returning the program size in arch_prepare_bpf_trampoline > (on > success). This is the same behavior as other architectures. > > Signed-off-by: Song Liu <song@kernel.org> > --- > arch/s390/net/bpf_jit_comp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Thanks! Fixes: 528eb2cb87bc ("s390/bpf: Implement arch_prepare_bpf_trampoline()") Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index de2fb12120d2..2861e3360aff 100644 --- a/arch/s390/net/bpf_jit_comp.c +++ b/arch/s390/net/bpf_jit_comp.c @@ -2513,7 +2513,7 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, return -E2BIG; } - return ret; + return tjit.common.prg; } bool bpf_jit_supports_subprog_tailcalls(void)
arch_prepare_bpf_trampoline() for s390 currently returns 0 on success. This is not a problem for regular trampoline. However, struct_ops relies on the return value to advance "image" pointer: bpf_struct_ops_map_update_elem() { ... for_each_member(i, t, member) { ... err = bpf_struct_ops_prepare_trampoline(); ... image += err; } } When arch_prepare_bpf_trampoline returns 0 on success, all members of the struct_ops will point to the same trampoline (the last one). Fix this by returning the program size in arch_prepare_bpf_trampoline (on success). This is the same behavior as other architectures. Signed-off-by: Song Liu <song@kernel.org> --- arch/s390/net/bpf_jit_comp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)