diff options
author | Chuang Wang <nashuiliang@gmail.com> | 2022-06-29 23:18:45 +0800 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2022-07-05 21:21:41 -0700 |
commit | 8094029330a2f03fb406ecff80671cf27ce28d42 (patch) | |
tree | 64fcb754a070e4312c5c88ee8421646057dc4897 /fs/lockd/procfs.c | |
parent | f6b9f6d57e5c765b5ff358af1d7749df5e30334c (diff) | |
download | linux-8094029330a2f03fb406ecff80671cf27ce28d42.tar.gz linux-8094029330a2f03fb406ecff80671cf27ce28d42.tar.bz2 linux-8094029330a2f03fb406ecff80671cf27ce28d42.zip |
libbpf: Cleanup the legacy kprobe_event on failed add/attach_event()
Before the 0bc11ed5ab60 commit ("kprobes: Allow kprobes coexist with
livepatch"), in a scenario where livepatch and kprobe coexist on the
same function entry, the creation of kprobe_event using
add_kprobe_event_legacy() will be successful, at the same time as a
trace event (e.g. /debugfs/tracing/events/kprobe/XXX) will exist, but
perf_event_open() will return an error because both livepatch and kprobe
use FTRACE_OPS_FL_IPMODIFY. As follows:
1) add a livepatch
$ insmod livepatch-XXX.ko
2) add a kprobe using tracefs API (i.e. add_kprobe_event_legacy)
$ echo 'p:mykprobe XXX' > /sys/kernel/debug/tracing/kprobe_events
3) enable this kprobe (i.e. sys_perf_event_open)
This will return an error, -EBUSY.
On Andrii Nakryiko's comment, few error paths in
bpf_program__attach_kprobe_opts() that should need to call
remove_kprobe_event_legacy().
With this patch, whenever an error is returned after
add_kprobe_event_legacy() or bpf_program__attach_perf_event_opts(), this
ensures that the created kprobe_event is cleaned.
Signed-off-by: Chuang Wang <nashuiliang@gmail.com>
Signed-off-by: Jingren Zhou <zhoujingren@didiglobal.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220629151848.65587-2-nashuiliang@gmail.com
Diffstat (limited to 'fs/lockd/procfs.c')
0 files changed, 0 insertions, 0 deletions