Re: [PATCH v4 1/3] bpf/verifier: allow calling bpf_kptr_xchg while holding a lock

From: Chengkaitao

Date: Mon Feb 02 2026 - 20:14:52 EST


On Tue, Feb 3, 2026 at 1:57 AM Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> On Mon, Feb 2, 2026 at 1:01 AM Chengkaitao <pilgrimtao@xxxxxxxxx> wrote:
> >
> > From: Chengkaitao <chengkaitao@xxxxxxxxxx>
> >
> > For the following scenario:
> > struct tree_node {
> > struct bpf_rb_node node;
> > struct request __kptr *req;
> > u64 key;
> > };
> > struct bpf_rb_root tree_root __contains(tree_node, node);
> > struct bpf_spin_lock tree_lock;
> >
> > If we need to traverse all nodes in the rbtree, retrieve the __kptr
> > pointer from each node, and read kernel data from the referenced
> > object, using bpf_kptr_xchg appears unavoidable.
> >
> > This patch skips the BPF verifier checks for bpf_kptr_xchg when
> > called while holding a lock.
> >
> > Signed-off-by: Chengkaitao <chengkaitao@xxxxxxxxxx>
>
> You ignored earlier feedback. This is not ok.
>
It's my full name. Every region has its own customs and traditions,
so this isn't an essential change.

--
Yours,
Chengkaitao