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: <CAErzpmuTJpgwafJzR=LNudNXTzL-=LpmEdF6zxr=s6hkDUDhvg@mail.gmail.com>
Date: Fri, 19 Dec 2025 13:49:50 +0800
From: Donglin Peng <dolinux.peng@...il.com>
To: Eduard Zingerman <eddyz87@...il.com>
Cc: ast@...nel.org, andrii.nakryiko@...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 11/13] libbpf: Add btf_is_sorted and
 btf_sorted_start_id helpers to refactor the code

On Fri, Dec 19, 2025 at 6:33 AM Eduard Zingerman <eddyz87@...il.com> wrote:
>
> On Thu, 2025-12-18 at 19:30 +0800, Donglin Peng wrote:
> > From: pengdonglin <pengdonglin@...omi.com>
> >
> > Introduce two new helper functions 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>
> > ---
> >  tools/lib/bpf/btf.c             | 14 ++++++++++++--
> >  tools/lib/bpf/libbpf_internal.h |  2 ++
> >  2 files changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> > index b5b0898d033d..571b72bd90b5 100644
> > --- a/tools/lib/bpf/btf.c
> > +++ b/tools/lib/bpf/btf.c
> > @@ -626,6 +626,16 @@ const struct btf *btf__base_btf(const struct btf *btf)
> >       return btf->base_btf;
> >  }
> >
> > +int btf_sorted_start_id(const struct btf *btf)
> > +{
> > +     return btf->sorted_start_id;
> > +}
>
> Having this function declared differently in kernel and in libbpf is a
> bit confusing. Is it needed in libbpf at all?

Thanks. Keeping it consistent between libbpf and kernel side.
Will remove in the next version.

>
> > +bool btf_is_sorted(const struct btf *btf)
> > +{
> > +     return btf->sorted_start_id > 0;
> > +}
> > +
>
> Please squash this with the first btf_find_by_name_kind() change.

Yes.

>
> >  /* internal helper returning non-const pointer to a type */
> >  struct btf_type *btf_type_by_id(const struct btf *btf, __u32 type_id)
> >  {
> > @@ -976,11 +986,11 @@ static __s32 btf_find_by_name_kind(const struct btf *btf, int start_id,
> >       if (kind == BTF_KIND_UNKN || strcmp(type_name, "void") == 0)
> >               return 0;
> >
> > -     if (btf->sorted_start_id > 0 && type_name[0]) {
> > +     if (btf_is_sorted(btf) && type_name[0]) {
> >               __s32 end_id = btf__type_cnt(btf) - 1;
> >
> >               /* skip anonymous types */
> > -             start_id = max(start_id, btf->sorted_start_id);
> > +             start_id = max(start_id, btf_sorted_start_id(btf));
> >               idx = btf_find_by_name_bsearch(btf, type_name, start_id, end_id);
> >               if (unlikely(idx < 0))
> >                       return libbpf_err(-ENOENT);
> > diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
> > index fc59b21b51b5..95e6848396b4 100644
> > --- a/tools/lib/bpf/libbpf_internal.h
> > +++ b/tools/lib/bpf/libbpf_internal.h
> > @@ -250,6 +250,8 @@ const struct btf_type *skip_mods_and_typedefs(const struct btf *btf, __u32 id, _
> >  const struct btf_header *btf_header(const struct btf *btf);
> >  void btf_set_base_btf(struct btf *btf, const struct btf *base_btf);
> >  int btf_relocate(struct btf *btf, const struct btf *base_btf, __u32 **id_map);
> > +int btf_sorted_start_id(const struct btf *btf);
> > +bool btf_is_sorted(const struct btf *btf);
> >
> >  static inline enum btf_func_linkage btf_func_linkage(const struct btf_type *t)
> >  {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ