From 8fa5f3bdd4707e327c346581871c3bd51b8751e4 Mon Sep 17 00:00:00 2001 From: Lukas Sismis Date: Sat, 21 May 2022 08:30:06 +0200 Subject: [PATCH] bypass: af-packet: fix memory leak - reassign of EBPFBypassData 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 0cf20eb465..db8d79307d 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -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); -- 2.47.2