From 3883d8f1af1454260472a712d54aab806a7b5ecd Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 10 Jul 2017 15:31:11 +0100 Subject: [PATCH] fix a minor leak in ebfp fdinstall_pids table when we got an fd install event but the pid was dead by time we processed it, we would fail to remove the watcher for that pid from the fdinstall_pids table. This is a minor, and bounded, leak, since the table only contains pids that were alive when we initialized ebpf. And this change only plugs that leak very partially, since we will never remove pids that die while sitting in accept(). --- probe/endpoint/ebpf.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/probe/endpoint/ebpf.go b/probe/endpoint/ebpf.go index b6faa704b..7b1708952 100644 --- a/probe/endpoint/ebpf.go +++ b/probe/endpoint/ebpf.go @@ -172,6 +172,9 @@ func tupleFromPidFd(pid int, fd int) (tuple fourTuple, netns string, ok bool) { } func (t *EbpfTracker) handleFdInstall(ev tracer.EventType, pid int, fd int) { + if !process.IsProcInAccept("/proc", strconv.Itoa(pid)) { + t.tracer.RemoveFdInstallWatcher(uint32(pid)) + } tuple, netns, ok := tupleFromPidFd(pid, fd) log.Debugf("EbpfTracker: got fd-install event: pid=%d fd=%d -> tuple=%s netns=%s ok=%v", pid, fd, tuple, netns, ok) if !ok { @@ -183,9 +186,6 @@ func (t *EbpfTracker) handleFdInstall(ev tracer.EventType, pid int, fd int) { pid: pid, networkNamespace: netns, } - if !process.IsProcInAccept("/proc", strconv.Itoa(pid)) { - t.tracer.RemoveFdInstallWatcher(uint32(pid)) - } } func (t *EbpfTracker) handleConnection(ev tracer.EventType, tuple fourTuple, pid int, networkNamespace string) {