On Tue, 2026-05-12 at 13:59 +0800, Kaitao cheng wrote: > From: Kaitao Cheng <[email protected]> > > Add a new kfunc bpf_list_add(head, new, prev, meta, off) that > inserts 'new' after 'prev' in the BPF linked list. Both must be in > the same list; 'prev' must already be in the list. The new node must > be an owning reference (e.g. from bpf_obj_new); the kfunc consumes > that reference and the node becomes non-owning once inserted. > > We have added an additional parameter bpf_list_head *head to > bpf_list_add, as the verifier requires the head parameter to > check whether the lock is being held. > > Returns 0 on success, -EINVAL if 'prev' is not in a list or 'new' > is already in a list (or duplicate insertion). On failure, the > kernel drops the passed-in node. > > Signed-off-by: Kaitao Cheng <[email protected]> > ---
Reviewed-by: Eduard Zingerman <[email protected]> [...] > @@ -19228,8 +19231,11 @@ int bpf_fixup_kfunc_call(struct bpf_verifier_env > *env, struct bpf_insn *insn, > int struct_meta_reg = BPF_REG_3; > int node_offset_reg = BPF_REG_4; > > - /* rbtree_add has extra 'less' arg, so args-to-fixup are in > diff regs */ > - if (is_bpf_rbtree_add_kfunc(desc->func_id)) { > + /* list_add/rbtree_add have an extra arg (prev/less), > + * so args-to-fixup are in diff regs. > + */ > + if (desc->func_id == special_kfunc_list[KF_bpf_list_add] || Nit: same nit here, maybe add is_bpf_list_add_kfunc(). > + is_bpf_rbtree_add_kfunc(desc->func_id)) { > struct_meta_reg = BPF_REG_4; > node_offset_reg = BPF_REG_5; > }

