Skip to content

Commit

Permalink
work around gobpf memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
itaysk committed May 18, 2020
1 parent 2187ecb commit 5dc755f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tracee/tracee.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,22 +230,23 @@ func (t *Tracee) initBPF(ebpfProgram string) error {
}
}

sysPrefix := bpf.GetSyscallPrefix()
for _, e := range eventsToTraceFinal {
eName := EventsIDToName[e]
if IsEventSyscall(e) {
kp, err := t.bpfModule.LoadKprobe(fmt.Sprintf("syscall__%s", eName))
if err != nil {
return fmt.Errorf("error loading kprobe %s: %v", eName, err)
}
err = t.bpfModule.AttachKprobe(bpf.GetSyscallFnName(eName), kp, -1)
err = t.bpfModule.AttachKprobe(sysPrefix+eName, kp, -1)
if err != nil {
return fmt.Errorf("error attaching kprobe %s: %v", eName, err)
}
kp, err = t.bpfModule.LoadKprobe(fmt.Sprintf("trace_ret_%s", eName))
if err != nil {
return fmt.Errorf("error loading kprobe %s: %v", eName, err)
}
err = t.bpfModule.AttachKretprobe(bpf.GetSyscallFnName(eName), kp, -1)
err = t.bpfModule.AttachKretprobe(sysPrefix+eName, kp, -1)
if err != nil {
return fmt.Errorf("error attaching kretprobe %s: %v", eName, err)
}
Expand Down

0 comments on commit 5dc755f

Please sign in to comment.