mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
libbpf: Clarify raw-address single kprobe attach behavior
bpf_program__attach_kprobe_opts() documents single-kprobe attach through func_name, with an optional offset. For the PMU-based path, func_name = NULL with an absolute address in offset already works as well, but that is not described in the API. This commit clarifies this existing non-legacy behavior. For PMU-based attach, callers can use func_name = NULL with an absolute address in offset as the raw-address form. For legacy tracefs/debugfs kprobes, reject this form explicitly. Signed-off-by: Hoyeon Lee <hoyeon.lee@suse.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/bpf/20260401143116.185049-3-hoyeon.lee@suse.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
f547cf7947
commit
e1621c7528
@@ -11843,6 +11843,8 @@ bpf_program__attach_kprobe_opts(const struct bpf_program *prog,
|
||||
default:
|
||||
return libbpf_err_ptr(-EINVAL);
|
||||
}
|
||||
if (!func_name && legacy)
|
||||
return libbpf_err_ptr(-EOPNOTSUPP);
|
||||
|
||||
if (!legacy) {
|
||||
pfd = perf_event_open_probe(false /* uprobe */, retprobe,
|
||||
@@ -11863,20 +11865,20 @@ bpf_program__attach_kprobe_opts(const struct bpf_program *prog,
|
||||
}
|
||||
if (pfd < 0) {
|
||||
err = pfd;
|
||||
pr_warn("prog '%s': failed to create %s '%s+0x%zx' perf event: %s\n",
|
||||
pr_warn("prog '%s': failed to create %s '%s%s0x%zx' perf event: %s\n",
|
||||
prog->name, retprobe ? "kretprobe" : "kprobe",
|
||||
func_name, offset,
|
||||
errstr(err));
|
||||
func_name ?: "", func_name ? "+" : "",
|
||||
offset, errstr(err));
|
||||
goto err_out;
|
||||
}
|
||||
link = bpf_program__attach_perf_event_opts(prog, pfd, &pe_opts);
|
||||
err = libbpf_get_error(link);
|
||||
if (err) {
|
||||
close(pfd);
|
||||
pr_warn("prog '%s': failed to attach to %s '%s+0x%zx': %s\n",
|
||||
pr_warn("prog '%s': failed to attach to %s '%s%s0x%zx': %s\n",
|
||||
prog->name, retprobe ? "kretprobe" : "kprobe",
|
||||
func_name, offset,
|
||||
errstr(err));
|
||||
func_name ?: "", func_name ? "+" : "",
|
||||
offset, errstr(err));
|
||||
goto err_clean_legacy;
|
||||
}
|
||||
if (legacy) {
|
||||
|
||||
Reference in New Issue
Block a user