> The provided <pattern> is used as 'pattern' argument in
> bpf_program__attach_kprobe_multi_opts function.
The function referenced here should be
bpf_program__attach_tracing_multi, not
bpf_program__attach_kprobe_multi_opts. This was noted in v1
review.
> - bpf_program__attach_kprobe_multi_opts must either have
> pattern with module spec or BTF ids from the module
Same here, should be bpf_program__attach_tracing_multi.
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
[ ... ]
> +struct bpf_link *
> +bpf_program__attach_tracing_multi(const struct bpf_program *prog, const char
> *pattern,
> + const struct bpf_tracing_multi_opts *opts)
> +{
> + LIBBPF_OPTS(bpf_link_create_opts, lopts);
> + __u32 *ids, *free_ids = NULL;
> + __u64 *cookies;
> + int prog_fd, link_fd, err, cnt;
> + struct bpf_link *link;
> +
> + cnt = OPTS_GET(opts, cnt, 0);
> + ids = OPTS_GET(opts, ids, NULL);
> + cookies = OPTS_GET(opts, cookies, NULL);
Should this function validate opts with OPTS_VALID() before
calling OPTS_GET()? The comparable
bpf_program__attach_kprobe_multi_opts() does:
if (!OPTS_VALID(opts, bpf_kprobe_multi_opts))
return libbpf_err_ptr(-EINVAL);
Without OPTS_VALID(), a caller passing opts with sz=0 would have
ids, cookies and cnt silently ignored rather than getting -EINVAL
back.
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/22692622038