The reuslt:
$ tools/testing/selftests/bpf/test_progs --name=tracing_deny
#467/1 tracing_deny/migrate_disable:OK
#467 tracing_deny:OK
Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: KaFai Wan <mannkafai@gmail.com>
---
.../selftests/bpf/prog_tests/tracing_deny.c | 11 +++++++++++
tools/testing/selftests/bpf/progs/tracing_deny.c | 15 +++++++++++++++
2 files changed, 26 insertions(+)
create mode 100644 tools/testing/selftests/bpf/prog_tests/tracing_deny.c
create mode 100644 tools/testing/selftests/bpf/progs/tracing_deny.c
diff --git a/tools/testing/selftests/bpf/prog_tests/tracing_deny.c b/tools/testing/selftests/bpf/prog_tests/tracing_deny.c
new file mode 100644
index 000000000000..460c59a9667f
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/tracing_deny.c
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <test_progs.h>
+#include "tracing_deny.skel.h"
+
+void test_tracing_deny(void)
+{
+ /* migrate_disable depends on CONFIG_SMP */
+ if (libbpf_find_vmlinux_btf_id("migrate_disable", BPF_TRACE_FENTRY) > 0)
+ RUN_TESTS(tracing_deny);
+}
diff --git a/tools/testing/selftests/bpf/progs/tracing_deny.c b/tools/testing/selftests/bpf/progs/tracing_deny.c
new file mode 100644
index 000000000000..98ef834f0b6d
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/tracing_deny.c
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/bpf.h>
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+#include "bpf_misc.h"
+
+char _license[] SEC("license") = "GPL";
+
+SEC("fentry/migrate_disable")
+__failure __msg("Attaching tracing programs to function 'migrate_disable' is rejected.")
+int BPF_PROG(migrate_disable)
+{
+ return 0;
+}
--
2.43.0
On Mon, Jul 14, 2025 at 5:04 AM KaFai Wan <mannkafai@gmail.com> wrote: > > The reuslt: > > $ tools/testing/selftests/bpf/test_progs --name=tracing_deny > #467/1 tracing_deny/migrate_disable:OK > #467 tracing_deny:OK > Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED > > Signed-off-by: KaFai Wan <mannkafai@gmail.com> > --- > .../selftests/bpf/prog_tests/tracing_deny.c | 11 +++++++++++ > tools/testing/selftests/bpf/progs/tracing_deny.c | 15 +++++++++++++++ > 2 files changed, 26 insertions(+) > create mode 100644 tools/testing/selftests/bpf/prog_tests/tracing_deny.c > create mode 100644 tools/testing/selftests/bpf/progs/tracing_deny.c > > diff --git a/tools/testing/selftests/bpf/prog_tests/tracing_deny.c b/tools/testing/selftests/bpf/prog_tests/tracing_deny.c > new file mode 100644 > index 000000000000..460c59a9667f > --- /dev/null > +++ b/tools/testing/selftests/bpf/prog_tests/tracing_deny.c > @@ -0,0 +1,11 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +#include <test_progs.h> > +#include "tracing_deny.skel.h" > + > +void test_tracing_deny(void) > +{ > + /* migrate_disable depends on CONFIG_SMP */ > + if (libbpf_find_vmlinux_btf_id("migrate_disable", BPF_TRACE_FENTRY) > 0) > + RUN_TESTS(tracing_deny); > +} > diff --git a/tools/testing/selftests/bpf/progs/tracing_deny.c b/tools/testing/selftests/bpf/progs/tracing_deny.c > new file mode 100644 > index 000000000000..98ef834f0b6d > --- /dev/null > +++ b/tools/testing/selftests/bpf/progs/tracing_deny.c > @@ -0,0 +1,15 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +#include <linux/bpf.h> > +#include <bpf/bpf_helpers.h> > +#include <bpf/bpf_tracing.h> > +#include "bpf_misc.h" > + > +char _license[] SEC("license") = "GPL"; > + > +SEC("fentry/migrate_disable") > +__failure __msg("Attaching tracing programs to function 'migrate_disable' is rejected.") > +int BPF_PROG(migrate_disable) > +{ > + return 0; > +} Please roll these two tiny files into existing files in progs/ and prog_tests/ directories. Every file takes time to compile 4 times, so let's avoid unnecessary overhead. -- pw-bot: cr
On Wed, 2025-07-16 at 18:37 -0700, Alexei Starovoitov wrote: > On Mon, Jul 14, 2025 at 5:04 AM KaFai Wan <mannkafai@gmail.com> > wrote: > > > > The reuslt: > > > > $ tools/testing/selftests/bpf/test_progs --name=tracing_deny > > #467/1 tracing_deny/migrate_disable:OK > > #467 tracing_deny:OK > > Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED > > > > Signed-off-by: KaFai Wan <mannkafai@gmail.com> > > --- > > .../selftests/bpf/prog_tests/tracing_deny.c | 11 +++++++++++ > > tools/testing/selftests/bpf/progs/tracing_deny.c | 15 > > +++++++++++++++ > > 2 files changed, 26 insertions(+) > > create mode 100644 > > tools/testing/selftests/bpf/prog_tests/tracing_deny.c > > create mode 100644 > > tools/testing/selftests/bpf/progs/tracing_deny.c > > > > diff --git a/tools/testing/selftests/bpf/prog_tests/tracing_deny.c > > b/tools/testing/selftests/bpf/prog_tests/tracing_deny.c > > new file mode 100644 > > index 000000000000..460c59a9667f > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/prog_tests/tracing_deny.c > > @@ -0,0 +1,11 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > + > > +#include <test_progs.h> > > +#include "tracing_deny.skel.h" > > + > > +void test_tracing_deny(void) > > +{ > > + /* migrate_disable depends on CONFIG_SMP */ > > + if (libbpf_find_vmlinux_btf_id("migrate_disable", > > BPF_TRACE_FENTRY) > 0) > > + RUN_TESTS(tracing_deny); > > +} > > diff --git a/tools/testing/selftests/bpf/progs/tracing_deny.c > > b/tools/testing/selftests/bpf/progs/tracing_deny.c > > new file mode 100644 > > index 000000000000..98ef834f0b6d > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/progs/tracing_deny.c > > @@ -0,0 +1,15 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > + > > +#include <linux/bpf.h> > > +#include <bpf/bpf_helpers.h> > > +#include <bpf/bpf_tracing.h> > > +#include "bpf_misc.h" > > + > > +char _license[] SEC("license") = "GPL"; > > + > > +SEC("fentry/migrate_disable") > > +__failure __msg("Attaching tracing programs to function > > 'migrate_disable' is rejected.") > > +int BPF_PROG(migrate_disable) > > +{ > > + return 0; > > +} > > Please roll these two tiny files into existing files in progs/ and > prog_tests/ > directories. > Every file takes time to compile 4 times, so let's avoid unnecessary > overhead. > Okay, will update it in v3. > -- > pw-bot: cr -- Thanks, KaFai
© 2016 - 2025 Red Hat, Inc.