Fix crash in Analyzer::ForwardPacket due to recursive analyzer calls.

The change in 44f558df7b that made analyzer_list
a std::vector instead of a std::list doesn't take into account that in some
cases an analyzer may chain back into itself, such as with UDP-in-UDP tunnels.
In these cases, the second call to ForwardPacket may cause iterator
invalidation, leading to a crash.
This commit is contained in:
Tim Wojtulewicz 2021-03-24 13:31:36 -07:00
parent 8fb30f1d62
commit 4015beb732
4 changed files with 22 additions and 1 deletions

View file

@ -38,7 +38,12 @@ class AnalyzerTimer;
class SupportAnalyzer;
class OutputHandler;
using analyzer_list = std::vector<Analyzer*>;
// This needs to remain a std::list because of the usage of iterators in the
// Analyzer::Forward methods. These methods have the chance to loop back
// into the same analyzer in the case of tunnels. If the recursive call adds
// to the children list, it can invalidate iterators in the outer call,
// causing a crash.
using analyzer_list = std::list<Analyzer*>;
typedef uint32_t ID;
typedef void (Analyzer::*analyzer_timer_func)(double t);

View file

@ -0,0 +1,12 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
#separator \x09
#set_separator ,
#empty_field (empty)
#unset_field -
#path tunnel
#open XXXX-XX-XX-XX-XX-XX
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p tunnel_type action
#types time string addr port addr port enum enum
XXXXXXXXXX.XXXXXX CHhAvVGS1DHFjwGM9 ::38:5f55:6265:726b 25977 2090:9090:9090:9090:9090:9000:: 25964 Tunnel::TEREDO Tunnel::DISCOVER
XXXXXXXXXX.XXXXXX CHhAvVGS1DHFjwGM9 ::38:5f55:6265:726b 25977 2090:9090:9090:9090:9090:9000:: 25964 Tunnel::TEREDO Tunnel::CLOSE
#close XXXX-XX-XX-XX-XX-XX

Binary file not shown.

View file

@ -0,0 +1,4 @@
# @TEST-EXEC: zeek -r $TRACES/tunnels/teredo-udp-in-udp.pcap %INPUT
# @TEST-EXEC: btest-diff tunnel.log
@load base/frameworks/tunnels