From: sashiko-bot@kernel.org
To: "Alan Maguire" <alan.maguire@oracle.com>
Cc: linux-modules@vger.kernel.org, "Petr Pavlu" <petr.pavlu@suse.com>,
bpf@vger.kernel.org
Subject: Re: [PATCH v3 bpf-next 7/7] selftests/bpf: Add a test verifying inline information
Date: Sat, 03 Oct 2026 19:54:27 +0000 [thread overview]
Message-ID: <20261003195427.E25CA1F0089C@smtp.kernel.org> (raw)
In-Reply-To: <20261003194323.817885-8-alan.maguire@oracle.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] bpf: null pointer dereference in test_btf_inline() on error path
- [Medium] bpf: invalid pointer dereference in test_btf_inline() due to missing NULL check
- [Medium] bpf: uninitialized variable usage in module_get_base_addr()
- [Low] bpf: inverted assertion logic in test_btf_inline() breaks failure-abort pattern
--
commit 0f45ec42b3956956fce6d91dc0397c28034b638d
Author: Alan Maguire <alan.maguire@oracle.com>
selftests/bpf: Add a test verifying inline information
This commit adds a selftest for bpf_testmod to verify that inline information
is correctly generated and matches expectations for an always-inline function.
It validates the LOCSEC descriptor offset and skips the test if pahole does
not encode inline information.
> diff --git a/tools/testing/selftests/bpf/prog_tests/btf_inline.c b/tools/testing/selftests/bpf/prog_tests/btf_inline.c
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/btf_inline.c
[ ... ]
> +void test_btf_inline(void)
> +{
[ ... ]
> + 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, "inline.text", BTF_KIND_LOCSEC);
[Severity: Medium]
What happens if btf__parse_split() fails with an error other than -ENOENT,
such as -ENOMEM?
If inline_btf is an error pointer or NULL, the condition checking for -ENOENT
evaluates to false, and the invalid inline_btf pointer is passed directly to
btf__find_by_name_kind().
Can this cause a null pointer dereference when libbpf attempts to access the
BTF struct?
[ ... ]
> + 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);
> + if (!ASSERT_EQ(lp->flags, BTF_LOC_PARAM_REG, "param_is_reg"))
[Severity: Medium]
Does the second call to btf__type_by_id() require a check to ensure 't' is
not NULL before calculating the location param?
If *p is an invalid type ID, t would be NULL, and passing it to
btf_loc_param() calculates an offset from a NULL pointer. Could this cause a
segmentation fault when lp->flags is accessed?
> + 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: Low]
Is the logic inverted on this ASSERT_LT() check?
The other assertions use the ! operator to jump to 'out' on failure. Because
ASSERT_LT() returns true when the check succeeds, it looks like this will jump
to 'out' on success instead of on failure. While this might be benign right
now as the last statement, will it bypass any future checks appended here?
> diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/trace_helpers.c
> --- a/tools/testing/selftests/bpf/trace_helpers.c
> +++ b/tools/testing/selftests/bpf/trace_helpers.c
[ ... ]
> +long module_get_base_addr(const char *module)
> +{
[ ... ]
> + while (fscanf(f, "%s %*s %*s %*s %*s 0x%llx", name, &addr) > 0) {
> + if (strcmp(module, name) == 0) {
> + base_addr = addr;
> + break;
> + }
> + }
[Severity: Medium]
Can fscanf() return 1 if it successfully parses the module name but fails to
parse the address field?
If the line format in /proc/modules is unexpected or malformed, and fscanf()
returns 1, the check > 0 will pass, but the addr variable will remain
uninitialized. If the module name matches, could this return uninitialized
stack memory as the base address? Would it be safer to check that fscanf
returns exactly 2?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261003194323.817885-1-alan.maguire@oracle.com?part=7
prev parent reply other threads:[~2026-10-03 19:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 19:43 [PATCH v3 bpf-next 0/7] kbuild, bpf: Support inline info in BTF Alan Maguire
2026-10-03 19:43 ` [PATCH v3 bpf-next 1/7] resolve_btfids: Build separate main and inline BTF objects Alan Maguire
2026-10-03 20:27 ` bot+bpf-ci
2026-10-06 17:30 ` Alan Maguire
2026-10-03 19:43 ` [PATCH v3 bpf-next 2/7] resolve_btfids: Populate BTF link section Alan Maguire
2026-10-03 20:27 ` bot+bpf-ci
2026-10-03 19:43 ` [PATCH v3 bpf-next 3/7] kbuild, btf: Expose vmlinux inline BTF through sysfs Alan Maguire
2026-10-03 19:56 ` sashiko-bot
2026-10-06 18:12 ` Alan Maguire
2026-10-03 20:41 ` bot+bpf-ci
2026-10-06 18:42 ` Alan Maguire
2026-10-03 19:43 ` [PATCH v3 bpf-next 4/7] btf: Preserve string relocation maps for split BTF Alan Maguire
2026-10-03 19:43 ` [PATCH v3 bpf-next 5/7] btf: Relocate and expose module inline BTF Alan Maguire
2026-10-03 19:59 ` sashiko-bot
2026-10-06 18:56 ` Alan Maguire
2026-10-03 20:27 ` bot+bpf-ci
2026-10-03 19:43 ` [PATCH v3 bpf-next 6/7] selftests/bpf: Test BTF sysfs inline representations Alan Maguire
2026-10-03 19:54 ` sashiko-bot
2026-10-03 19:43 ` [PATCH v3 bpf-next 7/7] selftests/bpf: Add a test verifying inline information Alan Maguire
2026-10-03 19:54 ` sashiko-bot [this message]
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=20261003195427.E25CA1F0089C@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=petr.pavlu@suse.com \
--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