Skip to content

Commit 88d1d4a

Browse files
Alexei StarovoitovMartin KaFai Lau
authored andcommitted
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>
1 parent e63985e commit 88d1d4a

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

kernel/bpf/verifier.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12364,6 +12364,9 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
1236412364
meta.func_name);
1236512365
return -EFAULT;
1236612366
}
12367+
} else if (btf_type_is_void(ptr_type)) {
12368+
/* kfunc returning 'void *' is equivalent to returning scalar */
12369+
mark_reg_unknown(env, regs, BPF_REG_0);
1236712370
} else if (!__btf_type_is_struct(ptr_type)) {
1236812371
if (!meta.r0_size) {
1236912372
__u32 sz;

0 commit comments

Comments
 (0)