BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ihor Solodrai" <ihor.solodrai@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 07/17] libbpf, bpftool, resolve_btfids: Dump kflagged BTF tags as is
Date: Thu, 05 Nov 2026 18:16:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-199716@kernel.org> (raw)
In-Reply-To: <20261105175845.30357-8-ihor.solodrai@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] bpf: changing kflag BTF_KIND_TYPE_TAG format breaks C dumps across versions
--

commit 02905c14788165a6bc8db8f66ae9bfa227c2d55a
Author: Ihor Solodrai <ihor.solodrai@linux.dev>

libbpf, bpftool, resolve_btfids: Dump kflagged BTF tags as is

This commit changes btf_dump to print kflagged BTF decl and type tags as-is
without wrapping them in __attribute__((...)), updates resolve_btfids to
encode the full __attribute__((address_space(1))) string in TYPE_ATTR_ARENA,
and adds a split-BTF decl tag override in bpftool for older kernel BTF.

> diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c
> index 5ad5473563034..c16dd93fa6d4c 100644
> --- a/tools/bpf/resolve_btfids/main.c
> +++ b/tools/bpf/resolve_btfids/main.c
> @@ -204,7 +204,7 @@ struct btf_links {
>  #define KF_ARENA_ARG2	(1 << 15)
>  #define KF_IMPLICIT_ARGS (1 << 16)
>  #define KF_IMPL_SUFFIX "_impl"
> -#define TYPE_ATTR_ARENA "address_space(1)"
> +#define TYPE_ATTR_ARENA "__attribute__((address_space(1)))"
>  #define PARAM_SUFFIX_ARENA "__arena"
>  #define PARAM_SUFFIX_ARENA_NULLABLE "__arena__nullable"
>  
> diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
> index c12c3c248407f..fcd97aa905897 100644
> --- a/tools/lib/bpf/btf_dump.c
> +++ b/tools/lib/bpf/btf_dump.c
> @@ -1023,7 +1023,7 @@ static void btf_dump_emit_decl_tag(struct btf_dump *d, const struct btf_type *t)
>  	const char *name = btf_name_of(d, t->name_off);
>  
>  	if (btf_kflag(t))
> -		btf_dump_printf(d, " __attribute__((%s))", name);
> +		btf_dump_printf(d, " %s", name);
>  	else
>  		btf_dump_printf(d, " __attribute__((btf_decl_tag(\"%s\")))", name);
>  }
> @@ -1602,7 +1602,7 @@ static void btf_dump_emit_type_chain(struct btf_dump *d,
>  				break;
>  			name = btf_name_of(d, t->name_off);
>  			if (btf_kflag(t))
> -				btf_dump_printf(d, " __attribute__((%s))", name);
> +				btf_dump_printf(d, " %s", name);
>  			else
>  				btf_dump_printf(d, " __attribute__((btf_type_tag(\"%s\")))", name);
>  			break;

[Severity: Medium]
As reported by bot+bpf-ci@kernel.org on v3 [1], changing how kflagged
BTF_KIND_TYPE_TAG entries are encoded by resolve_btfids and emitted by
btf_dump_emit_type_chain() causes regressions when dumping C headers across
versions.

In tools/bpf/resolve_btfids/main.c, TYPE_ATTR_ARENA is changed to
"__attribute__((address_space(1)))" and passed to btf__add_type_attr() in
arena_tag_ptr(), which encodes the full attribute wrapper into vmlinux BTF for
arena kfuncs. When an existing bpftool built with libbpf 1.6 or later dumps
vmlinux.h from a newly built kernel, its btf_dump_emit_type_chain() wraps the
kflagged type tag in __attribute__((%s)) again, emitting:

  void __attribute__((__attribute__((address_space(1))))) *

This breaks compilation of any BPF program including vmlinux.h unless
BPF_NO_KFUNC_PROTOTYPES is defined.

Conversely, in tools/lib/bpf/btf_dump.c, changing btf_dump_emit_type_chain()
to print kflagged BTF_KIND_TYPE_TAG strings without __attribute__((...))
means that any external caller of btf_dump__dump_type() or
btf_dump__emit_type_decl() outside bpftool (which does not run
btf_c_annotate_type_tags()) will emit bare address_space(1) when dumping
existing v6.16+ kernel BTF or BTF produced by pahole with
--btf_features=attributes, which also fails to compile.

Since btf_dump already allows a kflagged BTF_KIND_DECL_TAG (with
component_idx = -1) in the dump split BTF to override how a referenced
BTF_KIND_TYPE_TAG is printed, could btf_dump_emit_type_chain() and
TYPE_ATTR_ARENA in resolve_btfids be left unchanged, and raw printing be
restricted to kflagged BTF_KIND_DECL_TAG in btf_dump_emit_decl_tag() as
requested by Alexei Starovoitov on v3?

[1] https://lore.kernel.org/r/b8912e062900f51fd8c8f44c44ef43d0788ce6af12582abc0060dd6cd4c05065@mail.kernel.org

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261105175845.30357-1-ihor.solodrai@linux.dev?part=7

  reply	other threads:[~2026-11-05 18:16 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 17:58 [PATCH bpf-next v4 00/17] bpftool: Per-record CO-RE attributes in the C dump Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 01/17] Revert "libbpf: Render the arena type tag with its address space" Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 02/17] libbpf: Look up BTF strings without making BTF modifiable Ihor Solodrai
2026-11-05 18:41   ` bot+bpf-ci
2026-11-05 17:58 ` [PATCH bpf-next v4 03/17] bpftool: Dump C through a split BTF Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 04/17] selftests/bpf: Build BTF fixtures in btf_to_tmpfile() Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 05/17] selftests/bpf: Cover unknown BTF header-extension bytes in bpftool C dumps Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 06/17] libbpf: Let decl tags override how btf_dump renders type tags Ihor Solodrai
2026-11-06  0:24   ` Andrii Nakryiko
2026-11-05 17:58 ` [PATCH bpf-next v4 07/17] libbpf, bpftool, resolve_btfids: Dump kflagged BTF tags as is Ihor Solodrai
2026-11-05 18:16   ` sashiko-bot [this message]
2026-11-06  0:25   ` Andrii Nakryiko
2026-11-05 17:58 ` [PATCH bpf-next v4 08/17] selftests/bpf: Cover type tag rendering overrides in btf_dump Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 09/17] selftests/bpf: Cover legacy arena type tags in bpftool C dumps Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 10/17] bpftool: Apply __bpf_relocatable per record on BTF dump Ihor Solodrai
2026-11-05 18:41   ` bot+bpf-ci
2026-11-05 17:58 ` [PATCH bpf-next v4 11/17] bpftool: Skip __bpf_relocatable on verifier-rewritten context types Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 12/17] bpftool: Emit __bpf_static_offset " Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 13/17] selftests/bpf: Cover record attributes in bpftool BTF dumps Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 14/17] selftests/bpf: Cover context and socket accesses through vmlinux.h Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 15/17] bpftool: Document __bpf_relocatable and __bpf_static_offset Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 16/17] bpftool: Render the arena type tag as __bpf_arena Ihor Solodrai
2026-11-05 17:58 ` [PATCH bpf-next v4 17/17] selftests/bpf: Cover the arena type tag in bpftool C dumps Ihor Solodrai
2026-11-06  0:30 ` [PATCH bpf-next v4 00/17] bpftool: Per-record CO-RE attributes in the C dump patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-199716@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox