]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/bpf: Fix uprobe syscall shadow stack test
authorJiri Olsa <jolsa@kernel.org>
Thu, 21 Aug 2025 14:15:57 +0000 (16:15 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 21 Aug 2025 18:09:25 +0000 (20:09 +0200)
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
tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c

index c1f945cacebc2741e8949efefe3faae8fc6f4227..5da0b49eeacaed848fcf834d295f23a0ba3a54ca 100644 (file)
@@ -403,8 +403,6 @@ static void *find_nop5(void *fn)
 
 typedef void (__attribute__((nocf_check)) *trigger_t)(void);
 
-static bool shstk_is_enabled;
-
 static void *check_attach(struct uprobe_syscall_executed *skel, trigger_t trigger,
                          void *addr, int executed)
 {
@@ -413,7 +411,6 @@ static void *check_attach(struct uprobe_syscall_executed *skel, trigger_t trigge
                __s32 raddr;
        } __packed *call;
        void *tramp = NULL;
-       __u8 *bp;
 
        /* Uprobe gets optimized after first trigger, so let's press twice. */
        trigger();
@@ -422,17 +419,11 @@ static void *check_attach(struct uprobe_syscall_executed *skel, trigger_t trigge
        /* Make sure bpf program got executed.. */
        ASSERT_EQ(skel->bss->executed, executed, "executed");
 
-       if (shstk_is_enabled) {
-               /* .. and check optimization is disabled under shadow stack. */
-               bp = (__u8 *) addr;
-               ASSERT_EQ(*bp, 0xcc, "int3");
-       } else {
-               /* .. and check the trampoline is as expected. */
-               call = (struct __arch_relative_insn *) addr;
-               tramp = (void *) (call + 1) + call->raddr;
-               ASSERT_EQ(call->op, 0xe8, "call");
-               ASSERT_OK(find_uprobes_trampoline(tramp), "uprobes_trampoline");
-       }
+       /* .. and check the trampoline is as expected. */
+       call = (struct __arch_relative_insn *) addr;
+       tramp = (void *) (call + 1) + call->raddr;
+       ASSERT_EQ(call->op, 0xe8, "call");
+       ASSERT_OK(find_uprobes_trampoline(tramp), "uprobes_trampoline");
 
        return tramp;
 }
@@ -440,7 +431,7 @@ static void *check_attach(struct uprobe_syscall_executed *skel, trigger_t trigge
 static void check_detach(void *addr, void *tramp)
 {
        /* [uprobes_trampoline] stays after detach */
-       ASSERT_OK(!shstk_is_enabled && find_uprobes_trampoline(tramp), "uprobes_trampoline");
+       ASSERT_OK(find_uprobes_trampoline(tramp), "uprobes_trampoline");
        ASSERT_OK(memcmp(addr, nop5, 5), "nop5");
 }
 
@@ -642,7 +633,6 @@ static void test_uretprobe_shadow_stack(void)
        }
 
        /* Run all the tests with shadow stack in place. */
-       shstk_is_enabled = true;
 
        test_uprobe_regs_equal(false);
        test_uprobe_regs_equal(true);
@@ -655,8 +645,6 @@ static void test_uretprobe_shadow_stack(void)
 
        test_regs_change();
 
-       shstk_is_enabled = false;
-
        ARCH_PRCTL(ARCH_SHSTK_DISABLE, ARCH_SHSTK_SHSTK);
 }