On Wed, May 01, 2024 at 11:30:55AM -0700, Andrii Nakryiko wrote: SNIP > > > > +static int attach_kprobe_session(const struct bpf_program *prog, long cookie, > > + struct bpf_link **link) > > +{ > > + LIBBPF_OPTS(bpf_kprobe_multi_opts, opts, .session = true); > > + const char *spec; > > + char *pattern; > > + int n; > > + > > + *link = NULL; > > + > > + /* no auto-attach for SEC("kprobe.session") */ > > + if (strcmp(prog->sec_name, "kprobe.session") == 0) > > + return 0; > > + > > + spec = prog->sec_name + sizeof("kprobe.session/") - 1; > > + n = sscanf(spec, "%m[a-zA-Z0-9_.*?]", &pattern); > > + if (n < 1) { > > + pr_warn("kprobe session pattern is invalid: %s\n", pattern); > > this should be printing spec, not pattern, please send a follow up fix, thanks ugh yes, also attach_kprobe_multi is broken same way, will send the fix tomorrow thanks, jirka > > > + return -EINVAL; > > + } > > + > > + *link = bpf_program__attach_kprobe_multi_opts(prog, pattern, &opts); > > + free(pattern); > > + return *link ? 0 : -errno; > > +} > > + > > static int attach_uprobe_multi(const struct bpf_program *prog, long cookie, struct bpf_link **link) > > { > > char *probe_type = NULL, *binary_path = NULL, *func_name = NULL; > > diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h > > index 1333ae20ebe6..c3f77d9260fe 100644 > > --- a/tools/lib/bpf/libbpf.h > > +++ b/tools/lib/bpf/libbpf.h > > @@ -539,10 +539,12 @@ struct bpf_kprobe_multi_opts { > > size_t cnt; > > /* create return kprobes */ > > bool retprobe; > > + /* create session kprobes */ > > + bool session; > > size_t :0; > > }; > > > > -#define bpf_kprobe_multi_opts__last_field retprobe > > +#define bpf_kprobe_multi_opts__last_field session > > > > LIBBPF_API struct bpf_link * > > bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog, > > -- > > 2.44.0 > >