]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4561: Tsanity1
authorRuss Combs (rucombs) <rucombs@cisco.com>
Tue, 7 Jan 2025 14:49:39 +0000 (14:49 +0000)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Tue, 7 Jan 2025 14:49:39 +0000 (14:49 +0000)
Merge in SNORT/snort3 from ~RUCOMBS/snort3:tsanity1 to master

Squashed commit of the following:

commit ddec702eca36358fe5238fa2cee3664bc20d0f9d
Author: Russ Combs <rucombs@cisco.com>
Date:   Thu Dec 19 09:47:37 2024 -0500

    data_bus: fix publisher registration data races

commit da6d5590d82cd4d123029f00e4b18d4de46bf72d
Author: Russ Combs <rucombs@cisco.com>
Date:   Thu Dec 19 07:42:03 2024 -0500

    hyperscan: fix debug log tsan issue

14 files changed:
src/detection/detection_options.cc
src/network_inspectors/appid/appid_inspector.cc
src/network_inspectors/reputation/reputation_inspect.cc
src/network_inspectors/rna/rna_inspector.cc
src/service_inspectors/cip/cip.cc
src/service_inspectors/dce_rpc/dce_tcp.cc
src/service_inspectors/dns/dns.cc
src/service_inspectors/ftp_telnet/ftp.cc
src/service_inspectors/http_inspect/http_inspect.cc
src/service_inspectors/netflow/netflow.cc
src/service_inspectors/sip/sip.cc
src/service_inspectors/ssh/ssh.cc
src/service_inspectors/ssl/ssl_inspector.cc
src/stream/stream.cc

index a5e9d7b68f63c3193e8856b035b8e3feebb57d0a..14a8dcbb09bfbe86df4e06ec5cdaf687c39187f6 100644 (file)
@@ -290,6 +290,9 @@ void* add_detection_option(SnortConfig* sc, option_type_t type, void* option_dat
 void print_option_tree(detection_option_tree_node_t* node, int level)
 {
 #ifdef DEBUG_MSGS
+    if ( !trace_enabled(detection_trace, TRACE_OPTION_TREE) )
+        return;
+
     char buf[32];
     const char* opt;
 
index 0138dbff0fb2f3c849294c04ae8943045eb9d4cd..1a3d58f252b9ba91d9b2edf206373f4608c98749 100644 (file)
@@ -165,7 +165,9 @@ bool AppIdInspector::configure(SnortConfig* sc)
     DataBus::subscribe_global(intrinsic_pub_key, IntrinsicEventIds::FLOW_NO_SERVICE,
          new AppIdServiceEventHandler(*this), *sc);
 
-    cached_global_pub_id = DataBus::get_id(appid_pub_key);
+    if (!cached_global_pub_id)
+        cached_global_pub_id = DataBus::get_id(appid_pub_key);
+
     appid_pub_id = cached_global_pub_id;
     return true;
 }
index b033d13bf2d26e699dc65978e2e027c9dc47a063..0cb23784d054b1563334c80c7f7aeb7e7d075f42 100644 (file)
@@ -583,7 +583,9 @@ bool Reputation::configure(SnortConfig*)
     DataBus::subscribe_network(intrinsic_pub_key, IntrinsicEventIds::AUXILIARY_IP, new AuxiliaryIpRepHandler(*this));
     DataBus::subscribe_network(intrinsic_pub_key, IntrinsicEventIds::PKT_WITHOUT_FLOW, new IpRepHandler(*this));
 
-    pub_id = DataBus::get_id(reputation_pub_key);
+    if (!pub_id)
+        pub_id = DataBus::get_id(reputation_pub_key);
+
     return true;
 }
 
index bdd8ccf620658027315a40d053d4677a698fadbd..36f5ce57e0af64b0fae8fdd28c0073cc853f6479 100644 (file)
@@ -94,7 +94,8 @@ RnaInspector::~RnaInspector()
 
 bool RnaInspector::configure(SnortConfig*)
 {
-    RnaConfig::pub_id = DataBus::get_id(rna_pub_key);
+    if (!RnaConfig::pub_id)
+        RnaConfig::pub_id = DataBus::get_id(rna_pub_key);
 
     DataBus::subscribe_network( appid_pub_key, AppIdEventIds::ANY_CHANGE, new RnaAppidEventHandler(*pnd) );
     DataBus::subscribe_network( appid_pub_key, AppIdEventIds::DHCP_INFO, new RnaDHCPInfoEventHandler(*pnd) );
index d143e4a95218e42914a19fb4c7fb9b6f27c66e89..562de43e8bcf548d0e8cbca5132220c05063237b 100644 (file)
@@ -267,21 +267,16 @@ private:
 };
 
 Cip::Cip(CipProtoConf* pc)
-{
-    config = pc;
-}
+{ config = pc; }
 
 Cip::~Cip()
-{
-    if (config)
-    {
-        delete config;
-    }
-}
+{ delete config; }
 
 bool Cip::configure(SnortConfig*)
 {
-    CipEventData::pub_id = DataBus::get_id(cip_pub_key);
+    if (!CipEventData::pub_id)
+        CipEventData::pub_id = DataBus::get_id(cip_pub_key);
+
     return true;
 }
 
index ee469a4ac6ddcf386b409050e97d0be7611340be..05fed1bb7ec08f13ce00f605434cccf451990152 100644 (file)
@@ -119,7 +119,10 @@ Dce2Tcp::Dce2Tcp(const dce2TcpProtoConf& pc) :
 bool Dce2Tcp::configure(snort::SnortConfig* sc)
 {
     esm.set_proto_id(sc->proto_ref->add(DCE_RPC_SERVICE_NAME));
-    pub_id = DataBus::get_id(dce_tcp_pub_key);
+
+    if (!pub_id)
+        pub_id = DataBus::get_id(dce_tcp_pub_key);
+
     return true;
 }
 
index 78951c4a6253fba65b204b0b7ea904128ad32415..16544a91b164bac78e4c35a912717913ebae5411 100644 (file)
@@ -1113,7 +1113,9 @@ void Dns::eval(Packet* p)
 
 bool Dns::configure(snort::SnortConfig*)
 {
-    pub_id = DataBus::get_id(dns_pub_key);
+    if ( !pub_id )
+        pub_id = DataBus::get_id(dns_pub_key);
+
     return true;
 }
 
index 51f67c42243ea972ab78a4cb997892d591168ecc..5190890b0a4722e23c28b50877db2c28682778c9 100644 (file)
@@ -263,7 +263,9 @@ FtpServer::~FtpServer ()
 
 bool FtpServer::configure(SnortConfig* sc)
 {
-    pub_id = DataBus::get_id(ftp_pub_key);
+    if ( !pub_id )
+        pub_id = DataBus::get_id(ftp_pub_key);
+
     ftp_data_snort_protocol_id = sc->proto_ref->add("ftp-data");
     return !FTPCheckConfigs(sc, ftp_server);
 }
index 6aeebca0076089afddba4c26b98d42afb70c4388..a2321d350d8937df4cc89678b55191c99f3817b8 100755 (executable)
@@ -141,7 +141,9 @@ bool HttpInspect::configure(SnortConfig* sc)
 {
     params->js_norm_param.configure();
     params->mime_decode_conf->sync_all_depths(sc);
-    pub_id = DataBus::get_id(http_pub_key);
+
+    if (!pub_id)
+        pub_id = DataBus::get_id(http_pub_key);
 
     return true;
 }
index db6094e724aa2e54d21d19c17947a17ed8175ba4..9728762474d25cfa4f78f1df972311976914c7fa 100644 (file)
@@ -843,7 +843,9 @@ static std::string to_string(const std::vector <int>& zones)
 
 bool NetFlowInspector::configure(SnortConfig*)
 {
-    pub_id = DataBus::get_id(netflow_pub_key);
+    if ( !pub_id )
+        pub_id = DataBus::get_id(netflow_pub_key);
+
     return true;
 }
 
index b0dd6a0462a7996e816f5d1194957391ff5590b6..e58dd6b047ec09c464a1893ad85470e9628a6c12 100644 (file)
@@ -245,7 +245,9 @@ Sip::~Sip()
 
 bool Sip::configure(SnortConfig*)
 {
-    SIPData::pub_id = DataBus::get_id(sip_pub_key);
+    if ( !SIPData::pub_id )
+        SIPData::pub_id = DataBus::get_id(sip_pub_key);
+
     return true;
 }
 
index 81789dfc87594aa4dc038a4cd0b1dad6d71aecec..716d20edb74ed4852845b541f29b27e7c38ede48 100644 (file)
@@ -604,7 +604,9 @@ Ssh::~Ssh()
 
 bool Ssh::configure(SnortConfig*)
 {
-    pub_id = DataBus::get_id(ssh_pub_key);
+    if ( !pub_id )
+        pub_id = DataBus::get_id(ssh_pub_key);
+
     return true;
 }
 
index 0fd4fe45aa9301a4dd6580ac90eed3d18b7de008..f576dcc5ed9fe2e3b807e54aa3f8a08253e3f40c 100644 (file)
@@ -514,7 +514,8 @@ void Ssl::eval(Packet* p)
 
 bool Ssl::configure(SnortConfig*)
 {
-    pub_id = DataBus::get_id(ssl_pub_key);
+    if ( !pub_id )
+        pub_id = DataBus::get_id(ssl_pub_key);
 
     DataBus::subscribe(intrinsic_pub_key, IntrinsicEventIds::FINALIZE_PACKET, new SslFinalizePacketHandler());
     DataBus::subscribe(intrinsic_pub_key, IntrinsicEventIds::OPPORTUNISTIC_TLS, new SslStartTlsEventtHandler());
index 3b9a808a6780201aa8026601054944034ebdb24c..d003386cbe052b87345acbd3d33a6b641fc50d2c 100644 (file)
@@ -858,7 +858,10 @@ bool Stream::get_held_pkt_seq(Flow* flow, uint32_t& seq)
 static unsigned stream_pub_id = 0;
 
 void Stream::set_pub_id()
-{ stream_pub_id = DataBus::get_id(stream_pub_key); }
+{
+    if ( !stream_pub_id )
+        stream_pub_id = DataBus::get_id(stream_pub_key);
+}
 
 unsigned Stream::get_pub_id()
 { return stream_pub_id; }