]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Check link_create.flags parameter for multi_kprobe
authorTao Chen <chen.dylane@linux.dev>
Mon, 7 Apr 2025 03:57:51 +0000 (11:57 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 9 Apr 2025 23:28:22 +0000 (16:28 -0700)
The link_create.flags are currently not used for multi-kprobes, so return
-EINVAL if it is set, same as for other attach APIs.

We allow target_fd, on the other hand, to have an arbitrary value for
multi-kprobe, as there are existing users (libbpf) relying on this.

Fixes: 0dcac2725406 ("bpf: Add multi kprobe link")
Signed-off-by: Tao Chen <chen.dylane@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250407035752.1108927-1-chen.dylane@linux.dev
kernel/trace/bpf_trace.c

index 187dc37d61d4a3fad0a1065f84ab6de8927c794f..ec19942321e6d2ba4319ee2a62fbc7f725dc0ef8 100644 (file)
@@ -2987,6 +2987,9 @@ int bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
        if (sizeof(u64) != sizeof(void *))
                return -EOPNOTSUPP;
 
+       if (attr->link_create.flags)
+               return -EINVAL;
+
        if (!is_kprobe_multi(prog))
                return -EINVAL;