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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzbOS8DCe=yhJOoiV3XfpwMTsnDgZ2AmBtkGMnaYWUL1QQ@mail.gmail.com>
Date: Tue, 15 Apr 2025 16:05:20 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Feng Yang <yangfeng59949@....com>
Cc: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org, 
	martin.lau@...ux.dev, eddyz87@...il.com, song@...nel.org, 
	yonghong.song@...ux.dev, john.fastabend@...il.com, kpsingh@...nel.org, 
	sdf@...ichev.me, haoluo@...gle.com, jolsa@...nel.org, hengqi.chen@...il.com, 
	olsajiri@...il.com, bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 bpf-next 3/3] selftests/bpf: Add test for attaching
 kprobe with long event names

On Tue, Apr 15, 2025 at 2:40 AM Feng Yang <yangfeng59949@....com> wrote:
>
> From: Feng Yang <yangfeng@...inos.cn>
>
> This test verifies that attaching kprobe/kretprobe with long event names
> does not trigger EINVAL errors.
>
> Signed-off-by: Feng Yang <yangfeng@...inos.cn>
> ---
>  .../selftests/bpf/prog_tests/attach_probe.c   | 35 +++++++++++++++++++
>  .../selftests/bpf/test_kmods/bpf_testmod.c    |  4 +++
>  2 files changed, 39 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> index 9b7f36f39c32..cabc51c2ca6b 100644
> --- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> +++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> @@ -168,6 +168,39 @@ static void test_attach_uprobe_long_event_name(void)
>         test_attach_probe_manual__destroy(skel);
>  }
>
> +/* attach kprobe/kretprobe long event name testings */
> +static void test_attach_kprobe_long_event_name(void)
> +{
> +       DECLARE_LIBBPF_OPTS(bpf_kprobe_opts, kprobe_opts);
> +       struct bpf_link *kprobe_link, *kretprobe_link;
> +       struct test_attach_probe_manual *skel;
> +
> +       skel = test_attach_probe_manual__open_and_load();
> +       if (!ASSERT_OK_PTR(skel, "skel_kprobe_manual_open_and_load"))
> +               return;
> +
> +       /* manual-attach kprobe/kretprobe */
> +       kprobe_opts.attach_mode = PROBE_ATTACH_MODE_LEGACY;
> +       kprobe_opts.retprobe = false;
> +       kprobe_link = bpf_program__attach_kprobe_opts(skel->progs.handle_kprobe,
> +                                                     "bpf_testmod_looooooooooooooooooooooooooooooong_name",
> +                                                     &kprobe_opts);
> +       if (!ASSERT_OK_PTR(kprobe_link, "attach_kprobe_long_event_name"))
> +               goto cleanup;
> +       skel->links.handle_kprobe = kprobe_link;
> +
> +       kprobe_opts.retprobe = true;
> +       kretprobe_link = bpf_program__attach_kprobe_opts(skel->progs.handle_kretprobe,
> +                                                        "bpf_testmod_looooooooooooooooooooooooooooooong_name",
> +                                                        &kprobe_opts);
> +       if (!ASSERT_OK_PTR(kretprobe_link, "attach_kretprobe_long_event_name"))
> +               goto cleanup;
> +       skel->links.handle_kretprobe = kretprobe_link;
> +
> +cleanup:
> +       test_attach_probe_manual__destroy(skel);
> +}
> +
>  static void test_attach_probe_auto(struct test_attach_probe *skel)
>  {
>         struct bpf_link *uprobe_err_link;
> @@ -371,6 +404,8 @@ void test_attach_probe(void)
>
>         if (test__start_subtest("uprobe-long_name"))
>                 test_attach_uprobe_long_event_name();
> +       if (test__start_subtest("kprobe-long_name"))
> +               test_attach_kprobe_long_event_name();
>
>  cleanup:
>         test_attach_probe__destroy(skel);
> diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
> index f38eaf0d35ef..13b0dc7a4a7e 100644
> --- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
> +++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
> @@ -134,6 +134,10 @@ bpf_testmod_test_arg_ptr_to_struct(struct bpf_testmod_struct_arg_1 *a) {
>         return bpf_testmod_test_struct_arg_result;
>  }
>
> +noinline void bpf_testmod_looooooooooooooooooooooooooooooong_name(void)

please use ` __weak noinline` just like `bpf_testmod_return_ptr()`,
it's more reliable this way (at least for the future)

> +{
> +}
> +
>  __bpf_kfunc void
>  bpf_testmod_test_mod_kfunc(int i)
>  {
> --
> 2.43.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ