> diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c 
> b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c
> index c944136252c6..0868fb9793e0 100644
> --- a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c
> +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c

[ ... ]

> @@ -388,14 +388,15 @@ static int find_uprobes_trampoline(void *tramp_addr)
>       return ret;
>  }
>
> -static unsigned char nop5[5] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 };
> +static unsigned char nop10[10]  = { 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 
> 0x00, 0x00, 0x00, 0x00 };
> +static unsigned char lea_rsp[5] = { 0x48, 0x8d, 0x64, 0x24, 0x80 };
>
> -static void *find_nop5(void *fn)
> +static void *find_nop10(void *fn)
>  {
>       int i;
>
> -     for (i = 0; i < 10; i++) {
> -             if (!memcmp(nop5, fn + i, 5))
> +     for (i = 0; i < 128; i++) {
> +             if (!memcmp(nop10, fn + i, 10))
>                       return fn + i;
>       }
>       return NULL;

[ ... ]

> diff --git a/tools/testing/selftests/bpf/prog_tests/usdt.c 
> b/tools/testing/selftests/bpf/prog_tests/usdt.c
> index 69759b27794d..fda3a298ccfc 100644
> --- a/tools/testing/selftests/bpf/prog_tests/usdt.c
> +++ b/tools/testing/selftests/bpf/prog_tests/usdt.c
> @@ -252,7 +252,7 @@ extern void usdt_1(void);
>  extern void usdt_2(void);
>
>  static unsigned char nop1[1] = { 0x90 };
> -static unsigned char nop1_nop5_combo[6] = { 0x90, 0x0f, 0x1f, 0x44, 0x00, 
> 0x00 };
> +static unsigned char nop1_nop10_combo[11] = { 0x90, 0x66, 0x2e, 0x0f, 0x1f, 
> 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 };
>
>  static void *find_instr(void *fn, unsigned char *instr, size_t cnt)
>  {

Is the loop in find_instr() adequate to find the updated instruction
sequence? In uprobe_syscall.c, find_nop10() was updated to search up
to 128 bytes to account for compiler-generated prologues:

tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c:find_nop10() {
        for (i = 0; i < 128; i++) {
                if (!memcmp(nop10, fn + i, 10))
                        return fn + i;
        }
}

But find_instr() in usdt.c only searches the first 10 bytes:

tools/testing/selftests/bpf/prog_tests/usdt.c:find_instr() {
        for (i = 0; i < 10; i++) {
                if (!memcmp(instr, fn + i, cnt))
                        return fn + i;
        }
}

If a modern compiler generates a prologue longer than 9 bytes for
usdt_2(), find_instr() will prematurely terminate and cause
subtest_optimized_attach() to fail. This concern was raised by
reviewers in v2 and v3 of the patch series:

  https://lore.kernel.org/bpf/[email protected]/

The author acknowledged this with "yea find_instr needs same update,
will fix" but the loop bound remains 10 in the current v4 patch.

> @@ -271,17 +271,17 @@ static void subtest_optimized_attach(void)
>       __u8 *addr_1, *addr_2;
>
>       /* usdt_1 USDT probe has single nop instruction */
> -     addr_1 = find_instr(usdt_1, nop1_nop5_combo, 6);
> -     if (!ASSERT_NULL(addr_1, "usdt_1_find_nop1_nop5_combo"))
> +     addr_1 = find_instr(usdt_1, nop1_nop10_combo, 11);
> +     if (!ASSERT_NULL(addr_1, "usdt_1_find_nop1_nop10_combo"))
>               return;
>
>       addr_1 = find_instr(usdt_1, nop1, 1);
>       if (!ASSERT_OK_PTR(addr_1, "usdt_1_find_nop1"))
>               return;
>
> -     /* usdt_2 USDT probe has nop,nop5 instructions combo */
> -     addr_2 = find_instr(usdt_2, nop1_nop5_combo, 6);
> -     if (!ASSERT_OK_PTR(addr_2, "usdt_2_find_nop1_nop5_combo"))
> +     /* usdt_2 USDT probe has nop,nop10 instructions combo */
> +     addr_2 = find_instr(usdt_2, nop1_nop10_combo, 11);
> +     if (!ASSERT_OK_PTR(addr_2, "usdt_2_find_nop1_nop10_combo"))
>               return;

[ ... ]


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/26475828601

Reply via email to