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: <CAEf4BzZGz1k4ma4hYL-nR_e5QQxuzM3Y+VxZNWe_YupeQMj0-w@mail.gmail.com>
Date: Thu, 18 Dec 2025 16:05:34 -0800
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Donglin Peng <dolinux.peng@...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 11/13] libbpf: Add btf_is_sorted and
 btf_sorted_start_id helpers to refactor the code

On Thu, Dec 18, 2025 at 3:31 AM Donglin Peng <dolinux.peng@...il.com> 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(-)
>

It just adds more functions to jump to and check what it's doing. I
don't think this adds much value, just drop this patch


> 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;
> +}
> +
> +bool btf_is_sorted(const struct btf *btf)
> +{
> +       return btf->sorted_start_id > 0;
> +}
> +
>  /* 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)
>  {
> --
> 2.34.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ