fuzz/mutator_aux: make sure msan is triggered

consume() does a read over a chunk of data to make sure it is
addressable and completely initialised. that, however, is not enough
to trigger msan - you need to either branch on uninitialised memory,
or use __msan_check_mem_is_initialized(). for clarity, opt for the
latter.
This commit is contained in:
pedro martelletto
2020-06-12 15:48:27 +02:00
parent 8339e91c97
commit 7f9f1d1e8c
3 changed files with 5 additions and 4 deletions

View File

@@ -12,10 +12,6 @@
#include "mutator_aux.h"
#ifdef WITH_MSAN
#include <sanitizer/msan_interface.h>
#endif
static bool debug;
static unsigned long long test_fail;
static unsigned long long test_total;

View File

@@ -35,6 +35,10 @@ consume(const void *body, size_t len)
const volatile uint8_t *ptr = body;
volatile uint8_t x = 0;
#ifdef WITH_MSAN
__msan_check_mem_is_initialized(body, len);
#endif
while (len--)
x ^= *ptr++;
}

View File

@@ -23,6 +23,7 @@
#if defined(__has_feature)
# if __has_feature(memory_sanitizer)
# include <sanitizer/msan_interface.h>
# define NO_MSAN __attribute__((no_sanitize("memory")))
# define WITH_MSAN 1
# endif