Commit 3a932466 authored by yonghong-song's avatar yonghong-song Committed by GitHub

fix attach_kretprobe for newer kernels (#1922)

fix #1921

For newer kernels, bcc tries to fd based kuprobe
attachment. In fd based kprobe attachment,
  config1: for symbol
  config2: for symbol offset

In python API attach_kretprobe, the offset value
is not set in lib.bpf_attach_kprobe and hence it
will be a random value and eventually causing
kretprobe attachment failure.

This is not an issue for old debugfs based attachment
as the offset will not be used if it is a retprobe.
Signed-off-by: default avatarYonghong Song <yhs@fb.com>
parent 5aadf2ed
...@@ -614,7 +614,7 @@ class BPF(object): ...@@ -614,7 +614,7 @@ class BPF(object):
self._check_probe_quota(1) self._check_probe_quota(1)
fn = self.load_func(fn_name, BPF.KPROBE) fn = self.load_func(fn_name, BPF.KPROBE)
ev_name = b"r_" + event.replace(b"+", b"_").replace(b".", b"_") ev_name = b"r_" + event.replace(b"+", b"_").replace(b".", b"_")
fd = lib.bpf_attach_kprobe(fn.fd, 1, ev_name, event) fd = lib.bpf_attach_kprobe(fn.fd, 1, ev_name, event, 0)
if fd < 0: if fd < 0:
raise Exception("Failed to attach BPF to kretprobe") raise Exception("Failed to attach BPF to kretprobe")
self._add_kprobe_fd(ev_name, fd) self._add_kprobe_fd(ev_name, fd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment