lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP01T75q1wWNcgT3aeq8DSOLkVCu-xTD3foR2n7+fOju87OBQA@mail.gmail.com>
Date: Tue, 22 Apr 2025 04:32:10 +0200
From: Kumar Kartikeya Dwivedi <memxor@...il.com>
To: Martin KaFai Lau <martin.lau@...ux.dev>
Cc: bpf@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>, 
	Andrii Nakryiko <andrii@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, netdev@...r.kernel.org, 
	kernel-team@...a.com, Amery Hung <ameryhung@...il.com>
Subject: Re: [RFC PATCH bpf-next 05/12] bpf: Allow refcounted bpf_rb_node used
 in bpf_rbtree_{remove,left,right}

On Sat, 19 Apr 2025 at 00:48, Martin KaFai Lau <martin.lau@...ux.dev> wrote:
>
> From: Martin KaFai Lau <martin.lau@...nel.org>
>
> The bpf_rbtree_{remove,left,right} requires the root's lock to be held.
> They also check the node_internal->owner is still owned by that root
> before proceeding, so it is safe to allow refcounted bpf_rb_node
> pointer to be used in these kfuncs.
>
> In the later selftest, a networking flow (allocated by bpf_obj_new)
> can be added to two different rbtrees. There are cases that the flow
> is searched from one rbtree, held the refcount of the flow,
> and then removed from the another rbtree:
>
> struct fq_flow {
>         struct bpf_rb_node      fq_node;
>         struct bpf_rb_node      rate_node;
>         struct bpf_refcount     refcount;
>         unsigned long           sk_long;
> };
>
> int bpf_fq_enqueue(...)
> {
>         /* ... */
>
>         bpf_spin_lock(&root->lock);
>         while (can_loop) {
>                 /* ... */
>                 if (!p)
>                         break;
>                 gc_f = bpf_rb_entry(p, struct fq_flow, fq_node);
>                 if (gc_f->sk_long == sk_long) {
>                         f = bpf_refcount_acquire(gc_f);
>                         break;
>                 }
>                 /* ... */
>         }
>         bpf_spin_unlock(&root->lock);
>
>         if (f) {
>                 bpf_spin_lock(&q->lock);
>                 bpf_rbtree_remove(&q->delayed, &f->rate_node);
>                 bpf_spin_unlock(&q->lock);
>         }
> }
>
> bpf_rbtree_{left,right} do not need this change but are relaxed together
> with bpf_rbtree_remove instead of adding extra verifier logic
> to exclude these kfuncs.
>
> Signed-off-by: Martin KaFai Lau <martin.lau@...nel.org>
> ---

Acked-by: Kumar Kartikeya Dwivedi <memxor@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ