Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Fix uprobe syscall shadow stack test

Now that we have uprobe syscall working properly with shadow stack,
we can remove testing limitations for shadow stack tests and make
sure uprobe gets properly optimized.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250821141557.13233-1-jolsa@kernel.org

authored by

Jiri Olsa and committed by
Peter Zijlstra
52718438 3abf4298

+6 -18
+6 -18
tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c
··· 403 403 404 404 typedef void (__attribute__((nocf_check)) *trigger_t)(void); 405 405 406 - static bool shstk_is_enabled; 407 - 408 406 static void *check_attach(struct uprobe_syscall_executed *skel, trigger_t trigger, 409 407 void *addr, int executed) 410 408 { ··· 411 413 __s32 raddr; 412 414 } __packed *call; 413 415 void *tramp = NULL; 414 - __u8 *bp; 415 416 416 417 /* Uprobe gets optimized after first trigger, so let's press twice. */ 417 418 trigger(); ··· 419 422 /* Make sure bpf program got executed.. */ 420 423 ASSERT_EQ(skel->bss->executed, executed, "executed"); 421 424 422 - if (shstk_is_enabled) { 423 - /* .. and check optimization is disabled under shadow stack. */ 424 - bp = (__u8 *) addr; 425 - ASSERT_EQ(*bp, 0xcc, "int3"); 426 - } else { 427 - /* .. and check the trampoline is as expected. */ 428 - call = (struct __arch_relative_insn *) addr; 429 - tramp = (void *) (call + 1) + call->raddr; 430 - ASSERT_EQ(call->op, 0xe8, "call"); 431 - ASSERT_OK(find_uprobes_trampoline(tramp), "uprobes_trampoline"); 432 - } 425 + /* .. and check the trampoline is as expected. */ 426 + call = (struct __arch_relative_insn *) addr; 427 + tramp = (void *) (call + 1) + call->raddr; 428 + ASSERT_EQ(call->op, 0xe8, "call"); 429 + ASSERT_OK(find_uprobes_trampoline(tramp), "uprobes_trampoline"); 433 430 434 431 return tramp; 435 432 } ··· 431 440 static void check_detach(void *addr, void *tramp) 432 441 { 433 442 /* [uprobes_trampoline] stays after detach */ 434 - ASSERT_OK(!shstk_is_enabled && find_uprobes_trampoline(tramp), "uprobes_trampoline"); 443 + ASSERT_OK(find_uprobes_trampoline(tramp), "uprobes_trampoline"); 435 444 ASSERT_OK(memcmp(addr, nop5, 5), "nop5"); 436 445 } 437 446 ··· 633 642 } 634 643 635 644 /* Run all the tests with shadow stack in place. */ 636 - shstk_is_enabled = true; 637 645 638 646 test_uprobe_regs_equal(false); 639 647 test_uprobe_regs_equal(true); ··· 644 654 test_uprobe_usdt(); 645 655 646 656 test_regs_change(); 647 - 648 - shstk_is_enabled = false; 649 657 650 658 ARCH_PRCTL(ARCH_SHSTK_DISABLE, ARCH_SHSTK_SHSTK); 651 659 }