perf_event_open() without caps fails with EACCES on some kernels. With this fix, the shadow stack selftest passes without privileges on a kernel with a RHEL-like config.
Signed-off-by: Richard Patel <[email protected]> --- tools/testing/selftests/x86/test_shadow_stack.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/x86/test_shadow_stack.c b/tools/testing/selftests/x86/test_shadow_stack.c index 67baebbdbd87..e2340232a7b6 100644 --- a/tools/testing/selftests/x86/test_shadow_stack.c +++ b/tools/testing/selftests/x86/test_shadow_stack.c @@ -952,8 +952,11 @@ static int test_uretprobe(void) fd = syscall(__NR_perf_event_open, &attr, 0 /* pid */, -1 /* cpu */, -1 /* group_fd */, PERF_FLAG_FD_CLOEXEC); - if (fd < 0) + if (fd < 0) { + printf("[SKIP]\tUretprobe test, perf_event_open() failed: %m\n"); + err = 0; goto out; + } if (sigsetjmp(jmp_buffer, 1)) goto out; @@ -1031,8 +1034,11 @@ static int test_uprobe_call(void) fd = syscall(__NR_perf_event_open, &attr, 0 /* pid */, -1 /* cpu */, -1 /* group_fd */, PERF_FLAG_FD_CLOEXEC); - if (fd < 0) + if (fd < 0) { + printf("[SKIP]\tUprobe on CALL test, perf_event_open() failed: %m\n"); + err = 0; goto out; + } if (sigsetjmp(jmp_buffer, 1)) goto out; -- 2.52.0

