From: sashiko-bot@kernel.org
To: "Alan Maguire" <alan.maguire@oracle.com>
Cc: linux-modules@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v2 bpf-next 02/18] libbpf: Add support for BTF kinds LOC[_PARAM|_PROTO|SEC]
Date: Tue, 01 Sep 2026 17:11:26 +0000 [thread overview]
Message-ID: <20260901171126.DF09C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901165757.801449-3-alan.maguire@oracle.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] btf_equal_loc_param() fails to compare the flags field of BTF_KIND_LOC_PARAM, leading to incorrect deduplication.
- [Medium] Public libbpf API functions (e.g., btf__add_locsec, btf__add_loc_param, btf__add_loc_proto) return negative error codes directly without using the required libbpf_err() wrapper.
- [Low] The m_offs array in struct btf_field_desc is mistakenly inflated to size 22 instead of 2, unnecessarily wasting stack memory.
--
commit ce9959576588b24d58d6a9f71651d919ddebad03
Author: Alan Maguire <alan.maguire@oracle.com>
Subject: libbpf: Add support for BTF kinds LOC[_PARAM|_PROTO|SEC]
This patch adds support for new BTF kinds to libbpf, including deduplication
logic, data accessors, and construction APIs. It also extends the BTF field
iterator to handle the new section types.
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index c783359977b46..9449f6f50f18f 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
[ ... ]
> +int btf__add_loc_param(struct btf *btf, __u32 size, __u32 flags)
> +{
[ ... ]
> + p = btf_loc_param(t);
> + p->flags = flags;
> +
> + return btf_commit_type(btf, sz);
[Severity: Medium]
Since btf__add_loc_param() is a public libbpf API, should its error return
paths be wrapped with libbpf_err() to ensure errno is set properly for
userspace callers? Here, btf_commit_type() can return a negative error code
directly.
> +}
[ ... ]
> +int btf__add_loc_proto(struct btf *btf)
> +{
[ ... ]
> + t->info = btf_type_info(BTF_KIND_LOC_PROTO, 0, 0);
> + t->size = 0;
> +
> + return btf_commit_type(btf, sizeof(struct btf_type));
[Severity: Medium]
Does this unwrapped negative return code also apply to btf__add_loc_proto()?
> +}
[ ... ]
> +int btf__add_locsec(struct btf *btf, const char *name)
> +{
[ ... ]
> + if (!str_is_empty(name)) {
> + name_off = btf__add_str(btf, name);
> + if (name_off < 0)
> + return name_off;
[Severity: Medium]
Could this leak a negative error code without setting errno? The name_off
result can be negative on failure, and btf__add_locsec is a public API.
> + }
> + t->name_off = name_off;
> + t->info = btf_type_info(BTF_KIND_LOCSEC, 0, 0);
> + t->size = 0;
> +
> + return btf_commit_type(btf, sizeof(struct btf_type));
[Severity: Medium]
Similarly, should the return value of btf_commit_type() be wrapped here?
> +}
[ ... ]
> +static bool btf_equal_loc_param(struct btf_type *t1, struct btf_type *t2)
> +{
> + struct btf_loc_param *p1 = btf_loc_param(t1);
> + struct btf_loc_param *p2 = btf_loc_param(t2);
> + __u32 *v1 = (__u32 *)(p1 + 1);
> + __u32 *v2 = (__u32 *)(p2 + 1);
> + int i, vlen = btf_vlen(t1);
> +
> + if (!btf_equal_common(t1, t2))
> + return false;
> + for (i = 0; i < vlen; i++, v1++, v2++) {
> + if (*v1 != *v2)
> + return false;
> + }
> + return true;
[Severity: High]
Does this loop need to compare the flags field of the two btf_loc_param
structures? The current logic checks the trailing parameters but appears
to skip checking if p1->flags equals p2->flags, which might cause
LOC_PARAM types with different metadata to be incorrectly deduplicated.
> +}
[ ... ]
> diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
> index cb4d962338441..ebac8db1ccfda 100644
> --- a/tools/lib/bpf/libbpf_internal.h
> +++ b/tools/lib/bpf/libbpf_internal.h
> @@ -580,7 +580,7 @@ struct btf_field_desc {
> /* member struct size, or zero, if no members */
> int m_sz;
> /* repeated per-member offsets */
> - int m_off_cnt, m_offs[1];
> + int m_off_cnt, m_offs[22];
[Severity: Low]
Is m_offs sized to 22 here because BTF_KIND_LOCSEC equals 22?
Since the iter_init function only specifies 2 offsets for LOCSEC (func and
loc_proto), could this array be sized to the maximum offset count needed
(e.g., 2) to avoid unnecessary stack memory consumption when
struct btf_field_desc is instantiated?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901165757.801449-1-alan.maguire@oracle.com?part=2
next prev parent reply other threads:[~2026-09-01 17:11 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 16:57 [PATCH v2 bpf-next 00/18] Support inline functions in BTF Alan Maguire
2026-09-01 16:57 ` [PATCH v2 bpf-next 01/18] btf: Extend UAPI to support BTF location (inline site) info Alan Maguire
2026-09-01 17:17 ` sashiko-bot
2026-09-01 17:55 ` bot+bpf-ci
2026-09-01 16:57 ` [PATCH v2 bpf-next 02/18] libbpf: Add support for BTF kinds LOC[_PARAM|_PROTO|SEC] Alan Maguire
2026-09-01 17:11 ` sashiko-bot [this message]
2026-09-01 16:57 ` [PATCH v2 bpf-next 03/18] libbpf: Support moving permuted BTF types into split BTF Alan Maguire
2026-09-01 17:15 ` sashiko-bot
2026-09-01 18:14 ` bot+bpf-ci
2026-09-01 16:57 ` [PATCH v2 bpf-next 04/18] selftests/bpf: Test helper support for BTF_KIND_LOC[_PARAM|_PROTO|SEC] Alan Maguire
2026-09-01 17:06 ` sashiko-bot
2026-09-01 16:57 ` [PATCH v2 bpf-next 05/18] selftests/bpf: Add LOC_PARAM, LOC_PROTO, LOCSEC to field iter tests Alan Maguire
2026-09-01 16:57 ` [PATCH v2 bpf-next 06/18] selftests/bpf: Add LOC_PARAM, LOC_PROTO, LOCSEC to dedup split tests Alan Maguire
2026-09-01 17:55 ` bot+bpf-ci
2026-09-01 16:57 ` [PATCH v2 bpf-next 07/18] selftests/bpf: BTF distill tests to ensure LOC[_PARAM|_PROTO] add to split BTF Alan Maguire
2026-09-01 17:55 ` bot+bpf-ci
2026-09-01 16:57 ` [PATCH v2 bpf-next 08/18] selftests/bpf: Validate that btf__permute transfer works Alan Maguire
2026-09-01 17:16 ` sashiko-bot
2026-09-01 17:55 ` bot+bpf-ci
2026-09-01 16:57 ` [PATCH v2 bpf-next 09/18] bpftool: Handle multi-split BTF by supporting multiple base BTFs Alan Maguire
2026-09-01 17:13 ` sashiko-bot
2026-09-01 16:57 ` [PATCH v2 bpf-next 10/18] bpftool: Document support for multi-split BTF Alan Maguire
2026-09-01 17:12 ` sashiko-bot
2026-09-01 16:57 ` [PATCH v2 bpf-next 11/18] bpftool: Add ability to dump LOC_PARAM, LOC_PROTO and LOCSEC Alan Maguire
2026-09-01 17:16 ` sashiko-bot
2026-09-01 17:55 ` bot+bpf-ci
2026-09-01 16:57 ` [PATCH v2 bpf-next 12/18] resolve_btfids: Extract inline BTF Alan Maguire
2026-09-01 17:23 ` sashiko-bot
2026-09-01 16:57 ` [PATCH v2 bpf-next 13/18] kbuild: Add support for BTF inline information Alan Maguire
2026-09-01 17:55 ` bot+bpf-ci
2026-09-01 16:57 ` [PATCH v2 bpf-next 14/18] btf: Make vmlinux, module inline info available in /sys/kernel/btf Alan Maguire
2026-09-01 16:57 ` [PATCH v2 bpf-next 15/18] btf: Support CONFIG_DEBUG_INFO_BTF_INLINE=m Alan Maguire
2026-09-01 17:24 ` sashiko-bot
2026-09-01 16:57 ` [PATCH v2 bpf-next 16/18] btf: Relocate inline BTF for modules with distilled base BTF Alan Maguire
2026-09-01 17:29 ` sashiko-bot
2026-09-01 17:55 ` bot+bpf-ci
2026-09-01 16:57 ` [PATCH v2 bpf-next 17/18] selftests/bpf: Test BTF sysfs inline representations Alan Maguire
2026-09-01 17:22 ` sashiko-bot
2026-09-01 17:55 ` bot+bpf-ci
2026-09-01 16:57 ` [PATCH v2 bpf-next 18/18] selftests/bpf: Add a test verifying inline information Alan Maguire
2026-09-01 17:28 ` sashiko-bot
2026-09-01 17:55 ` bot+bpf-ci
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=20260901171126.DF09C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=bpf@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--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