]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Handle return value of BPF_PROG_TYPE_STRUCT_OPS prog
authorHou Tao <houtao1@huawei.com>
Tue, 14 Sep 2021 02:33:51 +0000 (10:33 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 14 Sep 2021 18:09:50 +0000 (11:09 -0700)
commitbc08514882f9a3a2bf4a5d49fd342a35c3b81c9a
tree770425a34bcd9a948033c5164e64a127e1b4a94c
parent70f4f5d676125d132af7c91d6feebd9bc9af29ae
bpf: Handle return value of BPF_PROG_TYPE_STRUCT_OPS prog

Currently if a function ptr in struct_ops has a return value, its
caller will get a random return value from it, because the return
value of related BPF_PROG_TYPE_STRUCT_OPS prog is just dropped.

So adding a new flag BPF_TRAMP_F_RET_FENTRY_RET to tell bpf trampoline
to save and return the return value of struct_ops prog if ret_size of
the function ptr is greater than 0. Also restricting the flag to be
used alone.

Fixes: 81e2adb6e6de ("bpf: Introduce BPF_MAP_TYPE_STRUCT_OPS")
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20210914023351.3664499-1-houtao1@huawei.com
arch/x86/net/bpf_jit_comp.c
include/linux/bpf.h
kernel/bpf/bpf_struct_ops.c