From: sashiko-bot@kernel.org
To: "Ricardo B. Marlière" <rbm@suse.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v9 10/11] selftests/bpf: Provide weak definitions for cross-test functions
Date: Wed, 29 Apr 2026 21:29:29 +0000 [thread overview]
Message-ID: <20260429212931.44DD4C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260429-selftests-bpf_misconfig-v9-10-c311f06b4791@suse.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Test flakiness and deterministic failure due to Identical Code Folding (ICF) of weak stubs.
- [Low] Missing `<alloca.h>` include for `alloca()` in `testing_helpers.c`.
--
commit 45cfa2851c72a65543e44de19ed32088ef920e33
Author: Ricardo B. Marlière <rbm@suse.com>
selftests/bpf: Provide weak definitions for cross-test functions
This commit replaces forward declarations of uprobe_multi_func_{1,2,3}() with
weak no-op stubs to allow the linker to resolve them when skeletons are
missing. It also moves stack_mprotect() to testing_helpers.c to make it
universally available and resolve an issue where the previous weak stub
returned 0.
> diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
> index 35adc3f6d443..5a864cd8ad1b 100644
> --- a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
> +++ b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c
[ ... ]
> -/* defined in prog_tests/uprobe_multi_test.c */
> -void uprobe_multi_func_1(void);
> -void uprobe_multi_func_2(void);
> -void uprobe_multi_func_3(void);
> +/*
> + * Weak uprobe target stubs. noinline is required because
> + * uprobe_multi_test_run() takes their addresses to configure the BPF
> + * program's attachment points; an inlined function has no stable
> + * address in the binary to probe. The strong definitions in
> + * uprobe_multi_test.c take precedence when that translation unit is
> + * linked.
> + */
> +noinline __weak void uprobe_multi_func_1(void) {}
> +noinline __weak void uprobe_multi_func_2(void) {}
> +noinline __weak void uprobe_multi_func_3(void) {}
Because these three weak stubs are structurally identical empty functions,
can compiler and linker optimization passes like Identical Code Folding
(ICF) merge them into a single memory address?
If they are folded into a single address, bpf_program__attach_uprobe_multi()
will attach three separate uprobes to the exact same offset, each with a
different cookie.
Calling any of the functions would then execute the shared address,
triggering all three uprobes simultaneously. This would increment the BPF
program counters multiple times per call, causing assertions like:
ASSERT_EQ(skel->bss->uprobe_multi_func_1_result, 1, ...);
to fail deterministically, as the result would be 3 instead of 1.
Would it make sense to make these stubs structurally unique, perhaps by
adding unique inline assembly to each?
[ ... ]
> diff --git a/tools/testing/selftests/bpf/testing_helpers.c b/tools/testing/selftests/bpf/testing_helpers.c
> index 6fbe1e995660..3f7ae76c209b 100644
> --- a/tools/testing/selftests/bpf/testing_helpers.c
> +++ b/tools/testing/selftests/bpf/testing_helpers.c
[ ... ]
> +int stack_mprotect(void)
> +{
> + void *buf;
> + long sz;
> + int ret;
> +
> + sz = sysconf(_SC_PAGESIZE);
> + if (sz < 0)
> + return sz;
> +
> + buf = alloca(sz * 3);
Does this code rely on a glibc-specific extension to provide alloca() via
<stdlib.h>?
The original implementation in test_lsm.c included <malloc.h>, but the new
location in testing_helpers.c includes neither <malloc.h> nor <alloca.h>.
On systems with strict POSIX-compliant C libraries, such as musl, omitting
<alloca.h> can result in an implicit function declaration error and lead
to build failures.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260429-selftests-bpf_misconfig-v9-0-c311f06b4791@suse.com?part=10
next prev parent reply other threads:[~2026-04-29 21:29 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 14:33 [PATCH bpf-next v9 00/11] selftests/bpf: Tolerate partial builds across kernel configs Ricardo B. Marlière
2026-04-29 14:33 ` [PATCH bpf-next v9 01/11] selftests/bpf: Add BPF_STRICT_BUILD toggle Ricardo B. Marlière
2026-04-29 15:13 ` bot+bpf-ci
2026-04-29 16:03 ` Ricardo B. Marlière
2026-04-29 14:33 ` [PATCH bpf-next v9 02/11] selftests/bpf: Fix test_kmods KDIR to honor O= and distro kernels Ricardo B. Marlière
2026-04-29 19:41 ` sashiko-bot
2026-04-29 14:33 ` [PATCH bpf-next v9 03/11] selftests/bpf: Tolerate BPF and skeleton generation failures Ricardo B. Marlière
2026-04-29 15:13 ` bot+bpf-ci
2026-04-29 16:03 ` Ricardo B. Marlière
2026-04-29 14:33 ` [PATCH bpf-next v9 04/11] selftests/bpf: Avoid rebuilds when running emit_tests Ricardo B. Marlière
2026-04-29 14:33 ` [PATCH bpf-next v9 05/11] selftests/bpf: Make skeleton headers order-only prerequisites of .test.d Ricardo B. Marlière
2026-04-29 20:23 ` sashiko-bot
2026-04-29 14:33 ` [PATCH bpf-next v9 06/11] selftests/bpf: Tolerate test file compilation failures Ricardo B. Marlière
2026-04-29 20:37 ` sashiko-bot
2026-04-29 14:33 ` [PATCH bpf-next v9 07/11] selftests/bpf: Skip tests whose objects were not built Ricardo B. Marlière
2026-04-29 14:33 ` [PATCH bpf-next v9 08/11] selftests/bpf: Allow test_progs to link with a partial object set Ricardo B. Marlière
2026-04-29 14:33 ` [PATCH bpf-next v9 09/11] selftests/bpf: Tolerate benchmark build failures Ricardo B. Marlière
2026-04-29 21:08 ` sashiko-bot
2026-04-29 14:33 ` [PATCH bpf-next v9 10/11] selftests/bpf: Provide weak definitions for cross-test functions Ricardo B. Marlière
2026-04-29 21:29 ` sashiko-bot [this message]
2026-04-29 14:33 ` [PATCH bpf-next v9 11/11] selftests/bpf: Tolerate missing files during install Ricardo B. Marlière
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=20260429212931.44DD4C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=rbm@suse.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox