summaryrefslogtreecommitdiffstats
path: root/kernel/bpf
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2024-03-06 19:12:23 -0800
committerMartin KaFai Lau <martin.lau@kernel.org>2024-03-07 14:58:48 -0800
commit88d1d4a7eebea2836859246d91fe9d141789dfc3 (patch)
tree265870b328e4ba8fd92373cca74fb1f12b849c84 /kernel/bpf
parente63985ecd22681c7f5975f2e8637187a326b6791 (diff)
downloadlinux-88d1d4a7eebea2836859246d91fe9d141789dfc3.tar.gz
linux-88d1d4a7eebea2836859246d91fe9d141789dfc3.tar.bz2
linux-88d1d4a7eebea2836859246d91fe9d141789dfc3.zip
bpf: Allow kfuncs return 'void *'
Recognize return of 'void *' from kfunc as returning unknown scalar. Acked-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/r/20240307031228.42896-2-alexei.starovoitov@gmail.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Diffstat (limited to 'kernel/bpf')
-rw-r--r--kernel/bpf/verifier.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index ee86e4d7d5fc..9c2a36b1373b 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -12364,6 +12364,9 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
meta.func_name);
return -EFAULT;
}
+ } else if (btf_type_is_void(ptr_type)) {
+ /* kfunc returning 'void *' is equivalent to returning scalar */
+ mark_reg_unknown(env, regs, BPF_REG_0);
} else if (!__btf_type_is_struct(ptr_type)) {
if (!meta.r0_size) {
__u32 sz;