lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250917072242.674528-4-zhaofuyu@vivo.com>
Date: Wed, 17 Sep 2025 15:22:42 +0800
From: Fuyu Zhao <zhaofuyu@...o.com>
To: ast@...nel.org,
	daniel@...earbox.net,
	andrii@...nel.org,
	martin.lau@...ux.dev,
	song@...nel.org,
	yonghong.song@...ux.dev,
	haoluo@...gle.com,
	jolsa@...nel.org,
	eddyz87@...il.com,
	kpsingh@...nel.org,
	sdf@...ichev.me,
	rostedt@...dmis.org,
	mhiramat@...nel.org,
	mathieu.desnoyers@...icios.com,
	shuah@...nel.org,
	willemb@...gle.com,
	kerneljasonxing@...il.com,
	paul.chaignon@...il.com,
	chen.dylane@...ux.dev,
	memxor@...il.com,
	martin.kelly@...wdstrike.com,
	zhaofuyu@...o.com,
	ameryhung@...il.com,
	linux-kernel@...r.kernel.org,
	bpf@...r.kernel.org,
	linux-trace-kernel@...r.kernel.org,
	linux-kselftest@...r.kernel.org
Cc: yikai.lin@...o.com
Subject: [RFC PATCH bpf-next v1 3/3] selftests/bpf: Add selftest for "raw_tp.o"

Add test for the new BPF_PROG_TYPE_RAW_TRACEPOINT_OVERRIDE program type.
This test verifies whether a BPF program can successfully override the
target tracepoint probe function.

Signed-off-by: Fuyu Zhao <zhaofuyu@...o.com>
---
 .../bpf/prog_tests/raw_tp_override_test_run.c | 23 +++++++++++++++++++
 .../bpf/progs/test_raw_tp_override_test_run.c | 20 ++++++++++++++++
 .../selftests/bpf/test_kmods/bpf_testmod.c    |  7 ++++++
 3 files changed, 50 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/raw_tp_override_test_run.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_raw_tp_override_test_run.c

diff --git a/tools/testing/selftests/bpf/prog_tests/raw_tp_override_test_run.c b/tools/testing/selftests/bpf/prog_tests/raw_tp_override_test_run.c
new file mode 100644
index 000000000000..02301253cd9b
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/raw_tp_override_test_run.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <test_progs.h>
+#include "bpf/libbpf_internal.h"
+#include "test_raw_tp_override_test_run.skel.h"
+
+void test_raw_tp_override_test_run(void)
+{
+	struct test_raw_tp_override_test_run *skel;
+
+	skel = test_raw_tp_override_test_run__open_and_load();
+	if (!ASSERT_OK_PTR(skel, "test_raw_tp_override_test_run__open_and_load"))
+		return;
+
+	if (!ASSERT_OK(test_raw_tp_override_test_run__attach(skel),
+		       "test_raw_tp_override_test_run__attach"))
+		goto cleanup;
+	ASSERT_OK(trigger_module_test_write(1), "trigger_write");
+	ASSERT_EQ(skel->bss->flag, 1, "check_flag");
+
+cleanup:
+	test_raw_tp_override_test_run__destroy(skel);
+}
diff --git a/tools/testing/selftests/bpf/progs/test_raw_tp_override_test_run.c b/tools/testing/selftests/bpf/progs/test_raw_tp_override_test_run.c
new file mode 100644
index 000000000000..eb6d24e1c737
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/test_raw_tp_override_test_run.c
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include "vmlinux.h"
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+
+__u32 flag = 0;
+
+/**
+ * This program overrides raw_tp_override_probe handler in
+ * tracepoint bpf_testmode_test_raw_tp_null_tp.
+ */
+SEC("raw_tp.o/bpf_testmod_test_write_bare_tp:raw_tp_override_probe")
+int BPF_PROG(tp_override, struct task_struct *task, char *comm)
+{
+	flag = 1;
+	return 0;
+}
+
+char _license[] SEC("license") = "GPL";
diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
index 2beb9b2fcbd8..7a49178d2343 100644
--- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
+++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
@@ -1628,6 +1628,11 @@ static struct bpf_testmod_multi_st_ops multi_st_ops_cfi_stubs = {
 	.test_1 = bpf_testmod_multi_st_ops__test_1,
 };
 
+static void raw_tp_override_probe(void *ignored, struct task_struct *task,
+				  struct bpf_testmod_test_write_ctx *ctx)
+{
+}
+
 struct bpf_struct_ops testmod_multi_st_ops = {
 	.verifier_ops = &bpf_testmod_verifier_ops,
 	.init = multi_st_ops_init,
@@ -1665,6 +1670,7 @@ static int bpf_testmod_init(void)
 	ret = ret ?: register_btf_id_dtor_kfuncs(bpf_testmod_dtors,
 						 ARRAY_SIZE(bpf_testmod_dtors),
 						 THIS_MODULE);
+	ret = ret ?: register_trace_bpf_testmod_test_write_bare_tp(raw_tp_override_probe, NULL);
 	if (ret < 0)
 		return ret;
 	if (bpf_fentry_test1(0) < 0)
@@ -1701,6 +1707,7 @@ static void bpf_testmod_exit(void)
 	bpf_kfunc_close_sock();
 	sysfs_remove_bin_file(kernel_kobj, &bin_attr_bpf_testmod_file);
 	unregister_bpf_testmod_uprobe();
+	unregister_trace_bpf_testmod_test_write_bare_tp(raw_tp_override_probe, NULL);
 }
 
 module_init(bpf_testmod_init);
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ