Add a configure option to disable pcre JIT compilation
authorFabian Keil <fk@fabiankeil.de>
Wed, 17 Mar 2021 11:12:42 +0000 (12:12 +0100)
committerFabian Keil <fk@fabiankeil.de>
Sun, 21 Mar 2021 06:58:53 +0000 (07:58 +0100)
While JIT compilation makes filtering faster it can
cause false-positive valgrind complaints like:

    ==94928== Thread 2:
    ==94928== Conditional jump or move depends on uninitialised value(s)
    ==94928==    at 0x40A990B: ???
    ==94928==    by 0x955E761: ???
    ==94928==  Uninitialised value was created by a heap allocation
    ==94928==    at 0x4C26A44: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
    ==94928==    by 0x5114247: BUF_MEM_grow_clean (in /usr/local/lib/libcrypto.so.11)
    ==94928==    by 0x50F2FD2: ??? (in /usr/local/lib/libcrypto.so.11)
    ==94928==    by 0x50EDB7F: ??? (in /usr/local/lib/libcrypto.so.11)
    ==94928==    by 0x50ECD78: ??? (in /usr/local/lib/libcrypto.so.11)
    ==94928==    by 0x50ECC75: BIO_write (in /usr/local/lib/libcrypto.so.11)
    ==94928==    by 0x5C15B0F: ??? (in /usr/local/lib/libssl.so.11)
    ==94928==    by 0x5C422A9: ??? (in /usr/local/lib/libssl.so.11)
    ==94928==    by 0x5C39156: ??? (in /usr/local/lib/libssl.so.11)
    ==94928==    by 0x5C07F9A: ??? (in /usr/local/lib/libssl.so.11)
    ==94928==    by 0x50ED3AA: BIO_ctrl (in /usr/local/lib/libcrypto.so.11)
    ==94928==    by 0x460033: create_server_ssl_connection (openssl.c:1150)

As reported by Gwyn Ciesla in SF bug 924 it also can
cause problems when the SELinux policy does not grant
Privoxy "execmem" privileges.

acconfig.h
configure.in
pcrs.c

index 9ec87fd..d88028b 100644 (file)
  */
 #undef FEATURE_DYNAMIC_PCRE
 
+/*
+ * Should pcrs use pcre JIT compilation if it's supported?
+ */
+#undef DISABLE_PCRE_JIT_COMPILATION
+
 /*
  * Should pcrs be statically built in instead of linkling with libpcrs?
  * (This is determined by configure depending on the availiability of
index cdec6b1..2614cab 100644 (file)
@@ -973,6 +973,12 @@ AC_ARG_ENABLE(pcre-host-patterns,
   AC_DEFINE(FEATURE_PCRE_HOST_PATTERNS)
 fi])
 
+AC_ARG_ENABLE(pcre-jit-compilation,
+[  --disable-pcre-jit-compilation     Don't let pcrs use pcre JIT compilation even if pcre supports it.],
+[if test $enableval != yes; then
+  AC_DEFINE(DISABLE_PCRE_JIT_COMPILATION)
+fi])
+
 AC_ARG_ENABLE(external-filters,
 [  --enable-external-filters       Allow to filter content with scripts and programs. Experimental.],
 [if test $enableval = yes; then
diff --git a/pcrs.c b/pcrs.c
index 8310098..007f7cc 100644 (file)
--- a/pcrs.c
+++ b/pcrs.c
@@ -670,10 +670,14 @@ pcrs_job *pcrs_compile(const char *pattern, const char *substitute, const char *
 
 
 #ifdef PCRE_STUDY_JIT_COMPILE
+#ifdef DISABLE_PCRE_JIT_COMPILATION
+#warning PCRE_STUDY_JIT_COMPILE is supported but Privoxy has been configured not to use it
+#else
    if (!(flags & PCRS_DYNAMIC))
    {
       pcre_study_options = PCRE_STUDY_JIT_COMPILE;
    }
+#endif
 #endif
 
    /*