From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v2 2/2] selftests/bpf: Add test for usdt probe with page-crossing nop10
Date: Tue, 25 Aug 2026 23:24:37 +0800 [thread overview]
Message-ID: <99716abe-9b40-42ac-88a5-e26324a97397@linux.dev> (raw)
In-Reply-To: <20260825151342.F3A601F000E9@smtp.kernel.org>
On 8/25/26 11:13 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The search loop limit `2 * page_sz` for locating the USDT probe can cause the test to falsely fail if the compiler generates a prologue of 11 bytes or larger.
> --
>
> --- Patch [2]: [PATCH bpf v2 2/2] selftests/bpf: Add test for usdt probe with page-crossing nop10 ---
> commit 3ab03ec0febc59ef7c61c7f1449047ef827d5e7b
> Author: Jiayuan Chen <jiayuan.chen@linux.dev>
>
> selftests/bpf: Add test for usdt probe with page-crossing nop10
>
> This commit adds a USDT probe layout where the nop10 crosses a page boundary.
> It verifies that attaching to it succeeds and the probe fires without the
> uprobe being shifted onto the nop10 incorrectly.
>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/usdt.c b/tools/testing/selftests/bpf/prog_tests/usdt.c
>> index 8004c9568ffa5..eff1e57ab13c0 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/usdt.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/usdt.c
> [ ... ]
>> @@ -342,6 +343,57 @@ static void subtest_optimized_attach(void)
>> test_usdt__destroy(skel);
>> }
>>
>> +/*
>> + * Test attachment to a USDT probe whose nop10 crosses a page boundary.
>> + * The kernel can't optimize such nop10, so libbpf keeps the uprobe on
>> + * the preceding 1-byte nop. Do not assume any particular placement
>> + * here, though: however the probe ends up attached, the attachment
>> + * must succeed and the probe must fire.
>> + */
>> +static void subtest_optimized_attach_cross_page(void)
>> +{
>> + long page_sz = sysconf(_SC_PAGESIZE);
>> + struct test_usdt *skel;
>> + __u8 *addr = NULL;
>> + long i;
>> +
>> + /* combo is placed up to a page of padding after the function start */
>> + for (i = 0; i < 2 * page_sz; i++) {
> [Severity: Medium]
> Will this loop bound of 2 * page_sz (8192) cause the test to falsely fail on
> builds with larger compiler prologues (like ASAN builds or those with frame
> pointers enabled)?
>
> If the compiler generates a prologue of size P, the offset to the probe is
> P + align_padding (up to 4095) + skip_padding (4086) = P + 8181.
>
> If P is 11 bytes or larger, the offset reaches 8192, which would exceed
> this i < 2 * page_sz search bound and cause a spurious ASSERT_OK_PTR
> failure.
I got such review locally, but I want to say that if such a compiler
existed, the existing tests would break before
this one: find_instr() in subtest_optimized_attach() only scans 10 bytes
past the function start.
>> + if (!memcmp((void *)usdt_2_cross_page + i, nop1_nop10_combo, 11)) {
>> + addr = (void *)usdt_2_cross_page + i;
>> + break;
>> + }
>> + }
>> + if (!ASSERT_OK_PTR(addr, "find_nop1_nop10_combo"))
>> + return;
next prev parent reply other threads:[~2026-08-25 15:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 15:04 [PATCH bpf v2 1/2] libbpf: Fix usdt attach failure when nop10 crosses page boundary Jiayuan Chen
2026-08-25 15:04 ` [PATCH bpf v2 2/2] selftests/bpf: Add test for usdt probe with page-crossing nop10 Jiayuan Chen
2026-08-25 15:13 ` sashiko-bot
2026-08-25 15:24 ` Jiayuan Chen [this message]
2026-08-25 18:39 ` [PATCH bpf v2 1/2] libbpf: Fix usdt attach failure when nop10 crosses page boundary Andrii Nakryiko
2026-08-25 22:08 ` patchwork-bot+netdevbpf
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=99716abe-9b40-42ac-88a5-e26324a97397@linux.dev \
--to=jiayuan.chen@linux.dev \
--cc=bpf@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.