> selftests/bpf: Test faulting build IDs from a sleepable raw tracepoint
TL;DR:
- Test issue: raise() may call getpid again, so the BPF programs may overwrite
the stack the test inspects; results may depend on libc
- Nit: usage message omits the new uprobe-paged-out-stop mode
> diff --git a/tools/testing/selftests/bpf/uprobe_multi.c
> b/tools/testing/selftests/bpf/uprobe_multi.c
> --- a/tools/testing/selftests/bpf/uprobe_multi.c
> +++ b/tools/testing/selftests/bpf/uprobe_multi.c
[ ... ]
> +int __attribute__((weak)) trigger_stop(void)
> +{
> + int err = prep_build_id_page(false /* page-out build ID */);
> +
> + if (err)
> + return err;
> +
> + /*
> + * Make one syscall that the BPF program under test filters on, then
> + * stop this process so that the recorded stack cannot be overwritten
> + * by another syscall while the caller inspects it.
> + */
> + (void)syscall(SYS_getpid);
> + raise(SIGSTOP);
With glibc, raise() goes through pthread_kill() which calls __getpid() to
get the tgid for tgkill(). So rawtp_nofault and rawtp_sleepable can match
a second time on id == SYS_getpid, from inside raise(), before SIGSTOP
takes effect.
That second match overwrites stack_rawtp_* and res_rawtp_*, so the stack
that subtest_raw_tp() inspects comes from the getpid stub called by
__pthread_kill_implementation(), not from the explicit syscall(SYS_getpid).
In the sleepable case, that stack is also captured after the first match
has already faulted the build ID page back in.
Whether a uprobe_multi frame shows up then depends on how libc compiles
raise()/pthread_kill().
Could the BPF programs keep only the first match, for example by returning
early once res_rawtp_* is non-zero? Or could the comment and commit
message mention that raise() issues a matching getpid() as well?
[ ... ]
> + if (!strcmp("uprobe-paged-out-stop", argv[1]))
> + return trigger_stop();
>
> error:
> fprintf(stderr,
This isn't a bug, but main() now accepts "uprobe-paged-out-stop" while the
usage message that follows still lists only
<bench|usdt|uprobe-paged-out|uprobe-paged-in>. Should the new mode be
added there?
---
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/41802507259