]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
bypass: af-packet: fix memory leak - reassign of EBPFBypassData
authorLukas Sismis <lukas.sismis@gmail.com>
Sat, 21 May 2022 06:30:06 +0000 (08:30 +0200)
committerVictor Julien <vjulien@oisf.net>
Mon, 13 Jun 2022 18:54:45 +0000 (20:54 +0200)
AF-Packet bypass function in some situations allocates EBPF bypass data
for an already bypassed flow and assigns it to the flow without any checks

Issue: #5368
(cherry picked from commit 8845c07a90ff6ad8304c25f6ccdd495623d35d53)

src/source-af-packet.c

index 0cf20eb465ca8c9028e9d298e8a89244a939fbf7..db8d79307d5c2759d974a838c02ce7c5f1f9b7c3 100644 (file)
@@ -2380,6 +2380,12 @@ static int AFPSetFlowStorage(Packet *p, int map_fd, void *key0, void* key1,
 {
     FlowBypassInfo *fc = FlowGetStorageById(p->flow, GetFlowBypassInfoID());
     if (fc) {
+        if (fc->bypass_data != NULL) {
+            // bypass already activated
+            SCFree(key0);
+            SCFree(key1);
+            return 1;
+        }
         EBPFBypassData *eb = SCCalloc(1, sizeof(EBPFBypassData));
         if (eb == NULL) {
             EBPFDeleteKey(map_fd, key0);