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

From: Alexei Starovoitov

Date: Mon Feb 02 2026 - 12:57:19 EST


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.

pw-bot: cr