]> git.ipfire.org Git - thirdparty/suricata.git/commit
flow/bypass: use_cnt desync'd on bypassed flows 6603/head
authorVictor Julien <victor@inliniac.net>
Wed, 20 Oct 2021 11:20:32 +0000 (13:20 +0200)
committerVictor Julien <vjulien@oisf.net>
Fri, 12 Nov 2021 09:34:26 +0000 (10:34 +0100)
commit38c19b9e8b8acdcd8ed287c7f08a0a56f86b022b
tree63d977b28bebf6b0b92fc231d895a0b33a6cbdc3
parenta3f88cb6f201f61547d593c580336c94bbb1ae3e
flow/bypass: use_cnt desync'd on bypassed flows

Locally bypassed flows had unsafe updates to `Flow::use_cnt` leading to a race
issue. For a packet it would do the flow lookup, attach the flow to the packet,
increment the `use_cnt`. Then it would detect that the flow is in the bypass
state, and unlock it while holding a reference (so alos not decrementing the
`use_cnt`). When the packet was then returned to the packet pool, the flow would
be disconnected from the packet, which would decrement `use_cnt` without holding
the flow lock.

This patch addresses this issue by disconnecting the flow from the packet
immediately when the bypassed state is detected. This moves the `use_cnt`
decrement to within the lock.

Bug: #4766.
(cherry picked from commit ec7e0561e8356371c7ec1c2b285f267424558f81)
src/flow-worker.c