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 18/18] selftests/bpf: Add a test verifying inline information
Date: Tue, 01 Sep 2026 17:28:11 +0000 [thread overview]
Message-ID: <20260901172811.AC7021F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901165757.801449-19-alan.maguire@oracle.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] Parser desynchronization in module_get_base_addr() when reading trailing fields in /proc/modules.
- [Medium] Inverted logic in ASSERT_LT check causes early exit on test success.
- [Medium] Unhandled error from btf__parse_split leads to invalid pointer dereference.
- [Medium] Missing NULL pointer check after btf__type_by_id allows segmentation fault on malformed BTF.
--
commit 2cf9036457ef4f9129e585e625be7f2e1a33c7fa
Author: Alan Maguire <alan.maguire@oracle.com>
selftests/bpf: Add a test verifying inline information
This commit adds a selftest to verify inline information for an
__always_inline function in bpf_testmod. It checks that the LOCSEC
descriptor offset is within the expected bounds of the function.
> diff --git a/tools/testing/selftests/bpf/prog_tests/btf_inline.c b/tools/testing/selftests/bpf/prog_tests/btf_inline.c
> index 0000000000000..8e0a85f6c6980
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/btf_inline.c
[ ... ]
> + inline_btf = btf__parse_split(BTF_SYSFS_DIR "/bpf_testmod" BTF_INLINE_SUFFIX,
> + btf);
> + err = libbpf_get_error(inline_btf);
> + /* pahole may not have inline BTF feature support. */
> + if (err == -ENOENT) {
> + skip = true;
> + goto out;
> + }
> + locsec_id = btf__find_by_name_kind(inline_btf, ".text", BTF_KIND_LOCSEC);
[Severity: Medium]
Does this code handle errors other than -ENOENT correctly?
If btf__parse_split() fails with an error like -ENOMEM, err will be extracted,
but since it is not -ENOENT, execution continues and the unhandled ERR_PTR in
inline_btf is passed to btf__find_by_name_kind(), leading to a dereference of
an invalid pointer.
[ ... ]
> + t = btf__type_by_id(inline_btf, l->loc_proto);
> + if (!ASSERT_OK_PTR(t, "loc_proto_ptr"))
> + goto out;
> + if (!ASSERT_EQ(btf_vlen(t), 1, "loc_proto_one_param"))
> + goto out;
> + p = btf_loc_proto_params(t);
> + t = btf__type_by_id(inline_btf, *p);
> + lp = btf_loc_param(t);
[Severity: Medium]
Can this lead to a NULL pointer dereference on malformed BTF data?
Unlike the safe pattern used earlier with ASSERT_OK_PTR, the return value of
btf__type_by_id() is passed directly to btf_loc_param() and dereferenced via
lp->flags without a NULL check.
> + if (!ASSERT_EQ(lp->flags, BTF_LOC_PARAM_REG, "param_is_reg"))
> + goto out;
> + if (!ASSERT_GT(l->offset, caller_addr, "inline_gt_caller"))
> + goto out;
> + /* simple sanity test to roughly ensure inline site still in function */
> + if (ASSERT_LT(l->offset, caller_addr + 256, "inline_in_caller"))
> + goto out;
[Severity: Medium]
Does this missing negation cause the test to exit early on success?
The ASSERT_LT macro evaluates to true when the check succeeds. Because the
condition lacks the negation ! used in all other assertions here, it will
execute the goto out branch when the sanity check passes.
> diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/trace_helpers.c
> index 679008b310d9a..bf4cb720e7b81 100644
> --- a/tools/testing/selftests/bpf/trace_helpers.c
> +++ b/tools/testing/selftests/bpf/trace_helpers.c
[ ... ]
> +long module_get_base_addr(const char *module)
> +{
> + unsigned long long addr, base_addr = 0;
> + char name[500];
> + FILE *f;
> +
> + f = fopen("/proc/modules", "r");
> + if (!f)
> + return 0;
> +
> + while (fscanf(f, "%s %*s %*s %*s %*s 0x%llx", name, &addr) > 0) {
[Severity: Medium]
Can this parser become desynchronized if trailing fields are present in
/proc/modules?
The fscanf format string expects exactly 6 tokens and lacks a way to consume
the remainder of the line. Out-of-tree modules natively produce a 7th token
(such as the (O) taint flag).
When this happens, the trailing token is not consumed and the next loop
iteration will mistakenly read it as the name, breaking the parsing structure
for all subsequent lines.
> + if (strcmp(module, name) == 0) {
> + base_addr = addr;
> + break;
> + }
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901165757.801449-1-alan.maguire@oracle.com?part=18
next prev parent reply other threads:[~2026-09-01 17:28 UTC|newest]
Thread overview: 50+ 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-09 22:26 ` Eduard Zingerman
2026-09-11 19:26 ` Jiri Olsa
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
2026-09-09 22:26 ` Eduard Zingerman
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-10 9:37 ` Eduard Zingerman
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-07 19:30 ` Alexei Starovoitov
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-07 19:34 ` Alexei Starovoitov
2026-09-07 19:50 ` Alan Maguire
2026-09-07 20:00 ` Alexei Starovoitov
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 [this message]
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=20260901172811.AC7021F000E9@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 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.