On Mon, Jul 14, 2025 at 5:04 AM KaFai Wan <mannka...@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 <mannka...@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

Reply via email to