On Tue, Feb 6, 2024 at 2:04 PM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > From: Alexei Starovoitov <ast@xxxxxxxxxx> > > Recognize return of 'void *' from kfunc as returning unknown scalar. > > Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx> > --- > kernel/bpf/verifier.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c > index ddaf09db1175..d9c2dbb3939f 100644 > --- a/kernel/bpf/verifier.c > +++ b/kernel/bpf/verifier.c > @@ -12353,6 +12353,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); Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> I think we should do a similar extension when passing `void *` into global funcs. It's best to treat it as SCALAR instead of rejecting it because we can't calculate the size. Currently users in practice just have to define it as `uintptr_t` and then cast (or create static wrappers doing the casting). Anyways, my point is that it makes sense to treat `void *` as non-pointer. > } else if (!__btf_type_is_struct(ptr_type)) { > if (!meta.r0_size) { > __u32 sz; > -- > 2.34.1 >