* [PATCH bpf-next v2 1/2] bpf: Check link_create parameter for multi_kprobe
@ 2025-04-07 3:57 Tao Chen
2025-04-07 3:57 ` [PATCH bpf-next v2 2/2] bpf: Check link_create parameter for multi_uprobe Tao Chen
2025-04-09 23:40 ` [PATCH bpf-next v2 1/2] bpf: Check link_create parameter for multi_kprobe patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Tao Chen @ 2025-04-07 3:57 UTC (permalink / raw)
To: song, jolsa, ast, daniel, andrii, martin.lau, eddyz87,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, rostedt,
mhiramat, mathieu.desnoyers, laoar.shao
Cc: bpf, linux-kernel, linux-trace-kernel, Tao Chen
The flags in link_create no used in multi_kprobe, return -EINVAL if
they assigned, keep it same as other link attach apis. Perhaps due to
their usage habits, users may set the target_fd to -1. Therefore, no
check is carried out here, and it is kept consistent with the multi_uprobe.
Fixes: 0dcac2725406 ("bpf: Add multi kprobe link")
Signed-off-by: Tao Chen <chen.dylane@linux.dev>
---
kernel/trace/bpf_trace.c | 6 ++++++
1 file changed, 6 insertions(+)
Change list:
- v1 -> v2:
- remove target_fd check suggested by jiri.
- v1:
https://lore.kernel.org/bpf/20250331094745.336010-1-chen.dylane@linux.dev/
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 13bef2462..5cd0af80f 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -2992,6 +2992,12 @@ int bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
/* no support for 32bit archs yet */
if (sizeof(u64) != sizeof(void *))
return -EOPNOTSUPP;
+ /*
+ * Perhaps due to their usage habits, users may set the target_fd to -1. Therefore,
+ * no check is carried out here, and it is kept consistent with the multi_uprobe.
+ */
+ if (attr->link_create.flags)
+ return -EINVAL;
if (!is_kprobe_multi(prog))
return -EINVAL;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH bpf-next v2 2/2] bpf: Check link_create parameter for multi_uprobe
2025-04-07 3:57 [PATCH bpf-next v2 1/2] bpf: Check link_create parameter for multi_kprobe Tao Chen
@ 2025-04-07 3:57 ` Tao Chen
2025-04-09 23:40 ` [PATCH bpf-next v2 1/2] bpf: Check link_create parameter for multi_kprobe patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Tao Chen @ 2025-04-07 3:57 UTC (permalink / raw)
To: song, jolsa, ast, daniel, andrii, martin.lau, eddyz87,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, rostedt,
mhiramat, mathieu.desnoyers, laoar.shao
Cc: bpf, linux-kernel, linux-trace-kernel, Tao Chen
The flags in link_create no used in multi_uprobe, return -EINVAL if
they assigned, keep it same as other link attach apis. And the target_fd
sometimes will be initialized -1 such as probe_uprobe_multi_link in libbpf,
so do not check it at the current stage suggested by jiri.
Fixes: 89ae89f53d20 ("bpf: Add multi uprobe link")
Signed-off-by: Tao Chen <chen.dylane@linux.dev>
---
kernel/trace/bpf_trace.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 5cd0af80f..0f4085e8d 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -3387,6 +3387,13 @@ int bpf_uprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
/* no support for 32bit archs yet */
if (sizeof(u64) != sizeof(void *))
return -EOPNOTSUPP;
+ /*
+ * The target_fd sometimes will be initialized -1 such as
+ * probe_uprobe_multi_link in libbpf, so do not check it at the
+ * current stage suggested by jiri.
+ */
+ if (attr->link_create.flags)
+ return -EINVAL;
if (!is_uprobe_multi(prog))
return -EINVAL;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next v2 1/2] bpf: Check link_create parameter for multi_kprobe
2025-04-07 3:57 [PATCH bpf-next v2 1/2] bpf: Check link_create parameter for multi_kprobe Tao Chen
2025-04-07 3:57 ` [PATCH bpf-next v2 2/2] bpf: Check link_create parameter for multi_uprobe Tao Chen
@ 2025-04-09 23:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-09 23:40 UTC (permalink / raw)
To: Tao Chen
Cc: song, jolsa, ast, daniel, andrii, martin.lau, eddyz87,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, rostedt,
mhiramat, mathieu.desnoyers, laoar.shao, bpf, linux-kernel,
linux-trace-kernel
Hello:
This series was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Mon, 7 Apr 2025 11:57:51 +0800 you wrote:
> The flags in link_create no used in multi_kprobe, return -EINVAL if
> they assigned, keep it same as other link attach apis. Perhaps due to
> their usage habits, users may set the target_fd to -1. Therefore, no
> check is carried out here, and it is kept consistent with the multi_uprobe.
>
> Fixes: 0dcac2725406 ("bpf: Add multi kprobe link")
> Signed-off-by: Tao Chen <chen.dylane@linux.dev>
>
> [...]
Here is the summary with links:
- [bpf-next,v2,1/2] bpf: Check link_create parameter for multi_kprobe
https://git.kernel.org/bpf/bpf-next/c/243911982aa9
- [bpf-next,v2,2/2] bpf: Check link_create parameter for multi_uprobe
https://git.kernel.org/bpf/bpf-next/c/a76116f422c4
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:[~2025-04-09 23:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-07 3:57 [PATCH bpf-next v2 1/2] bpf: Check link_create parameter for multi_kprobe Tao Chen
2025-04-07 3:57 ` [PATCH bpf-next v2 2/2] bpf: Check link_create parameter for multi_uprobe Tao Chen
2025-04-09 23:40 ` [PATCH bpf-next v2 1/2] bpf: Check link_create parameter for multi_kprobe 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;
as well as URLs for NNTP newsgroup(s).