Project

General

Profile

Actions

Bug #4734

closed

pfring: memory leak

Added by Victor Julien about 3 years ago. Updated 9 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Affected Versions:
Effort:
Difficulty:
Label:

Description

Oct 06 08:57:54 c2758 suricata[10914]: ==10914==ERROR: LeakSanitizer: detected memory leaks
Oct 06 08:57:54 c2758 suricata[10914]: Direct leak of 10000 byte(s) in 4 object(s) allocated from:
Oct 06 08:57:54 c2758 suricata[10914]:     #0 0x7f601e0a8b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
Oct 06 08:57:54 c2758 suricata[10914]:     #1 0x55ac5dfb80ba in SCMallocFunc /home/victor/dev/suricata/src/util-mem.c:30
Oct 06 08:57:54 c2758 suricata[10914]:     #2 0x55ac5e056399 in PacketGetFromAlloc /home/victor/dev/suricata/src/decode.c:152
Oct 06 08:57:54 c2758 suricata[10914]:     #3 0x55ac5df83bd6 in PacketPoolInit /home/victor/dev/suricata/src/tmqh-packetpool.c:323
Oct 06 08:57:54 c2758 suricata[10914]:     #4 0x55ac5df86750 in TmThreadsSlotPktAcqLoop /home/victor/dev/suricata/src/tm-threads.c:242
Oct 06 08:57:54 c2758 suricata[10914]:     #5 0x7f601c51c6da in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76da)
Oct 06 08:57:54 c2758 suricata[10914]: Direct leak of 832 byte(s) in 8 object(s) allocated from:
Oct 06 08:57:54 c2758 suricata[10914]:     #0 0x7f601e0a8b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
Oct 06 08:57:54 c2758 suricata[10914]:     #1 0x55ac5dfb80ba in SCMallocFunc /home/victor/dev/suricata/src/util-mem.c:30
Oct 06 08:57:54 c2758 suricata[10914]:     #2 0x55ac5e28b0b8 in ReceivePfringThreadInit /home/victor/dev/suricata/src/source-pfring.c:493
Oct 06 08:57:54 c2758 suricata[10914]:     #3 0x55ac5df869ef in TmThreadsSlotPktAcqLoop /home/victor/dev/suricata/src/tm-threads.c:258
Oct 06 08:57:54 c2758 suricata[10914]:     #4 0x7f601c51c6da in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76da)
Oct 06 08:57:54 c2758 suricata[10914]: SUMMARY: AddressSanitizer: 10832 byte(s) leaked in 12 allocation(s).

Subtasks 1 (0 open1 closed)

Bug #6812: pfring: memory leak (7.0.x backport)ClosedJason IshActions
Actions #1

Updated by Victor Julien about 3 years ago

More leaks, most likely with the same root cause of some packets getting lost with pfring

Oct 09 08:14:19 c2758 suricata[8565]: Indirect leak of 16 byte(s) in 1 object(s) allocated from:                                                                   
Oct 09 08:14:19 c2758 suricata[8565]:     #0 0x7f551022fb40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)                      
Oct 09 08:14:19 c2758 suricata[8565]:     #1 0x559e11559752 in SCMallocFunc /home/victor/dev/suricata/src/util-mem.c:30                       
Oct 09 08:14:19 c2758 suricata[8565]:     #2 0x559e115987e9 in AppLayerDecoderEventsSetEventRaw /home/victor/dev/suricata/src/app-layer-events.c:92
Oct 09 08:14:19 c2758 suricata[8565]:     #3 0x559e1158c3e9 in TCPProtoDetect /home/victor/dev/suricata/src/app-layer.c:530           
Oct 09 08:14:19 c2758 suricata[8565]:     #4 0x559e1158ca42 in AppLayerHandleTCPData /home/victor/dev/suricata/src/app-layer.c:636
Oct 09 08:14:19 c2758 suricata[8565]:     #5 0x559e11882f11 in ReassembleUpdateAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1190
Oct 09 08:14:19 c2758 suricata[8565]:     #6 0x559e118834d5 in StreamTcpReassembleAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1253
Oct 09 08:14:19 c2758 suricata[8565]:     #7 0x559e11886c0b in StreamTcpReassembleHandleSegmentUpdateACK /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1822
Oct 09 08:14:19 c2758 suricata[8565]:     #8 0x559e11886f22 in StreamTcpReassembleHandleSegment /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1867
Oct 09 08:14:19 c2758 suricata[8565]:     #9 0x559e11844eaa in HandleEstablishedPacketToServer /home/victor/dev/suricata/src/stream-tcp.c:2320
Oct 09 08:14:19 c2758 suricata[8565]:     #10 0x559e11849f37 in StreamTcpPacketStateEstablished /home/victor/dev/suricata/src/stream-tcp.c:2751
Oct 09 08:14:19 c2758 suricata[8565]:     #11 0x559e1186657a in StreamTcpStateDispatch /home/victor/dev/suricata/src/stream-tcp.c:4777
Oct 09 08:14:19 c2758 suricata[8565]:     #12 0x559e11867b99 in StreamTcpPacket /home/victor/dev/suricata/src/stream-tcp.c:4966
Oct 09 08:14:19 c2758 suricata[8565]:     #13 0x559e1186962e in StreamTcp /home/victor/dev/suricata/src/stream-tcp.c:5304
Oct 09 08:14:19 c2758 suricata[8565]:     #14 0x559e11778c4e in FlowWorkerStreamTCPUpdate /home/victor/dev/suricata/src/flow-worker.c:369
Oct 09 08:14:19 c2758 suricata[8565]:     #15 0x559e11779d2a in FlowWorker /home/victor/dev/suricata/src/flow-worker.c:535
Oct 09 08:14:19 c2758 suricata[8565]:     #16 0x559e11526fc5 in TmThreadsSlotVarRun /home/victor/dev/suricata/src/tm-threads.c:117
Oct 09 08:14:19 c2758 suricata[8565]:     #17 0x559e1182a68a in TmThreadsSlotProcessPkt /home/victor/dev/suricata/src/tm-threads.h:195
Oct 09 08:14:19 c2758 suricata[8565]:     #18 0x559e1182cc71 in ReceivePfringLoop /home/victor/dev/suricata/src/source-pfring.c:415
Oct 09 08:14:19 c2758 suricata[8565]:     #19 0x559e1152814a in TmThreadsSlotPktAcqLoop /home/victor/dev/suricata/src/tm-threads.c:312
Oct 09 08:14:19 c2758 suricata[8565]:     #20 0x7f550e6a36da in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76da)
Oct 09 08:14:19 c2758 suricata[8565]: Indirect leak of 16 byte(s) in 1 object(s) allocated from:
Oct 09 08:14:19 c2758 suricata[8565]:     #0 0x7f551022fb40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
Oct 09 08:14:19 c2758 suricata[8565]:     #1 0x559e11559752 in SCMallocFunc /home/victor/dev/suricata/src/util-mem.c:30
Oct 09 08:14:19 c2758 suricata[8565]:     #2 0x559e115987e9 in AppLayerDecoderEventsSetEventRaw /home/victor/dev/suricata/src/app-layer-events.c:92
Oct 09 08:14:19 c2758 suricata[8565]:     #3 0x559e1158c3e9 in TCPProtoDetect /home/victor/dev/suricata/src/app-layer.c:530
Oct 09 08:14:19 c2758 suricata[8565]:     #4 0x559e1158ca42 in AppLayerHandleTCPData /home/victor/dev/suricata/src/app-layer.c:636
Oct 09 08:14:19 c2758 suricata[8565]:     #5 0x559e11882f11 in ReassembleUpdateAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1190
Oct 09 08:14:19 c2758 suricata[8565]:     #6 0x559e118834d5 in StreamTcpReassembleAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1253
Oct 09 08:14:19 c2758 suricata[8565]:     #7 0x559e1158af4f in TCPProtoDetectTriggerOpposingSide /home/victor/dev/suricata/src/app-layer.c:290
Oct 09 08:14:19 c2758 suricata[8565]:     #8 0x559e1158b850 in TCPProtoDetect /home/victor/dev/suricata/src/app-layer.c:394
Oct 09 08:14:19 c2758 suricata[8565]:     #9 0x559e1158ca42 in AppLayerHandleTCPData /home/victor/dev/suricata/src/app-layer.c:636
Oct 09 08:14:19 c2758 suricata[8565]:     #10 0x559e11882f11 in ReassembleUpdateAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1190
Oct 09 08:14:19 c2758 suricata[8565]:     #11 0x559e118834d5 in StreamTcpReassembleAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1253
Oct 09 08:14:19 c2758 suricata[8565]:     #12 0x559e11886c0b in StreamTcpReassembleHandleSegmentUpdateACK /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1822
Oct 09 08:14:19 c2758 suricata[8565]:     #13 0x559e11886f22 in StreamTcpReassembleHandleSegment /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1867
Oct 09 08:14:19 c2758 suricata[8565]:     #14 0x559e11844eaa in HandleEstablishedPacketToServer /home/victor/dev/suricata/src/stream-tcp.c:2320
Oct 09 08:14:19 c2758 suricata[8565]:     #15 0x559e11849f37 in StreamTcpPacketStateEstablished /home/victor/dev/suricata/src/stream-tcp.c:2751
Oct 09 08:14:19 c2758 suricata[8565]:     #16 0x559e1186657a in StreamTcpStateDispatch /home/victor/dev/suricata/src/stream-tcp.c:4777
Oct 09 08:14:19 c2758 suricata[8565]:     #17 0x559e11867b99 in StreamTcpPacket /home/victor/dev/suricata/src/stream-tcp.c:4966
Oct 09 08:14:19 c2758 suricata[8565]:     #18 0x559e1186962e in StreamTcp /home/victor/dev/suricata/src/stream-tcp.c:5304
Oct 09 08:14:19 c2758 suricata[8565]:     #19 0x559e11778c4e in FlowWorkerStreamTCPUpdate /home/victor/dev/suricata/src/flow-worker.c:369
Oct 09 08:14:19 c2758 suricata[8565]:     #20 0x559e11779d2a in FlowWorker /home/victor/dev/suricata/src/flow-worker.c:535
Oct 09 08:14:19 c2758 suricata[8565]:     #21 0x559e11526fc5 in TmThreadsSlotVarRun /home/victor/dev/suricata/src/tm-threads.c:117
Oct 09 08:14:19 c2758 suricata[8565]:     #22 0x559e1182a68a in TmThreadsSlotProcessPkt /home/victor/dev/suricata/src/tm-threads.h:195
Oct 09 08:14:19 c2758 suricata[8565]:     #23 0x559e1182cc71 in ReceivePfringLoop /home/victor/dev/suricata/src/source-pfring.c:415
Oct 09 08:14:19 c2758 suricata[8565]:     #24 0x559e1152814a in TmThreadsSlotPktAcqLoop /home/victor/dev/suricata/src/tm-threads.c:312
Oct 09 08:14:19 c2758 suricata[8565]:     #25 0x7f550e6a36da in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76da)
Oct 09 08:14:19 c2758 suricata[8565]: Indirect leak of 8 byte(s) in 1 object(s) allocated from:
Oct 09 08:14:19 c2758 suricata[8565]:     #0 0x7f551022ff30 in realloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdef30)
Oct 09 08:14:19 c2758 suricata[8565]:     #1 0x559e115599e3 in SCReallocFunc /home/victor/dev/suricata/src/util-mem.c:44
Oct 09 08:14:19 c2758 suricata[8565]:     #2 0x559e11598a8c in AppLayerDecoderEventsSetEventRaw /home/victor/dev/suricata/src/app-layer-events.c:109
Oct 09 08:14:19 c2758 suricata[8565]:     #3 0x559e1158c3e9 in TCPProtoDetect /home/victor/dev/suricata/src/app-layer.c:530
Oct 09 08:14:19 c2758 suricata[8565]:     #4 0x559e1158ca42 in AppLayerHandleTCPData /home/victor/dev/suricata/src/app-layer.c:636
Oct 09 08:14:19 c2758 suricata[8565]:     #5 0x559e11882f11 in ReassembleUpdateAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1190
Oct 09 08:14:19 c2758 suricata[8565]:     #6 0x559e118834d5 in StreamTcpReassembleAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1253
Oct 09 08:14:19 c2758 suricata[8565]:     #7 0x559e11886c0b in StreamTcpReassembleHandleSegmentUpdateACK /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1822
Oct 09 08:14:19 c2758 suricata[8565]:     #8 0x559e11886f22 in StreamTcpReassembleHandleSegment /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1867
Oct 09 08:14:19 c2758 suricata[8565]:     #9 0x559e11844eaa in HandleEstablishedPacketToServer /home/victor/dev/suricata/src/stream-tcp.c:2320
Oct 09 08:14:19 c2758 suricata[8565]:     #10 0x559e11849f37 in StreamTcpPacketStateEstablished /home/victor/dev/suricata/src/stream-tcp.c:2751
Oct 09 08:14:19 c2758 suricata[8565]:     #11 0x559e1186657a in StreamTcpStateDispatch /home/victor/dev/suricata/src/stream-tcp.c:4777
Oct 09 08:14:19 c2758 suricata[8565]:     #12 0x559e11867b99 in StreamTcpPacket /home/victor/dev/suricata/src/stream-tcp.c:4966
Oct 09 08:14:19 c2758 suricata[8565]:     #13 0x559e1186962e in StreamTcp /home/victor/dev/suricata/src/stream-tcp.c:5304
Oct 09 08:14:19 c2758 suricata[8565]:     #14 0x559e11778c4e in FlowWorkerStreamTCPUpdate /home/victor/dev/suricata/src/flow-worker.c:369
Oct 09 08:14:19 c2758 suricata[8565]:     #15 0x559e11779d2a in FlowWorker /home/victor/dev/suricata/src/flow-worker.c:535
Oct 09 08:14:19 c2758 suricata[8565]:     #16 0x559e11526fc5 in TmThreadsSlotVarRun /home/victor/dev/suricata/src/tm-threads.c:117
Oct 09 08:14:19 c2758 suricata[8565]:     #17 0x559e1182a68a in TmThreadsSlotProcessPkt /home/victor/dev/suricata/src/tm-threads.h:195
Oct 09 08:14:19 c2758 suricata[8565]:     #18 0x559e1182cc71 in ReceivePfringLoop /home/victor/dev/suricata/src/source-pfring.c:415
Oct 09 08:14:19 c2758 suricata[8565]:     #19 0x559e1152814a in TmThreadsSlotPktAcqLoop /home/victor/dev/suricata/src/tm-threads.c:312
Oct 09 08:14:19 c2758 suricata[8565]:     #20 0x7f550e6a36da in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76da)
Oct 09 08:14:19 c2758 suricata[8565]: Indirect leak of 8 byte(s) in 1 object(s) allocated from:
Oct 09 08:14:19 c2758 suricata[8565]:     #0 0x7f551022ff30 in realloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdef30)
Oct 09 08:14:19 c2758 suricata[8565]:     #1 0x559e115599e3 in SCReallocFunc /home/victor/dev/suricata/src/util-mem.c:44
Oct 09 08:14:19 c2758 suricata[8565]:     #2 0x559e11598a8c in AppLayerDecoderEventsSetEventRaw /home/victor/dev/suricata/src/app-layer-events.c:109
Oct 09 08:14:19 c2758 suricata[8565]:     #3 0x559e1158c3e9 in TCPProtoDetect /home/victor/dev/suricata/src/app-layer.c:530
Oct 09 08:14:19 c2758 suricata[8565]:     #4 0x559e1158ca42 in AppLayerHandleTCPData /home/victor/dev/suricata/src/app-layer.c:636
Oct 09 08:14:19 c2758 suricata[8565]:     #5 0x559e11882f11 in ReassembleUpdateAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1190
Oct 09 08:14:19 c2758 suricata[8565]:     #6 0x559e118834d5 in StreamTcpReassembleAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1253
Oct 09 08:14:19 c2758 suricata[8565]:     #7 0x559e1158af4f in TCPProtoDetectTriggerOpposingSide /home/victor/dev/suricata/src/app-layer.c:290
Oct 09 08:14:19 c2758 suricata[8565]:     #8 0x559e1158b850 in TCPProtoDetect /home/victor/dev/suricata/src/app-layer.c:394
Oct 09 08:14:19 c2758 suricata[8565]:     #9 0x559e1158ca42 in AppLayerHandleTCPData /home/victor/dev/suricata/src/app-layer.c:636
Oct 09 08:14:19 c2758 suricata[8565]:     #10 0x559e11882f11 in ReassembleUpdateAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1190
Oct 09 08:14:19 c2758 suricata[8565]:     #11 0x559e118834d5 in StreamTcpReassembleAppLayer /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1253
Oct 09 08:14:19 c2758 suricata[8565]:     #12 0x559e11886c0b in StreamTcpReassembleHandleSegmentUpdateACK /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1822
Oct 09 08:14:19 c2758 suricata[8565]:     #13 0x559e11886f22 in StreamTcpReassembleHandleSegment /home/victor/dev/suricata/src/stream-tcp-reassemble.c:1867
Oct 09 08:14:19 c2758 suricata[8565]:     #14 0x559e11844eaa in HandleEstablishedPacketToServer /home/victor/dev/suricata/src/stream-tcp.c:2320
Oct 09 08:14:19 c2758 suricata[8565]:     #15 0x559e11849f37 in StreamTcpPacketStateEstablished /home/victor/dev/suricata/src/stream-tcp.c:2751
Oct 09 08:14:19 c2758 suricata[8565]:     #16 0x559e1186657a in StreamTcpStateDispatch /home/victor/dev/suricata/src/stream-tcp.c:4777
Oct 09 08:14:19 c2758 suricata[8565]:     #17 0x559e11867b99 in StreamTcpPacket /home/victor/dev/suricata/src/stream-tcp.c:4966
Oct 09 08:14:19 c2758 suricata[8565]:     #18 0x559e1186962e in StreamTcp /home/victor/dev/suricata/src/stream-tcp.c:5304
Oct 09 08:14:19 c2758 suricata[8565]:     #19 0x559e11778c4e in FlowWorkerStreamTCPUpdate /home/victor/dev/suricata/src/flow-worker.c:369
Oct 09 08:14:19 c2758 suricata[8565]:     #20 0x559e11779d2a in FlowWorker /home/victor/dev/suricata/src/flow-worker.c:535
Oct 09 08:14:19 c2758 suricata[8565]:     #21 0x559e11526fc5 in TmThreadsSlotVarRun /home/victor/dev/suricata/src/tm-threads.c:117
Oct 09 08:14:19 c2758 suricata[8565]:     #22 0x559e1182a68a in TmThreadsSlotProcessPkt /home/victor/dev/suricata/src/tm-threads.h:195
Oct 09 08:14:19 c2758 suricata[8565]:     #23 0x559e1182cc71 in ReceivePfringLoop /home/victor/dev/suricata/src/source-pfring.c:415
Oct 09 08:14:19 c2758 suricata[8565]:     #24 0x559e1152814a in TmThreadsSlotPktAcqLoop /home/victor/dev/suricata/src/tm-threads.c:312
Oct 09 08:14:19 c2758 suricata[8565]:     #25 0x7f550e6a36da in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76da)

Actions #2

Updated by Victor Julien about 3 years ago

Not a full fix, but this seems to be a possible leak

diff --git a/src/source-pfring.c b/src/source-pfring.c
index bafd80f15..a7adf59cb 100644
--- a/src/source-pfring.c
+++ b/src/source-pfring.c
@@ -423,6 +423,7 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot)
             }
         } else if (unlikely(r == 0)) {
             if (suricata_ctl_flags & SURICATA_STOP) {
+                TmqhOutputPacketpool(ptv->tv, p);
                 SCReturnInt(TM_ECODE_OK);
             }
 

My pfring setup just broke after a kernel update, so not sure I can test this further.

Actions #3

Updated by Jason Ish 9 months ago

  • Status changed from New to In Review
  • Assignee set to Jason Ish
  • Target version set to 8.0.0-beta1
  • Label Needs backport to 7.0 added
Actions #4

Updated by OISF Ticketbot 9 months ago

  • Subtask #6812 added
Actions #5

Updated by OISF Ticketbot 9 months ago

  • Label deleted (Needs backport to 7.0)
Actions #6

Updated by Jason Ish 9 months ago

  • Status changed from In Review to Resolved
Actions #7

Updated by Jason Ish 9 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF