On Tue, May 26, 2026 at 09:46:38PM +0000, [email protected] wrote:
SNIP
> > 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:
find_instr is ok for its usage in subtest_optimized_attach,
we first use it to verify the combo was not generated in usdt_1,
and having 128 bytes search we'd find combo from usdt_2 function
modern compilers seems to be smart emough not to generate long
prologue for usdt_2 function
jirka