From: KaFai Wan <kafai.wan@linux.dev>
To: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com,
song@kernel.org, yonghong.song@linux.dev, kpsingh@kernel.org,
sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org,
mykolal@fb.com, shuah@kernel.org, kafai.wan@linux.dev,
laoar.shao@gmail.com, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
leon.hwang@linux.dev
Subject: [PATCH bpf-next v3 3/4] selftests/bpf: Add selftest for attaching tracing programs to functions in deny list
Date: Tue, 22 Jul 2025 23:34:33 +0800 [thread overview]
Message-ID: <20250722153434.20571-4-kafai.wan@linux.dev> (raw)
In-Reply-To: <20250722153434.20571-1-kafai.wan@linux.dev>
The result:
$ tools/testing/selftests/bpf/test_progs -t tracing_failure/tracing_deny
#468/3 tracing_failure/tracing_deny:OK
#468 tracing_failure:OK
Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: KaFai Wan <kafai.wan@linux.dev>
---
.../bpf/prog_tests/tracing_failure.c | 33 +++++++++++++++++++
.../selftests/bpf/progs/tracing_failure.c | 6 ++++
2 files changed, 39 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/tracing_failure.c b/tools/testing/selftests/bpf/prog_tests/tracing_failure.c
index a222df765bc3..140fb0d175cf 100644
--- a/tools/testing/selftests/bpf/prog_tests/tracing_failure.c
+++ b/tools/testing/selftests/bpf/prog_tests/tracing_failure.c
@@ -28,10 +28,43 @@ static void test_bpf_spin_lock(bool is_spin_lock)
tracing_failure__destroy(skel);
}
+static void test_tracing_deny(void)
+{
+ struct tracing_failure *skel;
+ char log_buf[256];
+ int btf_id, err;
+
+ /* migrate_disable depends on CONFIG_SMP */
+ btf_id = libbpf_find_vmlinux_btf_id("migrate_disable", BPF_TRACE_FENTRY);
+ if (btf_id <= 0) {
+ test__skip();
+ return;
+ }
+
+ skel = tracing_failure__open();
+ if (!ASSERT_OK_PTR(skel, "tracing_failure__open"))
+ return;
+
+ bpf_program__set_autoload(skel->progs.tracing_deny, true);
+ bpf_program__set_log_buf(skel->progs.tracing_deny, log_buf, sizeof(log_buf));
+
+ err = tracing_failure__load(skel);
+ if (!ASSERT_ERR(err, "tracing_failure__load"))
+ goto out;
+
+ ASSERT_HAS_SUBSTR(log_buf,
+ "Attaching tracing programs to function 'migrate_disable' is rejected.",
+ "log_buf");
+out:
+ tracing_failure__destroy(skel);
+}
+
void test_tracing_failure(void)
{
if (test__start_subtest("bpf_spin_lock"))
test_bpf_spin_lock(true);
if (test__start_subtest("bpf_spin_unlock"))
test_bpf_spin_lock(false);
+ if (test__start_subtest("tracing_deny"))
+ test_tracing_deny();
}
diff --git a/tools/testing/selftests/bpf/progs/tracing_failure.c b/tools/testing/selftests/bpf/progs/tracing_failure.c
index d41665d2ec8c..dfa152e8194e 100644
--- a/tools/testing/selftests/bpf/progs/tracing_failure.c
+++ b/tools/testing/selftests/bpf/progs/tracing_failure.c
@@ -18,3 +18,9 @@ int BPF_PROG(test_spin_unlock, struct bpf_spin_lock *lock)
{
return 0;
}
+
+SEC("?fentry/migrate_disable")
+int BPF_PROG(tracing_deny)
+{
+ return 0;
+}
--
2.43.0
next prev parent reply other threads:[~2025-07-22 15:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-22 15:34 [PATCH bpf-next v3 0/4] bpf: Show precise rejected function when attaching to __noreturn and deny list functions KaFai Wan
2025-07-22 15:34 ` [PATCH bpf-next v3 1/4] bpf: Show precise rejected function when attaching fexit/fmod_ret to __noreturn functions KaFai Wan
2025-07-23 11:37 ` Yafang Shao
2025-07-23 16:36 ` Yonghong Song
2025-07-22 15:34 ` [PATCH bpf-next v3 2/4] bpf: Add log for attaching tracing programs to functions in deny list KaFai Wan
2025-07-23 11:37 ` Yafang Shao
2025-07-23 16:37 ` Yonghong Song
2025-07-22 15:34 ` KaFai Wan [this message]
2025-07-23 16:42 ` [PATCH bpf-next v3 3/4] selftests/bpf: Add selftest " Yonghong Song
2025-07-24 11:05 ` KaFai Wan
2025-07-22 15:34 ` [PATCH bpf-next v3 4/4] selftests/bpf: Migrate fexit_noreturns case into tracing_failure test suite KaFai Wan
2025-07-23 16:43 ` Yonghong Song
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=20250722153434.20571-4-kafai.wan@linux.dev \
--to=kafai.wan@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=laoar.shao@gmail.com \
--cc=leon.hwang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.