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 <[email protected]> Acked-by: Kumar Kartikeya Dwivedi <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin KaFai Lau <[email protected]>
1 parent e63985e commit 88d1d4a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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)