From: sashiko-bot@kernel.org
To: "Alan Maguire" <alan.maguire@oracle.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v2 bpf-next 2/8] libbpf: Adjust btf_vlen() to return a __u32
Date: Thu, 16 Apr 2026 19:36:35 +0000 [thread overview]
Message-ID: <20260416193636.33459C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260416143904.1220662-3-alan.maguire@oracle.com>
Sashiko AI review found 1 potential issue(s):
- [High] btf__add_field() manually increments vlen without checking for BTF_MAX_VLEN overflow, leading to silent BTF type corruption.
--
commit bc2a5650478dca79064a34b0022bfd5fa6e2da77
Author: Alan Maguire <alan.maguire@oracle.com>
libbpf: Adjust btf_vlen() to return a __u32
Now that vlen is 24 bits, btf_vlen() must return a __u32.
Adjust use cases in libbpf accordingly. Also add error
handling to avoid vlen overflow in btf_type_inc_vlen().
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
[ ... ]
> @@ -2121,9 +2121,12 @@ static void *btf_add_type_mem(struct btf *btf, size_t add_sz)
> btf->hdr.type_len, UINT_MAX, add_sz);
> }
>
> -static void btf_type_inc_vlen(struct btf_type *t)
> +static int btf_type_inc_vlen(struct btf_type *t)
> {
> + if (btf_vlen(t) == BTF_MAX_VLEN)
> + return -ENOSPC;
> t->info = btf_type_info(btf_kind(t), btf_vlen(t) + 1, btf_kflag(t));
> + return 0;
> }
Does btf__add_field() also need to check for BTF_MAX_VLEN overflow?
It looks like btf__add_field() manually increments the length without using
btf_type_inc_vlen() to preserve the kflag:
t = btf_last_type(btf);
/* update parent type's vlen and kflag */
t->info = btf_type_info(btf_kind(t), btf_vlen(t) + 1, is_bitfield || btf_kflag(t));
If a struct or union exceeds the maximum number of members, could this
increment overflow into the kind bits and corrupt the BTF type boundaries?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260416143904.1220662-1-alan.maguire@oracle.com?part=2
next prev parent reply other threads:[~2026-04-16 19:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 14:38 [PATCH v2 bpf-next 0/8] bpf: Extend BTF UAPI vlen, kinds to use unused bits Alan Maguire
2026-04-16 14:38 ` [PATCH v2 bpf-next 1/8] " Alan Maguire
2026-04-16 15:54 ` Alexei Starovoitov
2026-04-16 19:05 ` sashiko-bot
2026-04-16 14:38 ` [PATCH v2 bpf-next 2/8] libbpf: Adjust btf_vlen() to return a __u32 Alan Maguire
2026-04-16 15:27 ` bot+bpf-ci
2026-04-16 19:36 ` sashiko-bot [this message]
2026-04-16 14:38 ` [PATCH v2 bpf-next 3/8] libbpf: Add feature for kernel extended vlen/kind support Alan Maguire
2026-04-16 15:27 ` bot+bpf-ci
2026-04-16 15:56 ` Alexei Starovoitov
2026-04-16 16:08 ` Alan Maguire
2026-04-16 20:01 ` sashiko-bot
2026-04-16 14:39 ` [PATCH v2 bpf-next 4/8] bpftool: Support 24-bit vlen Alan Maguire
2026-04-16 15:15 ` bot+bpf-ci
2026-04-16 14:39 ` [PATCH v2 bpf-next 5/8] selftests/bpf: Test BTF sanitization rejection for invalid vlen Alan Maguire
2026-04-16 15:27 ` bot+bpf-ci
2026-04-16 20:20 ` sashiko-bot
2026-04-16 14:39 ` [PATCH v2 bpf-next 6/8] selftests/bpf: Fix up btf/invalid test for extended kind Alan Maguire
2026-04-16 14:39 ` [PATCH v2 bpf-next 7/8] selftests/bpf: Fix up __u16 vlen assumptions Alan Maguire
2026-04-16 20:32 ` sashiko-bot
2026-04-16 14:39 ` [PATCH v2 bpf-next 8/8] Documentation/bpf: Update btf doc with updated vlen, kind sizes Alan Maguire
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=20260416193636.33459C2BCB0@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.