OSDN Git Service

libbpf: Add legacy uprobe attaching support
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 21 Sep 2021 21:00:36 +0000 (14:00 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 22 Sep 2021 02:40:09 +0000 (19:40 -0700)
commitcc10623c681019c608c0cb30e2b38994e2c90b2a
tree371b4dbffe409debc25c062781bd9f620645f754
parent46ed5fc33db966aa1a46e8ae9d96b08b756a2546
libbpf: Add legacy uprobe attaching support

Similarly to recently added legacy kprobe attach interface support
through tracefs, support attaching uprobes using the legacy interface if
host kernel doesn't support newer FD-based interface.

For uprobes event name consists of "libbpf_" prefix, PID, sanitized
binary path and offset within that binary. Structuraly the code is
aligned with kprobe logic refactoring in previous patch. struct
bpf_link_perf is re-used and all the same legacy_probe_name and
legacy_is_retprobe fields are used to ensure proper cleanup on
bpf_link__destroy().

Users should be aware, though, that on old kernels which don't support
FD-based interface for kprobe/uprobe attachment, if the application
crashes before bpf_link__destroy() is called, uprobe legacy
events will be left in tracefs. This is the same limitation as with
legacy kprobe interfaces.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210921210036.1545557-5-andrii@kernel.org
tools/lib/bpf/libbpf.c