From 8d6b185856b9a5dc02548a5d06c1850570c00dd3 Mon Sep 17 00:00:00 2001 From: Eduardo Arias Date: Fri, 9 Aug 2024 09:41:37 -0700 Subject: [PATCH] Removed unnecessary lock to call acmp_process_quick in Pm::evaluate - This was introduced in commit 119a6fc & 7d786b3 because of a potential issue reported in #1573. - The ACMP tree structure is initialized when the operator is initialized. - During transaction execution the ACMP tree structure is only 'read' while traversing the tree (in acmp_process_quick) so this is safe for use in a multi-threaded environment. --- configure.ac | 17 ----------------- src/Makefile.am | 1 - src/operators/pm.cc | 7 ------- src/operators/pm.h | 6 ------ 4 files changed, 31 deletions(-) diff --git a/configure.ac b/configure.ac index 34281a3f01..11cef0b67e 100644 --- a/configure.ac +++ b/configure.ac @@ -316,23 +316,6 @@ AC_ARG_ENABLE(parser-generation, [buildParser=false] ) -# Mutex -AC_ARG_ENABLE(mutex-on-pm, - [AS_HELP_STRING([--enable-mutex-on-pm],[Treats pm operations as a critical section])], - - [case "${enableval}" in - yes) mutexPm=true ;; - no) mutexPm=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-mutex-on-pm) ;; - esac], - - [mutexPm=false] - ) -if test "$mutexPm" == "true"; then - MODSEC_MUTEX_ON_PM="-DMUTEX_ON_PM=1" - AC_SUBST(MODSEC_MUTEX_ON_PM) -fi - if test $buildParser = true; then AC_PROG_YACC diff --git a/src/Makefile.am b/src/Makefile.am index ef9357aac7..6f358655a0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -321,7 +321,6 @@ libmodsecurity_la_CPPFLAGS = \ $(GEOIP_CFLAGS) \ $(GLOBAL_CPPFLAGS) \ $(MODSEC_NO_LOGS) \ - $(MODSEC_MUTEX_ON_PM) \ $(YAJL_CFLAGS) \ $(LMDB_CFLAGS) \ $(PCRE_CFLAGS) \ diff --git a/src/operators/pm.cc b/src/operators/pm.cc index d92fc163f2..ba7039bff4 100644 --- a/src/operators/pm.cc +++ b/src/operators/pm.cc @@ -85,14 +85,7 @@ bool Pm::evaluate(Transaction *transaction, RuleWithActions *rule, pt.parser = m_p; pt.ptr = NULL; const char *match = NULL; -#ifdef MODSEC_MUTEX_ON_PM - { - const std::lock_guard lock(m_mutex); -#endif rc = acmp_process_quick(&pt, &match, input.c_str(), input.length()); -#ifdef MODSEC_MUTEX_ON_PM - } -#endif if (rc >= 0 && transaction) { std::string match_(match?match:""); diff --git a/src/operators/pm.h b/src/operators/pm.h index ed5649af85..d07ba46c59 100644 --- a/src/operators/pm.h +++ b/src/operators/pm.h @@ -53,12 +53,6 @@ class Pm : public Operator { protected: ACMP *m_p; - -#ifdef MODSEC_MUTEX_ON_PM - - private: - std::mutex m_mutex; -#endif };