]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
packetpool: reset PacketRelease on return to pool 6581/head
authorVictor Julien <victor@inliniac.net>
Fri, 5 Nov 2021 19:05:43 +0000 (20:05 +0100)
committerVictor Julien <victor@inliniac.net>
Sat, 6 Nov 2021 15:40:17 +0000 (16:40 +0100)
Reset PacketRelease callback to make sure its not set to a capture
specific callback.

As an example:

  0x000055e00af09d35 in AFPReleaseDataFromRing (p=0x7f1d884cb830) at source-af-packet.c:653
  0x000055e00af09dd0 in AFPReleasePacket (p=0x7f1d884cb830) at source-af-packet.c:678
  0x000055e00ab53d7e in TmqhOutputPacketpool (t=0x55e00fb79250, p=0x7f1d884cb830) at tmqh-packetpool.c:465
  0x000055e00af08dec in TmThreadsSlotProcessPkt (tv=0x55e00fb79250, s=0x55e012134790, p=0x7f1d884cb830) at tm-threads.h:201
  0x000055e00af08e70 in TmThreadsCaptureInjectPacket (tv=0x55e00fb79250, p=0x7f1d884cb830) at tm-threads.h:221
  0x000055e00af08f2e in TmThreadsCaptureHandleTimeout (tv=0x55e00fb79250, p=0x0) at tm-threads.h:245
  0x000055e00af0ba76 in ReceiveAFPLoop (tv=0x55e00fb79250, data=0x7f1d884ccb60, slot=0x55e01198e4b0) at source-af-packet.c:1321
  0x000055e00ab55257 in TmThreadsSlotPktAcqLoop (td=0x55e00fb79250) at tm-threads.c:312
  0x00007f1dca9d5609 in start_thread (arg=<optimized out>) at pthread_create.c:477
  0x00007f1dca7c6293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Here the packet was a pseudo packet to handle a timeout condition. But
the ReleasePacket callback was still set to AFPReleasePacket from a
previous use of the Packet.

Bug: #4807.

src/decode.c

index c91b747c51b508405bbda0249e8b332122744776..d75c637522df3d4adfd271b823566b2d80d12c0b 100644 (file)
@@ -172,8 +172,10 @@ void PacketFreeOrRelease(Packet *p)
 {
     if (p->flags & PKT_ALLOC)
         PacketFree(p);
-    else
+    else {
+        p->ReleasePacket = PacketPoolReturnPacket;
         PacketPoolReturnPacket(p);
+    }
 }
 
 /**