From: Jiri Olsa <jolsa@kernel.org>
To: Oleg Nesterov <oleg@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org, x86@kernel.org,
"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"Hao Luo" <haoluo@google.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Alan Maguire" <alan.maguire@oracle.com>,
"David Laight" <David.Laight@ACULAB.COM>,
"Thomas Weißschuh" <thomas@t-8ch.de>,
"Ingo Molnar" <mingo@kernel.org>
Subject: [PATCH] selftests/bpf: Fix uprobe syscall shadow stack test
Date: Thu, 21 Aug 2025 16:15:57 +0200 [thread overview]
Message-ID: <20250821141557.13233-1-jolsa@kernel.org> (raw)
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>
---
sending fix for changes posted in here [1]
[1] https://lore.kernel.org/bpf/20250821122822.671515652@infradead.org/T/#m571d8b1975e1f4ade55aa972940d8568647ac113
.../selftests/bpf/prog_tests/uprobe_syscall.c | 24 +++++--------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c
index c1f945cacebc..5da0b49eeaca 100644
--- a/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c
+++ b/tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c
@@ -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);
}
--
2.50.1
reply other threads:[~2025-08-21 14:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250821141557.13233-1-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=David.Laight@ACULAB.COM \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=thomas@t-8ch.de \
--cc=x86@kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).