public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alan Maguire" <alan.maguire@oracle.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 4/6] bpftool: Support 24-bit vlen
Date: Tue, 14 Apr 2026 22:12:16 +0000	[thread overview]
Message-ID: <20260414221216.DEB23C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260414195019.684531-5-alan.maguire@oracle.com>

Sashiko AI review found 1 potential issue(s):
- [Medium] Infinite loop in bpftool when dumping BTF enum types with 65536 or more members.
--

commit 0557506c731dab5c8d22900a9797fac53be5f625
Author: Alan Maguire <alan.maguire@oracle.com>

bpftool: Support 24-bit vlen

This commit updates bpftool to handle the new 24-bit BTF vlen by changing
variables and loop counters from 16-bit to 32-bit integers across various
BTF dumping functions.

> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
> index 2e899e9400341..6ef908adf3a4a 100644
> --- a/tools/bpf/bpftool/btf.c
> +++ b/tools/bpf/bpftool/btf.c
[ ... ]
> @@ -225,9 +224,8 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
>  	}
>  	case BTF_KIND_ENUM: {
>  		const struct btf_enum *v = (const void *)(t + 1);
> -		__u16 vlen = BTF_INFO_VLEN(t->info);
> +		__u32 i, vlen = BTF_INFO_VLEN(t->info);
>  		const char *encoding;
> -		int i;

Are there missing updates to btf_dumper_enum() and btf_dumper_enum64() in
tools/bpf/bpftool/btf_dumper.c?

In btf_dumper_enum(), the loop counter i is still declared as a 16-bit
integer:

static int btf_dumper_enum(const struct btf_dumper *d,
			    const struct btf_type *t,
			    const void *data)
{
	const struct btf_enum *enums = btf_enum(t);
	__s64 value;
	__u16 i;
	...
	for (i = 0; i < btf_vlen(t); i++) {
		if (value == enums[i].val) {
	...

If a BTF enum type has 65536 or more members, btf_vlen(t) will return a value
greater than or equal to 65536. The __u16 i counter will overflow to 0 upon
reaching 65536, meaning i < btf_vlen(t) will always remain true.

If the dumped variable's value does not match any of the first 65536 enum
members, will the function loop infinitely instead of falling back to
jsonw_int()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260414195019.684531-1-alan.maguire@oracle.com?part=4

  reply	other threads:[~2026-04-14 22:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14 19:50 [PATCH bpf-next 0/6] btf: Extend vlen, kind in struct btf_type Alan Maguire
2026-04-14 19:50 ` [PATCH bpf-next 1/6] bpf: Extend BTF UAPI vlen, kinds to use unused bits Alan Maguire
2026-04-14 20:42   ` bot+bpf-ci
2026-04-14 21:11   ` sashiko-bot
2026-04-15 15:48     ` Mykyta Yatsenko
2026-04-14 19:50 ` [PATCH bpf-next 2/6] libbpf: Adjust btf_vlen() to return a __u32 Alan Maguire
2026-04-14 21:39   ` sashiko-bot
2026-04-14 19:50 ` [PATCH bpf-next 3/6] libbpf: Add feature for kernel extended vlen/kind support Alan Maguire
2026-04-14 20:29   ` bot+bpf-ci
2026-04-14 21:58   ` sashiko-bot
2026-04-15  1:56   ` Alexei Starovoitov
2026-04-15 15:57   ` Mykyta Yatsenko
2026-04-16  8:57     ` Alan Maguire
2026-04-16 14:15       ` Alexei Starovoitov
2026-04-14 19:50 ` [PATCH bpf-next 4/6] bpftool: Support 24-bit vlen Alan Maguire
2026-04-14 22:12   ` sashiko-bot [this message]
2026-04-14 19:50 ` [PATCH bpf-next 5/6] selftests/bpf: Test BTF sanitization rejection for invalid vlen Alan Maguire
2026-04-14 22:26   ` sashiko-bot
2026-04-15 16:03     ` Mykyta Yatsenko
2026-04-14 19:50 ` [PATCH bpf-next 6/6] selftests/bpf: Fix up btf/invalid test for extended kind Alan Maguire
2026-04-14 22:32   ` sashiko-bot

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=20260414221216.DEB23C19425@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alan.maguire@oracle.com \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko@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