From: sashiko-bot@kernel.org
To: "Geyslan Gregório" <gg@condado.dev>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 3/3] selftests/bpf: Test weak typed ksyms without vmlinux BTF
Date: Sat, 05 Dec 2026 21:40:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-251915@kernel.org> (raw)
In-Reply-To: <20261205-libbpf-weak-typed-ksyms-no-vmlinux-btf-v1-3-77cc642f7d4b@condado.dev>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] selftests/bpf: multi-line comment style in
weak_syms_no_vmlinux_btf()
- [Low] selftests/bpf: weak_syms_no_vmlinux_btf() fails on missing
/sys/kernel/btf
- [Low] selftests/bpf: ineffective out__typeless check in
weak_syms_no_vmlinux_btf()
--
commit 5bb212acbecdd5b5802324ccf479855425cb6236
Author: Geyslan Gregório <gg@condado.dev>
selftests/bpf: Test weak typed ksyms without vmlinux BTF
This commit adds a BPF selftest subtest that hides /sys/kernel/btf in a child
mount namespace to verify that objects with only weak typed ksyms load and
run using btf_custom_path, while an object with a strong typed ksym fails to
load with -ESRCH.
> diff --git a/tools/testing/selftests/bpf/prog_tests/ksyms_btf.c b/tools/testing/selftests/bpf/prog_tests/ksyms_btf.c
> index 1bc3089f10fca..d64bb2d7a3223 100644
> --- a/tools/testing/selftests/bpf/prog_tests/ksyms_btf.c
> +++ b/tools/testing/selftests/bpf/prog_tests/ksyms_btf.c
[ ... ]
> @@ -139,6 +145,135 @@ static void test_weak_syms_lskel(void)
[ ... ]
> +/* Runs in a child, in a mount namespace of its own: with /sys/kernel/btf
> + * hidden, libbpf finds no kernel BTF, as on a kernel built without it.
> + */
> +static int weak_syms_no_vmlinux_btf(const char *btf_file)
[Severity: Low]
BPF code uses the multi-line comment style with the opening /* on its own
line and the text starting on the next line. The comment above
bpf_prog_test_run_opts() in this same function uses the old style as well.
[ ... ]
> + if (unshare(CLONE_NEWNS) ||
> + mount("", "/", "", MS_REC | MS_PRIVATE, NULL) ||
> + mount("none", "/sys/kernel/btf", "tmpfs", 0, NULL))
> + return NO_BTF_SETUP;
> +
> + /* libbpf also takes kernel BTF from a vmlinux image, if it finds one */
> + btf = btf__load_vmlinux_btf();
> + if (!libbpf_get_error(btf)) {
> + btf__free(btf);
> + return NO_BTF_SKIP;
> + }
[Severity: Low]
Can mount() fail with ENOENT here when /sys/kernel/btf is absent?
When sysfs is not mounted, btf__load_vmlinux_btf() in the parent still
succeeds if a fallback vmlinux image with BTF exists in /boot or
/lib/modules. The child then returns NO_BTF_SETUP and fails the subtest
instead of reaching the check below and skipping with NO_BTF_SKIP.
Ignoring ENOENT on the /sys/kernel/btf mount would treat it as already hidden
and let the subtest reach the skip check.
[ ... ]
> + if (skel->data->out__typed_var != 0)
> + ret = NO_BTF_TYPED_VAR;
> + else if (skel->data->out__typeless == -1)
> + ret = NO_BTF_TYPELESS;
[Severity: Low]
Can the out__typeless == -1 branch ever trigger?
If handler() never ran, out__typed_var is still -1 and triggers first. Once
handler() runs, it overwrites out__typeless with either the resolved address
or 0 because bpf_prog_active is __weak in test_ksyms_weak_no_btf.c, so this
passes even when /proc/kallsyms resolution fails.
Comparing out__typeless against kallsyms_find("bpf_prog_active", &addr) as
test_basic() does, or dropping __weak from bpf_prog_active, would check
kallsyms resolution.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-libbpf-weak-typed-ksyms-no-vmlinux-btf-v1-0-77cc642f7d4b@condado.dev?part=3
prev parent reply other threads:[~2026-12-05 21:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 21:28 [PATCH bpf-next 0/3] libbpf: Load objects with weak typed ksyms on kernels without BTF Geyslan Gregório
2026-12-05 21:28 ` Geyslan Gregório via B4 Relay
2026-12-05 21:28 ` [PATCH bpf-next 1/3] libbpf: Do not resolve typed ksyms through kallsyms Geyslan Gregório
2026-12-05 21:28 ` Geyslan Gregório via B4 Relay
2026-12-05 21:33 ` sashiko-bot
2026-12-05 21:28 ` [PATCH bpf-next 2/3] libbpf: Load objects with weak typed ksyms on kernels without BTF Geyslan Gregório
2026-12-05 21:28 ` Geyslan Gregório via B4 Relay
2026-12-05 21:36 ` sashiko-bot
2026-12-05 21:28 ` [PATCH bpf-next 3/3] selftests/bpf: Test weak typed ksyms without vmlinux BTF Geyslan Gregório
2026-12-05 21:28 ` Geyslan Gregório via B4 Relay
2026-12-05 21:40 ` 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=sashiko-outbox-251915@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=gg@condado.dev \
--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.