On Mon, May 2, 2022 at 4:09 PM Delyan Kratunov <delyank@xxxxxx> wrote: > > Add section mappings for uprobe.s and kprobe.s programs. The latter > cannot currently attach but they're still useful to open and load in > order to validate that prohibition. > > Signed-off-by: Delyan Kratunov <delyank@xxxxxx> > --- > tools/lib/bpf/libbpf.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > One nit below, otherwise LGTM Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index 63c0f412266c..d89529c9b52d 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -8945,8 +8945,10 @@ static const struct bpf_sec_def section_defs[] = { > SEC_DEF("sk_reuseport", SK_REUSEPORT, BPF_SK_REUSEPORT_SELECT, SEC_ATTACHABLE | SEC_SLOPPY_PFX), > SEC_DEF("kprobe+", KPROBE, 0, SEC_NONE, attach_kprobe), > SEC_DEF("uprobe+", KPROBE, 0, SEC_NONE, attach_uprobe), > + SEC_DEF("uprobe.s+", KPROBE, 0, SEC_SLEEPABLE, attach_uprobe), > SEC_DEF("kretprobe+", KPROBE, 0, SEC_NONE, attach_kprobe), > SEC_DEF("uretprobe+", KPROBE, 0, SEC_NONE, attach_uprobe), > + SEC_DEF("uretprobe.s+", KPROBE, 0, SEC_SLEEPABLE, attach_uprobe), > SEC_DEF("kprobe.multi+", KPROBE, BPF_TRACE_KPROBE_MULTI, SEC_NONE, attach_kprobe_multi), > SEC_DEF("kretprobe.multi+", KPROBE, BPF_TRACE_KPROBE_MULTI, SEC_NONE, attach_kprobe_multi), > SEC_DEF("usdt+", KPROBE, 0, SEC_NONE, attach_usdt), > @@ -10697,6 +10699,7 @@ static int attach_kprobe(const struct bpf_program *prog, long cookie, struct bpf > else > func_name = prog->sec_name + sizeof("kprobe/") - 1; > > + unnecessary empty line? > n = sscanf(func_name, "%m[a-zA-Z0-9_.]+%li", &func, &offset); > if (n < 1) { > pr_warn("kprobe name is invalid: %s\n", func_name); > @@ -11222,7 +11225,8 @@ static int attach_uprobe(const struct bpf_program *prog, long cookie, struct bpf > break; > case 3: > case 4: > - opts.retprobe = strcmp(probe_type, "uretprobe") == 0; > + opts.retprobe = strcmp(probe_type, "uretprobe") == 0 || > + strcmp(probe_type, "uretprobe.s") == 0; > if (opts.retprobe && offset != 0) { > pr_warn("prog '%s': uretprobes do not support offset specification\n", > prog->name); > -- > 2.35.1