Skip to content

Commit f5af339

Browse files
Delyan KratunovKernel Patches Daemon
authored andcommitted
libbpf: add support for sleepable kprobe and uprobe programs
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@fb.com> Acked-by: Andrii Nakryiko <andrii@kernel.org>
1 parent abed79e commit f5af339

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8985,8 +8985,10 @@ static const struct bpf_sec_def section_defs[] = {
89858985
SEC_DEF("sk_reuseport", SK_REUSEPORT, BPF_SK_REUSEPORT_SELECT, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
89868986
SEC_DEF("kprobe+", KPROBE, 0, SEC_NONE, attach_kprobe),
89878987
SEC_DEF("uprobe+", KPROBE, 0, SEC_NONE, attach_uprobe),
8988+
SEC_DEF("uprobe.s+", KPROBE, 0, SEC_SLEEPABLE, attach_uprobe),
89888989
SEC_DEF("kretprobe+", KPROBE, 0, SEC_NONE, attach_kprobe),
89898990
SEC_DEF("uretprobe+", KPROBE, 0, SEC_NONE, attach_uprobe),
8991+
SEC_DEF("uretprobe.s+", KPROBE, 0, SEC_SLEEPABLE, attach_uprobe),
89908992
SEC_DEF("kprobe.multi+", KPROBE, BPF_TRACE_KPROBE_MULTI, SEC_NONE, attach_kprobe_multi),
89918993
SEC_DEF("kretprobe.multi+", KPROBE, BPF_TRACE_KPROBE_MULTI, SEC_NONE, attach_kprobe_multi),
89928994
SEC_DEF("usdt+", KPROBE, 0, SEC_NONE, attach_usdt),
@@ -10737,6 +10739,7 @@ static int attach_kprobe(const struct bpf_program *prog, long cookie, struct bpf
1073710739
else
1073810740
func_name = prog->sec_name + sizeof("kprobe/") - 1;
1073910741

10742+
1074010743
n = sscanf(func_name, "%m[a-zA-Z0-9_.]+%li", &func, &offset);
1074110744
if (n < 1) {
1074210745
pr_warn("kprobe name is invalid: %s\n", func_name);
@@ -11262,7 +11265,8 @@ static int attach_uprobe(const struct bpf_program *prog, long cookie, struct bpf
1126211265
break;
1126311266
case 3:
1126411267
case 4:
11265-
opts.retprobe = strcmp(probe_type, "uretprobe") == 0;
11268+
opts.retprobe = strcmp(probe_type, "uretprobe") == 0 ||
11269+
strcmp(probe_type, "uretprobe.s") == 0;
1126611270
if (opts.retprobe && offset != 0) {
1126711271
pr_warn("prog '%s': uretprobes do not support offset specification\n",
1126811272
prog->name);

0 commit comments

Comments
 (0)