Re: [PATCH bpf-next v4 3/6] mm: introduce bpf_get_root_mem_cgroup() BPF kfunc
From: Alexei Starovoitov
Date: Mon Jan 05 2026 - 11:21:33 EST
On Sun, Jan 4, 2026 at 11:49 PM Matt Bobrowski <mattbobrowski@xxxxxxxxxx> wrote:
>
> >
> > No need for a new KF flag. Any struct returned by kfunc should be
> > trusted or trusted_or_null if KF_RET_NULL was specified.
> > I don't remember off the top of my head, but this behavior
> > is already implemented or we discussed making it this way.
>
> Hm, I do not see any evidence of this kind of semantic currently
> implemented, so perhaps it was only discussed at some point. Would you
> like me to put forward a patch that introduces this kind of implicit
> trust semantic for BPF kfuncs returning pointer to struct types?
Hmm. What about these:
BTF_ID_FLAGS(func, scx_bpf_cpu_rq)
BTF_ID_FLAGS(func, scx_bpf_locked_rq, KF_RET_NULL)
BTF_ID_FLAGS(func, scx_bpf_cpu_curr, KF_RET_NULL | KF_RCU_PROTECTED)
I thought they're returning a trusted pointer without acquiring it.
iirc the last one returns trusted in RCU CS,
but the first two return just a legacy ptr_to_btf_id ?
This is something to fix asap then.