Skip to content

Commit 3501a18

Browse files
committed
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 owasp-modsecurity#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.
1 parent 7bdc3c8 commit 3501a18

File tree

4 files changed

+0
-36
lines changed

4 files changed

+0
-36
lines changed

configure.ac

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -316,23 +316,6 @@ AC_ARG_ENABLE(parser-generation,
316316
[buildParser=false]
317317
)
318318

319-
# Mutex
320-
AC_ARG_ENABLE(mutex-on-pm,
321-
[AS_HELP_STRING([--enable-mutex-on-pm],[Treats pm operations as a critical section])],
322-
323-
[case "${enableval}" in
324-
yes) mutexPm=true ;;
325-
no) mutexPm=false ;;
326-
*) AC_MSG_ERROR(bad value ${enableval} for --enable-mutex-on-pm) ;;
327-
esac],
328-
329-
[mutexPm=false]
330-
)
331-
if test "$mutexPm" == "true"; then
332-
MODSEC_MUTEX_ON_PM="-DMUTEX_ON_PM=1"
333-
AC_SUBST(MODSEC_MUTEX_ON_PM)
334-
fi
335-
336319

337320
if test $buildParser = true; then
338321
AC_PROG_YACC

src/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ libmodsecurity_la_CPPFLAGS = \
322322
$(GEOIP_CFLAGS) \
323323
$(GLOBAL_CPPFLAGS) \
324324
$(MODSEC_NO_LOGS) \
325-
$(MODSEC_MUTEX_ON_PM) \
326325
$(YAJL_CFLAGS) \
327326
$(LMDB_CFLAGS) \
328327
$(PCRE_CFLAGS) \

src/operators/pm.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ Pm::~Pm() {
3939

4040
free(m_p);
4141
m_p = NULL;
42-
#ifdef MODSEC_MUTEX_ON_PM
43-
pthread_mutex_destroy(&m_lock);
44-
#endif
4542
}
4643

4744

@@ -88,13 +85,7 @@ bool Pm::evaluate(Transaction *transaction, RuleWithActions *rule,
8885
pt.parser = m_p;
8986
pt.ptr = NULL;
9087
const char *match = NULL;
91-
#ifdef MODSEC_MUTEX_ON_PM
92-
pthread_mutex_lock(&m_lock);
93-
#endif
9488
rc = acmp_process_quick(&pt, &match, input.c_str(), input.length());
95-
#ifdef MODSEC_MUTEX_ON_PM
96-
pthread_mutex_unlock(&m_lock);
97-
#endif
9889

9990
if (rc >= 0 && transaction) {
10091
std::string match_(match?match:"");
@@ -118,9 +109,6 @@ bool Pm::init(const std::string &file, std::string *error) {
118109
std::istringstream *iss;
119110
const char *err = NULL;
120111

121-
#ifdef MODSEC_MUTEX_ON_PM
122-
pthread_mutex_init(&m_lock, NULL);
123-
#endif
124112
char *content = parse_pm_content(m_param.c_str(), m_param.length(), &err);
125113
if (content == NULL) {
126114
iss = new std::istringstream(m_param);

src/operators/pm.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ class Pm : public Operator {
5252

5353
protected:
5454
ACMP *m_p;
55-
56-
#ifdef MODSEC_MUTEX_ON_PM
57-
58-
private:
59-
pthread_mutex_t m_lock;
60-
#endif
6155
};
6256

6357

0 commit comments

Comments
 (0)