diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2022-07-24 18:12:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-24 18:12:25 +0200 |
commit | 86a3e4c8c331773156283d365aa6a9b103ca44ff (patch) | |
tree | 2465fac386ae7ea40110544b8f4a1b9f427d4e12 | |
parent | e6b332aa4a1399e33df68998cf8351bccaee3fc4 (diff) |
Add support for Memory sanitizer (#1652)
-rw-r--r-- | .github/workflows/build.yml | 10 | ||||
-rw-r--r-- | configure.ac | 18 | ||||
-rw-r--r-- | src/lib/third_party/src/gcrypt/aesni.c | 5 |
3 files changed, 28 insertions, 5 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2d6e838d..0afdfadb9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -227,6 +227,13 @@ jobs: pcre: "--with-pcre" maxminddb: "--with-maxminddb" msan: "--with-thread-sanitizer" + - compiler: "clang-12" + os: ubuntu-latest + arch: "x86_64" + gcrypt: "" + pcre: "--with-pcre" + maxminddb: "--with-maxminddb" + msan: "--with-memory-sanitizer" - compiler: "cc" os: ubuntu-18.04 arch: "x86_64" @@ -391,7 +398,8 @@ jobs: run: | ./tests/do.sh - name: Test nDPI [UNIT] - if: startsWith(matrix.arch, 'x86_64') && !startsWith(matrix.os, 'windows') + #Some issues with masan + json-c. Disable the test as workaround + if: startsWith(matrix.arch, 'x86_64') && !startsWith(matrix.os, 'windows') && !startsWith(matrix.msan, '--with-memory-sanitizer') run: | ./tests/do-unit.sh - name: Test nDPI [DGA] diff --git a/configure.ac b/configure.ac index 0076d4222..60f8f2274 100644 --- a/configure.ac +++ b/configure.ac @@ -15,6 +15,7 @@ AS_IF([test "${with_only_libndpi+set}" = set],[ AC_ARG_WITH(sanitizer, AS_HELP_STRING([--with-sanitizer], [Build with support for address, undefined and leak sanitizer])) AC_ARG_WITH(thread-sanitizer, AS_HELP_STRING([--with-thread-sanitizer], [Build with support for thread sanitizer])) +AC_ARG_WITH(memory-sanitizer, AS_HELP_STRING([--with-memory-sanitizer], [Build with support for memory sanitizer])) AC_ARG_ENABLE(fuzztargets, AS_HELP_STRING([--enable-fuzztargets], [Enable fuzz targets]),[enable_fuzztargets=$enableval],[enable_fuzztargets=no]) AC_ARG_ENABLE(gprof, AS_HELP_STRING([--enable-gprof], [Enable CPU/HEAP profiling with gperftools]),[enable_gprof=$enableval],[enable_gprof=no]) AC_ARG_ENABLE(code-coverage, AS_HELP_STRING([--enable-code-coverage], [Generate Code Coverage report])) @@ -28,14 +29,20 @@ AM_CONDITIONAL([BUILD_FUZZTARGETS], [test "x$enable_fuzztargets" = "xyes"]) AS_IF([test "${with_sanitizer+set}" = set -a "${with_thread_sanitizer+set}" = set],[ AC_MSG_ERROR([Configure options `--with-sanitizer' and `--with_thread_sanitizer' can not used at the same time.]) ]) -AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set],[ +AS_IF([test "${with_sanitizer+set}" = set -a "${with_memory_sanitizer+set}" = set],[ + AC_MSG_ERROR([Configure options `--with-sanitizer' and `--with_memory_sanitizer' can not used at the same time.]) +]) +AS_IF([test "${with_thread_sanitizer+set}" = set -a "${with_memory_sanitizer+set}" = set],[ + AC_MSG_ERROR([Configure options `--with_thread_sanitizer' and `--with_memory_sanitizer' can not used at the same time.]) +]) +AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set -o "${with_memory_sanitizer+set}" = set],[ NDPI_CFLAGS="${NDPI_CFLAGS} -O0 -g3" ],[ NDPI_CFLAGS="${NDPI_CFLAGS} -O2" ]) -AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set],[ +AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set -o "${with_memory_sanitizer+set}" = set],[ AS_IF([test "x$enable_gprof" = "xyes"], [ - AC_MSG_ERROR([Configure options `--with-sanitizer' / `--with_thread_sanitizer' can not used together with `--enable-gprof'.]) + AC_MSG_ERROR([Configure options `--with-sanitizer' / `--with_thread_sanitizer' / `--with_memory_sanitizer' can not used together with `--enable-gprof'.]) ]) ]) @@ -49,6 +56,11 @@ AS_IF([test "${with_thread_sanitizer+set}" = set],[ NDPI_LDFLAGS="${NDPI_LDFLAGS} -fsanitize=thread" ]) +AS_IF([test "${with_memory_sanitizer+set}" = set],[ + NDPI_CFLAGS="${CFLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer" + NDPI_LDFLAGS="${LDFLAGS} -fsanitize=memory" +]) + AS_IF([test "x${enable_code_coverage}" = "xyes"],[ NDPI_CFLAGS="${NDPI_CFLAGS} -fprofile-arcs -ftest-coverage" NDPI_LDFLAGS="${NDPI_LDFLAGS} --coverage" diff --git a/src/lib/third_party/src/gcrypt/aesni.c b/src/lib/third_party/src/gcrypt/aesni.c index f20b0051c..db5c92eb6 100644 --- a/src/lib/third_party/src/gcrypt/aesni.c +++ b/src/lib/third_party/src/gcrypt/aesni.c @@ -25,7 +25,10 @@ #if defined(__has_feature) #if __has_feature(memory_sanitizer) -#warning "MBEDTLS_AESNI_C is known to cause spurious error reports with some memory sanitizers as they do not understand the assembly code." +/* Using "#pragma message" instead of "#warning" to allow compilation with -Werror. + This pragma directive should be supported from every compilers supporting also memory sanitizer +*/ +#pragma message "MBEDTLS_AESNI_C is known to cause spurious error reports with some memory sanitizers as they do not understand the assembly code." #endif #endif |