]> git.ipfire.org Git - thirdparty/suricata.git/commit
threading: don't pass locked flow between threads
authorVictor Julien <victor@inliniac.net>
Wed, 18 Aug 2021 18:14:48 +0000 (20:14 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 23 Aug 2021 15:09:24 +0000 (17:09 +0200)
commit9551cd05357925e8bec8e0030d5f98fd07f17839
treed0020859ca0c8b6582390e376e6072aa032ba9cc
parentcf21694ba6d535d435cfcaefcbb88517bcd4eac4
threading: don't pass locked flow between threads

Previously the flow manager would share evicted flows with the workers
while keeping the flows mutex locked. This reduced the number of unlock/
lock cycles while there was guaranteed to be no contention.

This turns out to be undefined behavior. A lock is supposed to be locked
and unlocked from the same thread. It appears that FreeBSD is stricter on
this than Linux.

This patch addresses the issue by unlocking before handing a flow off
to another thread, and locking again from the new thread.

Issue was reported and largely analyzed by Bill Meeks.

Bug: #4478
src/flow-hash.c
src/flow-manager.c
src/flow-timeout.c
src/flow-worker.c