]> git.ipfire.org Git - thirdparty/suricata.git/commit
detect: inspect all packets in multi-layer tunneling 9643/head
authorVictor Julien <vjulien@oisf.net>
Fri, 13 Oct 2023 11:47:05 +0000 (13:47 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 17 Oct 2023 15:50:44 +0000 (17:50 +0200)
commit0ada1d561f319ac86f6acdcd9ce890fd646ab54f
tree1ffccd88d60887a53f08bcc289d49ec29536e83a
parent07cc6a2a5f88cb0e540b8f91e6bb33f42435adff
detect: inspect all packets in multi-layer tunneling

When the decoders encounter multiple layers of tunneling, multiple tunnel
packets are created. These are then stored in ThreadVars::decode_pq, where
they are processed after the current thread "slot" is done. However, due
to a logic error, the tunnel packets after the first, where not called
for the correct position in the packet pipeline. This would lead to these
packets not going through the FlowWorker module, so skipping everything
from flow tracking, detection and logging.

This would only happen for single and workers, due to how the pipelines
are constructed.

The "slot" holding the decoder, would contain 2 packets in
ThreadVars::decode_pq. Then it would call the pipeline on the first
packet with the next slot of the pipeline through a indirect call to
TmThreadsSlotVarRun(), so it would be called for the FlowWorker.
However when that first (the most inner) packet was done, the call
to TmThreadsSlotVarRun() would again service the ThreadVars::decode_pq
and process it, again moving the slot pointer forward, so past the
FlowWorker.

This patch addresses the issue by making sure only a "decode" thread
slot will service the ThreadVars::decode_pq, thus never moving the
slot past the FlowWorker.

Bug: #6402.
(cherry picked from commit 15947f21736662ca5997dbc075b4ec9a7f5a304d)
src/tm-threads.c
src/tm-threads.h