From: Jiri Olsa <jolsa@kernel.org>
To: Oleg Nesterov <oleg@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: [PATCHv8 bpf-next 09/13] selftests/bpf: Add uprobe session verifier test for return value
Date: Fri, 18 Oct 2024 22:41:05 +0200 [thread overview]
Message-ID: <20241018204109.713820-10-jolsa@kernel.org> (raw)
In-Reply-To: <20241018204109.713820-1-jolsa@kernel.org>
Making sure uprobe.session program can return only [0,1] values.
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
.../bpf/prog_tests/uprobe_multi_test.c | 2 ++
.../bpf/progs/uprobe_multi_verifier.c | 31 +++++++++++++++++++
2 files changed, 33 insertions(+)
create mode 100644 tools/testing/selftests/bpf/progs/uprobe_multi_verifier.c
diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
index 284cd7fce576..e693eeb1a5a5 100644
--- a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
+++ b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c
@@ -11,6 +11,7 @@
#include "uprobe_multi_session.skel.h"
#include "uprobe_multi_session_cookie.skel.h"
#include "uprobe_multi_session_recursive.skel.h"
+#include "uprobe_multi_verifier.skel.h"
#include "bpf/libbpf_internal.h"
#include "testing_helpers.h"
#include "../sdt.h"
@@ -1246,4 +1247,5 @@ void test_uprobe_multi_test(void)
test_session_cookie_skel_api();
if (test__start_subtest("session_cookie_recursive"))
test_session_recursive_skel_api();
+ RUN_TESTS(uprobe_multi_verifier);
}
diff --git a/tools/testing/selftests/bpf/progs/uprobe_multi_verifier.c b/tools/testing/selftests/bpf/progs/uprobe_multi_verifier.c
new file mode 100644
index 000000000000..fe49f2cb5360
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/uprobe_multi_verifier.c
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "vmlinux.h"
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+#include <bpf/usdt.bpf.h>
+#include "bpf_misc.h"
+
+char _license[] SEC("license") = "GPL";
+
+
+SEC("uprobe.session")
+__success
+int uprobe_sesison_return_0(struct pt_regs *ctx)
+{
+ return 0;
+}
+
+SEC("uprobe.session")
+__success
+int uprobe_sesison_return_1(struct pt_regs *ctx)
+{
+ return 1;
+}
+
+SEC("uprobe.session")
+__failure
+__msg("At program exit the register R0 has smin=2 smax=2 should have been in [0, 1]")
+int uprobe_sesison_return_2(struct pt_regs *ctx)
+{
+ return 2;
+}
--
2.46.2
next prev parent reply other threads:[~2024-10-18 20:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 20:40 [PATCHv8 bpf-next 00/13] bpf: Add uprobe session support Jiri Olsa
2024-10-18 20:40 ` [PATCHv8 bpf-next 01/13] bpf: Allow return values 0 and 1 for kprobe session Jiri Olsa
2024-10-18 20:40 ` [PATCHv8 bpf-next 02/13] bpf: Force uprobe bpf program to always return 0 Jiri Olsa
2024-10-18 20:40 ` [PATCHv8 bpf-next 03/13] bpf: Add support for uprobe multi session attach Jiri Olsa
2024-10-18 20:41 ` [PATCHv8 bpf-next 04/13] bpf: Add support for uprobe multi session context Jiri Olsa
2024-10-18 20:41 ` [PATCHv8 bpf-next 05/13] libbpf: Add support for uprobe multi session attach Jiri Olsa
2024-10-18 20:41 ` [PATCHv8 bpf-next 06/13] selftests/bpf: Add uprobe session test Jiri Olsa
2024-10-18 20:41 ` [PATCHv8 bpf-next 07/13] selftests/bpf: Add uprobe session cookie test Jiri Olsa
2024-10-18 20:41 ` [PATCHv8 bpf-next 08/13] selftests/bpf: Add uprobe session recursive test Jiri Olsa
2024-10-18 20:41 ` Jiri Olsa [this message]
2024-10-18 20:41 ` [PATCHv8 bpf-next 10/13] selftests/bpf: Add kprobe session verifier test for return value Jiri Olsa
2024-10-18 20:41 ` [PATCHv8 bpf-next 11/13] selftests/bpf: Add uprobe session single consumer test Jiri Olsa
2024-10-18 20:41 ` [PATCHv8 bpf-next 12/13] selftests/bpf: Add uprobe sessions to " Jiri Olsa
2024-10-18 20:41 ` [PATCHv8 bpf-next 13/13] selftests/bpf: Add threads " Jiri Olsa
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=20241018204109.713820-10-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sdf@fomichev.me \
--cc=songliubraving@fb.com \
--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).