]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2375 in SNORT/snort3 from ~DAVMCPHE/snort3:stream_tcp_cleanup_onl...
authorRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 7 Aug 2020 16:53:12 +0000 (16:53 +0000)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 7 Aug 2020 16:53:12 +0000 (16:53 +0000)
Squashed commit of the following:

commit 8cb61ff4d038c75c12b099cb85bb9b48a7ff782e
Author: davis mcpherson <davmcphe@cisco.com>
Date:   Tue Aug 4 07:38:45 2020 -0400

    stream_tcp: add check to prevent reentry to TCP session cleanup when flushing a pdu

src/stream/tcp/tcp_state_time_wait.cc
src/stream/tcp/tcp_stream_session.cc
src/stream/tcp/tcp_stream_session.h

index 2787bae09f9715e95763a348fa4ad6ff9fc93cac..9c4351809d3587db254a4cf97bf98d34e7b50c21 100644 (file)
@@ -118,8 +118,7 @@ bool TcpStateTimeWait::do_post_sm_packet_actions(TcpSegmentDescriptor& tsd, TcpS
         if ( ( talker_state == TcpStreamTracker::TCP_TIME_WAIT )
             || ( talker_state == TcpStreamTracker::TCP_CLOSED ) )
         {
-            // The last ACK is a part of the session. Delete the session after processing is
-            // complete.
+            // The last ACK is a part of the session. Delete session after processing is complete.
             trk.session->clear_session(false, true, false, tsd.is_meta_ack_packet() ? nullptr : tsd.get_pkt() );
             flow->session_state |= STREAM_STATE_CLOSED;
             trk.session->set_pkt_action_flag(ACTION_LWSSN_CLOSED);
index dc4c9a614246196419d9925b42046f76abe8281b..33ba85267ac7d3f8b8d73ed38ce17f7ac8a6f70e 100644 (file)
@@ -360,6 +360,7 @@ bool TcpStreamSession::setup(Packet*)
     server.init_tcp_state();
     lws_init = tcp_init = false;
     generate_3whs_alert = true;
+    cleaning = false;
     pkt_action_mask = ACTION_NOTHING;
     ecn = 0;
     ingress_index = egress_index = 0;
@@ -372,9 +373,16 @@ bool TcpStreamSession::setup(Packet*)
 
 void TcpStreamSession::cleanup(Packet* p)
 {
+    if ( cleaning )
+        return;
+
+    cleaning = true;
     clear_session(true, true, false, p);
     client.normalizer.reset();
+    server.normalizer.reset();
+    client.reassembler.reset();
     server.reassembler.reset();
+    cleaning = false;
 }
 
 void TcpStreamSession::clear()
index ac562c104ab2476a757d6f88cafdafcef0e0c51b..32054907eb74dab19bcffe5820fab4d35dbd235c 100644 (file)
@@ -130,6 +130,7 @@ public:
 
 private:
     bool no_ack = false;
+    bool cleaning = false;
 
 protected:
     TcpStreamSession(snort::Flow*);