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: <CAErzpmu0achwAo7V6N04GkDL4ofoQBwKiQ0Siq8v9HOKYRv3RQ@mail.gmail.com>
Date: Sat, 20 Dec 2025 22:25:15 +0800
From: Donglin Peng <dolinux.peng@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: ast@...nel.org, eddyz87@...il.com, zhangxiaoqin@...omi.com, 
	ihor.solodrai@...ux.dev, linux-kernel@...r.kernel.org, bpf@...r.kernel.org, 
	pengdonglin <pengdonglin@...omi.com>, Alan Maguire <alan.maguire@...cle.com>
Subject: Re: [PATCH bpf-next v10 12/13] btf: Add btf_is_sorted to refactor the code

On Fri, Dec 19, 2025 at 8:05 AM Andrii Nakryiko
<andrii.nakryiko@...il.com> wrote:
>
> On Thu, Dec 18, 2025 at 3:31 AM Donglin Peng <dolinux.peng@...il.com> wrote:
> >
> > From: pengdonglin <pengdonglin@...omi.com>
> >
> > Introduce a new helper function to clarify the code and no
> > functional changes are introduced.
> >
> > Cc: Eduard Zingerman <eddyz87@...il.com>
> > Cc: Alexei Starovoitov <ast@...nel.org>
> > Cc: Andrii Nakryiko <andrii.nakryiko@...il.com>
> > Cc: Alan Maguire <alan.maguire@...cle.com>
> > Cc: Ihor Solodrai <ihor.solodrai@...ux.dev>
> > Cc: Xiaoqin Zhang <zhangxiaoqin@...omi.com>
> > Signed-off-by: pengdonglin <pengdonglin@...omi.com>
> > ---
> >  include/linux/btf.h | 1 +
> >  kernel/bpf/btf.c    | 9 +++++++--
> >  2 files changed, 8 insertions(+), 2 deletions(-)
> >
>
> let's drop, this is not necessary

Okay, I will drop it.

>
>
> > diff --git a/include/linux/btf.h b/include/linux/btf.h
> > index 2d28f2b22ae5..947ed2abf632 100644
> > --- a/include/linux/btf.h
> > +++ b/include/linux/btf.h
> > @@ -221,6 +221,7 @@ bool btf_is_vmlinux(const struct btf *btf);
> >  struct module *btf_try_get_module(const struct btf *btf);
> >  u32 btf_nr_types(const struct btf *btf);
> >  u32 btf_sorted_start_id(const struct btf *btf);
> > +bool btf_is_sorted(const struct btf *btf);
> >  struct btf *btf_base_btf(const struct btf *btf);
> >  bool btf_type_is_i32(const struct btf_type *t);
> >  bool btf_type_is_i64(const struct btf_type *t);
> > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> > index 3aeb4f00cbfe..0f20887a6f02 100644
> > --- a/kernel/bpf/btf.c
> > +++ b/kernel/bpf/btf.c
> > @@ -555,6 +555,11 @@ u32 btf_sorted_start_id(const struct btf *btf)
> >         return btf->sorted_start_id ?: (btf->start_id ?: 1);
> >  }
> >
> > +bool btf_is_sorted(const struct btf *btf)
> > +{
> > +       return btf->sorted_start_id > 0;
> > +}
> > +
> >  /*
> >   * Assuming that types are sorted by name in ascending order.
> >   */
> > @@ -649,9 +654,9 @@ s32 btf_find_by_name_kind(const struct btf *btf, const char *name, u8 kind)
> >                         return idx;
> >         }
> >
> > -       if (btf->sorted_start_id > 0 && name[0]) {
> > +       if (btf_is_sorted(btf) && name[0]) {
> >                 /* skip anonymous types */
> > -               s32 start_id = btf->sorted_start_id;
> > +               s32 start_id = btf_sorted_start_id(btf);
> >                 s32 end_id = btf_nr_types(btf) - 1;
> >
> >                 idx = btf_find_by_name_bsearch(btf, name, start_id, end_id);
> > --
> > 2.34.1
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ