[PATCH v2 0/2] selftests/bpf: make probe_user safe for parallel runs

Sun Jian
2026-02-26T09:31:48Z

The probe_user selftest attaches ksyscall hooks for connect() (and
socketcall() on s390). Historically it could corrupt other tests
calling connect() in parallel, causing flaky failures.

This series confines the instrumentation to the current test process only,
and then drops the serial restriction and removes the stale TODO.

v1: <https://lore.kernel.org/all/cover.1772079741.git.sun.jian.kdev@gmail.com/>

Changes in v2:
- Replace pid_map with a global .bss struct initialized via
bpf_map__set_initial_value() before bpf_object__load().
- Add bpf_map__value_size() check for the .bss map to catch
layout mismatch.
- Move PID filtering into handle_sys_connect_common() (covers both
connect() and s390 socketcall() paths).
- Keep existing validation flow intact (bridge via tmp buffer).

Tested:
- cd .kselftest-out/selftests-bpf
./test_progs -t probe_user -v
- cd .kselftest-out/selftests-bpf
./test_progs -j"$(nproc)" -t probe_user -v

Sun Jian (2):
selftests/bpf: probe_user: filter by pid to avoid cross-test
interference
selftests/bpf: probe_user: drop serial restriction

.../selftests/bpf/prog_tests/probe_user.c | 30 +++++++++++++++++--
.../selftests/bpf/progs/test_probe_user.c | 13 ++++++--
2 files changed, 38 insertions(+), 5 deletions(-)

base-commit: 7dff99b354601dd01829e1511711846e04340a69
--
2.43.0