Skip to content

Commit

Permalink
bypass: af-packet: fix memory leak - reassign of EBPFBypassData
Browse files Browse the repository at this point in the history
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: OISF#5368
  • Loading branch information
lukashino authored and victorjulien committed Jun 9, 2022
1 parent 116df70 commit 395fa4b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/source-af-packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,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);
Expand Down

0 comments on commit 395fa4b

Please sign in to comment.