Re: [PATCH bpf-next v10 3/4] bpf: Add kfunc bpf_rcu_read_lock/unlock()

Alexei Starovoitov
2022-11-24T20:56:54Z

On Thu, Nov 24, 2022 at 12:34 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Wed, Nov 23, 2022 at 9:32 PM Yonghong Song <yhs@fb.com> wrote:
> >
> > @@ -16580,6 +16682,8 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr)
> > env->bypass_spec_v1 = bpf_bypass_spec_v1();
> > env->bypass_spec_v4 = bpf_bypass_spec_v4();
> > env->bpf_capable = bpf_capable();
> > + env->rcu_tag_supported =
> > + btf_find_by_name_kind(btf_vmlinux, "rcu", BTF_KIND_TYPE_TAG) > 0;
>
> It needs btf_vmlinux != NULL check as well,
> since we error earlier only on IS_ERR(btf_vmlinux).
> btf_vmlinux can be NULL at this point when CONFIG_DEBUG_INFO_BTF is not set.
>
> In the previous discussion I thought we agreed to
> fix convert_ctx_accesses() vs incorrect application of
> BPF_PROBE_MEM for PTR_TRUSTED pointers.
> But I didn't find it in this patch.
> So I'm fixing both issues and planning to apply after testing.

Turned out the initial PTR_TRUSTED patch was buggy.
prog_type_args_trusted() is incorrect.
It marks fentry/fexit pointers as trusted and our own selftest
is crashing.
I'll send a separate fix.

So going to apply rcu set with just btf_vmlinux fix.