BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next] libbpf: Fix uretprobe.multi.s programs auto attachment
@ 2024-09-10 12:53 Jiri Olsa
  2024-09-10 18:49 ` Andrii Nakryiko
  2024-09-10 18:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jiri Olsa @ 2024-09-10 12:53 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: bpf, Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo

As reported by Andrii we don't currently recognize uretprobe.multi.s
programs as return probes due to using (wrong) strcmp function.

Using strncmp instead to match uretprobe.multi as prefix.

Tests are passing, because the return program was executed
as entry program and all counts were incremented properly.

Reported-by: Andrii Nakryiko <andrii@kernel.org>
Closes: https://lore.kernel.org/bpf/CAEf4BzYpH_2f0eHwQG205Q_4hewbtC9OrVSA-_jn6ysz53QbBg@mail.gmail.com/
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 4f29e06c2641..08e110392516 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -11688,7 +11688,7 @@ static int attach_uprobe_multi(const struct bpf_program *prog, long cookie, stru
 		ret = 0;
 		break;
 	case 3:
-		opts.retprobe = strcmp(probe_type, "uretprobe.multi") == 0;
+		opts.retprobe = strncmp(probe_type, "uretprobe.multi", sizeof("uretprobe.multi") - 1) == 0;
 		*link = bpf_program__attach_uprobe_multi(prog, -1, binary_path, func_name, &opts);
 		ret = libbpf_get_error(*link);
 		break;
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] libbpf: Fix uretprobe.multi.s programs auto attachment
  2024-09-10 12:53 [PATCH bpf-next] libbpf: Fix uretprobe.multi.s programs auto attachment Jiri Olsa
@ 2024-09-10 18:49 ` Andrii Nakryiko
  2024-09-10 18:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2024-09-10 18:49 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, bpf,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo

On Tue, Sep 10, 2024 at 5:53 AM Jiri Olsa <jolsa@kernel.org> wrote:
>
> As reported by Andrii we don't currently recognize uretprobe.multi.s
> programs as return probes due to using (wrong) strcmp function.
>
> Using strncmp instead to match uretprobe.multi as prefix.
>
> Tests are passing, because the return program was executed
> as entry program and all counts were incremented properly.
>
> Reported-by: Andrii Nakryiko <andrii@kernel.org>
> Closes: https://lore.kernel.org/bpf/CAEf4BzYpH_2f0eHwQG205Q_4hewbtC9OrVSA-_jn6ysz53QbBg@mail.gmail.com/
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/lib/bpf/libbpf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 4f29e06c2641..08e110392516 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -11688,7 +11688,7 @@ static int attach_uprobe_multi(const struct bpf_program *prog, long cookie, stru
>                 ret = 0;
>                 break;
>         case 3:
> -               opts.retprobe = strcmp(probe_type, "uretprobe.multi") == 0;
> +               opts.retprobe = strncmp(probe_type, "uretprobe.multi", sizeof("uretprobe.multi") - 1) == 0;

I replaced this with `opts.retprobe = str_has_pfx(probe_type,
"uretprobe.multi");`, less duplication


>                 *link = bpf_program__attach_uprobe_multi(prog, -1, binary_path, func_name, &opts);
>                 ret = libbpf_get_error(*link);
>                 break;
> --
> 2.46.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] libbpf: Fix uretprobe.multi.s programs auto attachment
  2024-09-10 12:53 [PATCH bpf-next] libbpf: Fix uretprobe.multi.s programs auto attachment Jiri Olsa
  2024-09-10 18:49 ` Andrii Nakryiko
@ 2024-09-10 18:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-10 18:50 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: ast, daniel, andrii, bpf, kafai, songliubraving, yhs,
	john.fastabend, kpsingh, sdf, haoluo

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Tue, 10 Sep 2024 14:53:36 +0200 you wrote:
> As reported by Andrii we don't currently recognize uretprobe.multi.s
> programs as return probes due to using (wrong) strcmp function.
> 
> Using strncmp instead to match uretprobe.multi as prefix.
> 
> Tests are passing, because the return program was executed
> as entry program and all counts were incremented properly.
> 
> [...]

Here is the summary with links:
  - [bpf-next] libbpf: Fix uretprobe.multi.s programs auto attachment
    https://git.kernel.org/bpf/bpf-next/c/8c8b47597403

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-10 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10 12:53 [PATCH bpf-next] libbpf: Fix uretprobe.multi.s programs auto attachment Jiri Olsa
2024-09-10 18:49 ` Andrii Nakryiko
2024-09-10 18:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox