]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3520: Fix tsan warning
authorOleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) <oshumeik@cisco.com>
Tue, 26 Jul 2022 15:01:55 +0000 (15:01 +0000)
committerOleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) <oshumeik@cisco.com>
Tue, 26 Jul 2022 15:01:55 +0000 (15:01 +0000)
Merge in SNORT/snort3 from ~VHORBAN/snort3:fix_tsan_warning to master

Squashed commit of the following:

commit 2b4ebd297a3b7088f6b4ba46e1b12698d876423f
Author: Oleksandr Serhiienko <oserhiie@cisco.com>
Date:   Sat Jul 16 18:41:34 2022 +0300

    utils: add static initialization of norm_names

commit 217831f9c1de3ea40bde105c7efc92e742447941
Author: Volodymyr Horban <vhorban@cisco.com>
Date:   Mon Jul 18 15:20:58 2022 +0300

    http_inspect: remove dependency of JS normalization depth on HTTP depth

src/service_inspectors/http_inspect/http_js_norm.cc
src/service_inspectors/http_inspect/http_js_norm.h
src/service_inspectors/http_inspect/http_msg_body.cc
src/service_inspectors/http_inspect/http_msg_header.cc
src/utils/js_identifier_ctx.cc

index d9e9b4792e7ff6a0a51c840f484db581e972daa4..ce7a7c09d8684b57a3080cc9be8b4792e029dc4d 100644 (file)
@@ -83,7 +83,6 @@ HttpJsNorm::HttpJsNorm(const HttpParaList::UriParam& uri_param_,
     const HttpParaList::JsNormParam& js_norm_param_) :
     uri_param(uri_param_),
     js_norm_param(js_norm_param_),
-    detection_depth(UINT64_MAX),
     mpse_otag(nullptr),
     mpse_attr(nullptr),
     mpse_type(nullptr)
@@ -252,7 +251,7 @@ void HttpJsNorm::do_external(const Field& input, Field& output,
     debug_logf(4, http_trace, TRACE_JS_PROC, current_packet,
         "input data was %s\n", final_portion ? "last one in PDU" : "a part of PDU");
 
-    uint32_t data_len = std::min(detection_depth, js_ctx.script_size());
+    uint32_t data_len = js_ctx.script_size();
 
     if (data_len)
     {
@@ -402,7 +401,7 @@ void HttpJsNorm::do_inline(const Field& input, Field& output,
         "input data was %s\n", final_portion ? "last one in PDU" : "a part of PDU");
 
     auto js_ctx = ssn->js_normalizer;
-    uint32_t data_len = std::min(detection_depth, js_ctx->script_size());
+    uint32_t data_len = js_ctx->script_size();
 
     if (data_len)
     {
index d8550a157a28d16cea56dacbfe6e516529c2ffaa..90094afc34ebdac844e684bcc391b455da9e32f6 100644 (file)
@@ -40,9 +40,6 @@ public:
         const HttpParaList::JsNormParam& js_norm_param_);
     ~HttpJsNorm();
 
-    void set_detection_depth(size_t depth)
-    { detection_depth = depth; }
-
     void do_legacy(const Field& input, Field& output, HttpInfractions*, HttpEventGen*,
         int max_javascript_whitespaces) const;
     void do_inline(const Field& input, Field& output, HttpInfractions*, HttpFlowData*, bool) const;
@@ -63,7 +60,6 @@ private:
 
     const HttpParaList::UriParam& uri_param;
     const HttpParaList::JsNormParam& js_norm_param;
-    size_t detection_depth;
     bool configure_once = false;
 
     snort::SearchTool* mpse_otag;
index 97b8bd140a9f33162bcc92cbb1107f722fe9986f..8de6f205523bbdef8d0ea5ab35a3c504076d0b17 100644 (file)
@@ -81,8 +81,6 @@ void HttpMsgBody::publish()
 void HttpMsgBody::bookkeeping_regular_flush(uint32_t& partial_detect_length,
     uint8_t*& partial_detect_buffer, uint32_t& partial_js_detect_length, int32_t detect_length)
 {
-    params->js_norm_param.js_norm->set_detection_depth(session_data->detect_depth_remaining[source_id]);
-
     session_data->detect_depth_remaining[source_id] -= detect_length;
     partial_detect_buffer = nullptr;
     partial_detect_length = 0;
index 3e9de469977e001bbd2343e8044f4d519a169d2f..e6053a6f49d034944f642dd4ef9dc1f49a06b41d 100755 (executable)
@@ -453,7 +453,6 @@ void HttpMsgHeader::prepare_body()
         const int64_t& depth = (source_id == SRC_CLIENT) ? params->request_depth :
             params->response_depth;
         session_data->detect_depth_remaining[source_id] = (depth != -1) ? depth : INT64_MAX;
-        params->js_norm_param.js_norm->set_detection_depth(session_data->detect_depth_remaining[source_id]);
     }
     else
     {
index aa6e36a966c861e329e322b01390b6753427d70c..b172d649465df4dd815172d2d43e071346e27991 100644 (file)
@@ -56,13 +56,6 @@ static char norm_names[NORM_NAME_SIZE * NORM_NAME_CNT];
 
 static void init_norm_names()
 {
-    static bool once = false;
-
-    if (once)
-        return;
-
-    once = true;
-
     char* c = norm_names;
     const char hex[] = "0123456789abcdef";
 
@@ -82,14 +75,14 @@ static void init_norm_names()
     assert(sizeof(norm_names) == c - norm_names);
 }
 
+static int _init_norm_names __attribute__((unused)) = (init_norm_names(), 0);
+
 JSIdentifierCtx::JSIdentifierCtx(int32_t depth, uint32_t max_scope_depth,
     const std::unordered_set<std::string>& ignored_ids_list,
     const std::unordered_set<std::string>& ignored_props_list)
     : ignored_ids_list(ignored_ids_list), ignored_props_list(ignored_props_list), 
     max_scope_depth(max_scope_depth)
 {
-    init_norm_names();
-
     norm_name = norm_names;
     norm_name_end = norm_names + NORM_NAME_SIZE * std::min(depth, NORM_NAME_CNT);
     scopes.emplace_back(JSProgramScopeType::GLOBAL);