From: Mike Stepanek (mstepane) Date: Wed, 25 Mar 2020 19:40:43 +0000 (+0000) Subject: Merge pull request #2089 in SNORT/snort3 from ~NIHDESAI/snort3:tsan_mime to master X-Git-Tag: 3.0.1-1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f012bc7c3818c9a58500d1e95d3af4bb984e99b;p=thirdparty%2Fsnort3.git Merge pull request #2089 in SNORT/snort3 from ~NIHDESAI/snort3:tsan_mime to master Squashed commit of the following: commit 60962397f8910eb4ade3ff842db5262d3337eeea Author: Nihal Desai Date: Wed Mar 18 04:57:26 2020 -0400 mime: fix data race in mime config --- diff --git a/src/mime/file_mime_config.cc b/src/mime/file_mime_config.cc index 0ab391dd1..aae828259 100644 --- a/src/mime/file_mime_config.cc +++ b/src/mime/file_mime_config.cc @@ -131,8 +131,6 @@ void DecodeConfig::sync_all_depths() int DecodeConfig::get_max_depth(int decode_depth) { - sync_all_depths(); - if ( file_depth and decode_depth ) return (file_depth > decode_depth) ? file_depth : decode_depth; diff --git a/src/service_inspectors/http_inspect/http_inspect.cc b/src/service_inspectors/http_inspect/http_inspect.cc index 8d30233fe..90ddd2331 100644 --- a/src/service_inspectors/http_inspect/http_inspect.cc +++ b/src/service_inspectors/http_inspect/http_inspect.cc @@ -88,6 +88,8 @@ bool HttpInspect::configure(SnortConfig* ) xtra_host_id = Stream::reg_xtra_data_cb(get_xtra_host); xtra_jsnorm_id = Stream::reg_xtra_data_cb(get_xtra_jsnorm); + config_decode(); + return true; } @@ -440,7 +442,8 @@ bool HttpInspect::process(const uint8_t* data, const uint16_t dsize, Flow* const break; case SEC_HEADER: current_section = new HttpMsgHeader( - data, dsize, session_data, source_id, buf_owner, flow, params); + data, dsize, session_data, source_id, buf_owner, flow, params, + decode_conf); break; case SEC_BODY_CL: current_section = new HttpMsgBodyCl( diff --git a/src/service_inspectors/http_inspect/http_inspect.h b/src/service_inspectors/http_inspect/http_inspect.h index ae62c44cb..58ce5f2d4 100644 --- a/src/service_inspectors/http_inspect/http_inspect.h +++ b/src/service_inspectors/http_inspect/http_inspect.h @@ -67,6 +67,7 @@ public: static int get_xtra_uri(snort::Flow*, uint8_t**, uint32_t*, uint32_t*); static int get_xtra_host(snort::Flow*, uint8_t** buf, uint32_t* len, uint32_t* type); static int get_xtra_jsnorm(snort::Flow*, uint8_t**, uint32_t*, uint32_t*); + void config_decode() { decode_conf.sync_all_depths(); } private: friend HttpApi; @@ -84,6 +85,7 @@ private: static uint32_t xtra_uri_id; static uint32_t xtra_host_id; static uint32_t xtra_jsnorm_id; + snort::DecodeConfig decode_conf; }; #endif diff --git a/src/service_inspectors/http_inspect/http_msg_header.cc b/src/service_inspectors/http_inspect/http_msg_header.cc index 855c74507..ac2be52f4 100644 --- a/src/service_inspectors/http_inspect/http_msg_header.cc +++ b/src/service_inspectors/http_inspect/http_msg_header.cc @@ -31,6 +31,7 @@ #include "http_api.h" #include "http_common.h" #include "http_enum.h" +#include "http_inspect.h" #include "http_msg_request.h" #include "http_msg_body.h" #include "pub_sub/http_events.h" @@ -43,8 +44,9 @@ using namespace HttpEnums; HttpMsgHeader::HttpMsgHeader(const uint8_t* buffer, const uint16_t buf_size, HttpFlowData* session_data_, SourceId source_id_, bool buf_owner, Flow* flow_, - const HttpParaList* params_) : - HttpMsgHeadShared(buffer, buf_size, session_data_, source_id_, buf_owner, flow_, params_) + const HttpParaList* params_, DecodeConfig decode_conf_) : + HttpMsgHeadShared(buffer, buf_size, session_data_, source_id_, buf_owner, flow_, params_), + decode_conf(decode_conf_) { transaction->set_header(this, source_id); get_related_sections(); diff --git a/src/service_inspectors/http_inspect/http_msg_header.h b/src/service_inspectors/http_inspect/http_msg_header.h index ce9c7a7d2..16663d5bf 100644 --- a/src/service_inspectors/http_inspect/http_msg_header.h +++ b/src/service_inspectors/http_inspect/http_msg_header.h @@ -36,7 +36,7 @@ class HttpMsgHeader : public HttpMsgHeadShared public: HttpMsgHeader(const uint8_t* buffer, const uint16_t buf_size, HttpFlowData* session_data_, HttpCommon::SourceId source_id_, bool buf_owner, snort::Flow* flow_, - const HttpParaList* params_); + const HttpParaList* params_, snort::DecodeConfig decode_conf); HttpEnums::InspectSection get_inspection_section() const override { return HttpEnums::IS_HEADER; } bool detection_required() const override { return true; }