diff options
author | Kamil Rytarowski <n54@gmx.com> | 2017-12-06 01:03:11 +0000 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2017-12-06 01:03:11 +0000 |
commit | 2d5fd854fbbecd11eca767a2e46ca693848a3e5f (patch) | |
tree | 72d846976b9274cfbe1f862a5e30b4bbe6edbe06 /lib/msan/msan_interceptors.cc | |
parent | 557effc84f4148e9fd0f119e3a777ee57015c0e2 (diff) | |
download | compiler-rt-2d5fd854fbbecd11eca767a2e46ca693848a3e5f.tar.gz |
Disable absent functions in MSan/NetBSD interceptors
Summary:
Disable for NetBSD missing functions missing in this OS:
- mempcpy,
- __libc_memalign,
- malloc_usable_size,
- stpcpy,
- gcvt,
- wmempcpy,
- fcvt.
Sponsored by <The NetBSD Foundation>
Reviewers: joerg, dvyukov, eugenis, vitalybuka, kcc
Reviewed By: vitalybuka
Subscribers: llvm-commits, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D40764
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319866 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/msan/msan_interceptors.cc')
-rw-r--r-- | lib/msan/msan_interceptors.cc | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/lib/msan/msan_interceptors.cc b/lib/msan/msan_interceptors.cc index 45e8014fc..8d59a2ae6 100644 --- a/lib/msan/msan_interceptors.cc +++ b/lib/msan/msan_interceptors.cc @@ -140,9 +140,14 @@ INTERCEPTOR(SSIZE_T, readlink, const char *path, char *buf, SIZE_T bufsiz) { return res; } +#if !SANITIZER_NETBSD INTERCEPTOR(void *, mempcpy, void *dest, const void *src, SIZE_T n) { return (char *)__msan_memcpy(dest, src, n) + n; } +#define MSAN_MAYBE_INTERCEPT_MEMPCPY INTERCEPT_FUNCTION(mempcpy) +#else +#define MSAN_MAYBE_INTERCEPT_MEMPCPY +#endif INTERCEPTOR(void *, memccpy, void *dest, const void *src, int c, SIZE_T n) { ENSURE_MSAN_INITED(); @@ -182,6 +187,7 @@ INTERCEPTOR(void *, aligned_alloc, SIZE_T alignment, SIZE_T size) { return msan_aligned_alloc(alignment, size, &stack); } +#if !SANITIZER_NETBSD INTERCEPTOR(void *, __libc_memalign, SIZE_T alignment, SIZE_T size) { GET_MALLOC_STACK_TRACE; void *ptr = msan_memalign(alignment, size, &stack); @@ -189,6 +195,10 @@ INTERCEPTOR(void *, __libc_memalign, SIZE_T alignment, SIZE_T size) { DTLS_on_libc_memalign(ptr, size); return ptr; } +#define MSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN INTERCEPT_FUNCTION(__libc_memalign) +#else +#define MSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN +#endif INTERCEPTOR(void *, valloc, SIZE_T size) { GET_MALLOC_STACK_TRACE; @@ -222,9 +232,15 @@ INTERCEPTOR(void, cfree, void *ptr) { #define MSAN_MAYBE_INTERCEPT_CFREE #endif +#if !SANITIZER_NETBSD INTERCEPTOR(uptr, malloc_usable_size, void *ptr) { return __sanitizer_get_allocated_size(ptr); } +#define MSAN_MAYBE_INTERCEPT_MALLOC_USABLE_SIZE \ + INTERCEPT_FUNCTION(malloc_usable_size) +#else +#define MSAN_MAYBE_INTERCEPT_MALLOC_USABLE_SIZE +#endif #if !SANITIZER_FREEBSD && !SANITIZER_NETBSD // This function actually returns a struct by value, but we can't unpoison a @@ -285,6 +301,7 @@ INTERCEPTOR(char *, strncpy, char *dest, const char *src, SIZE_T n) { // NOLINT return res; } +#if !SANITIZER_NETBSD INTERCEPTOR(char *, stpcpy, char *dest, const char *src) { // NOLINT ENSURE_MSAN_INITED(); GET_STORE_STACK_TRACE; @@ -294,6 +311,10 @@ INTERCEPTOR(char *, stpcpy, char *dest, const char *src) { // NOLINT CopyShadowAndOrigin(dest, src, n + 1, &stack); return res; } +#define MSAN_MAYBE_INTERCEPT_STPCPY INTERCEPT_FUNCTION(stpcpy) +#else +#define MSAN_MAYBE_INTERCEPT_STPCPY +#endif INTERCEPTOR(char *, strdup, char *src) { ENSURE_MSAN_INITED(); @@ -322,6 +343,7 @@ INTERCEPTOR(char *, __strdup, char *src) { #define MSAN_MAYBE_INTERCEPT___STRDUP #endif +#if !SANITIZER_NETBSD INTERCEPTOR(char *, gcvt, double number, SIZE_T ndigit, char *buf) { ENSURE_MSAN_INITED(); char *res = REAL(gcvt)(number, ndigit, buf); @@ -329,6 +351,10 @@ INTERCEPTOR(char *, gcvt, double number, SIZE_T ndigit, char *buf) { __msan_unpoison(buf, n + 1); return res; } +#define MSAN_MAYBE_INTERCEPT_GCVT INTERCEPT_FUNCTION(gcvr) +#else +#define MSAN_MAYBE_INTERCEPT_GCVT +#endif INTERCEPTOR(char *, strcat, char *dest, const char *src) { // NOLINT ENSURE_MSAN_INITED(); @@ -544,6 +570,7 @@ INTERCEPTOR(wchar_t *, wmemcpy, wchar_t *dest, const wchar_t *src, SIZE_T n) { return res; } +#if !SANITIZER_NETBSD INTERCEPTOR(wchar_t *, wmempcpy, wchar_t *dest, const wchar_t *src, SIZE_T n) { ENSURE_MSAN_INITED(); GET_STORE_STACK_TRACE; @@ -551,6 +578,10 @@ INTERCEPTOR(wchar_t *, wmempcpy, wchar_t *dest, const wchar_t *src, SIZE_T n) { CopyShadowAndOrigin(dest, src, n * sizeof(wchar_t), &stack); return res; } +#define MSAN_MAYBE_INTERCEPT_WMEMPCPY INTERCEPT_FUNCTION(wmempcpy) +#else +#define MSAN_MAYBE_INTERCEPT_WMEMPCPY +#endif INTERCEPTOR(wchar_t *, wmemset, wchar_t *s, wchar_t c, SIZE_T n) { CHECK(MEM_IS_APP(s)); @@ -584,6 +615,7 @@ INTERCEPTOR(int, gettimeofday, void *tv, void *tz) { return res; } +#if !SANITIZER_NETBSD INTERCEPTOR(char *, fcvt, double x, int a, int *b, int *c) { ENSURE_MSAN_INITED(); char *res = REAL(fcvt)(x, a, b, c); @@ -592,6 +624,10 @@ INTERCEPTOR(char *, fcvt, double x, int a, int *b, int *c) { if (res) __msan_unpoison(res, REAL(strlen)(res) + 1); return res; } +#define MSAN_MAYBE_INTERCEPT_FCVT INTERCEPT_FUNCTION(fcvr) +#else +#define MSAN_MAYBE_INTERCEPT_FCVT +#endif INTERCEPTOR(char *, getenv, char *name) { if (msan_init_is_running) @@ -1497,7 +1533,7 @@ void InitializeInterceptors() { MSAN_MAYBE_INTERCEPT_MMAP64; INTERCEPT_FUNCTION(posix_memalign); MSAN_MAYBE_INTERCEPT_MEMALIGN; - INTERCEPT_FUNCTION(__libc_memalign); + MSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN; INTERCEPT_FUNCTION(valloc); MSAN_MAYBE_INTERCEPT_PVALLOC; INTERCEPT_FUNCTION(malloc); @@ -1505,7 +1541,7 @@ void InitializeInterceptors() { INTERCEPT_FUNCTION(realloc); INTERCEPT_FUNCTION(free); MSAN_MAYBE_INTERCEPT_CFREE; - INTERCEPT_FUNCTION(malloc_usable_size); + MSAN_MAYBE_INTERCEPT_MALLOC_USABLE_SIZE; MSAN_MAYBE_INTERCEPT_MALLINFO; MSAN_MAYBE_INTERCEPT_MALLOPT; MSAN_MAYBE_INTERCEPT_MALLOC_STATS; @@ -1513,18 +1549,18 @@ void InitializeInterceptors() { MSAN_MAYBE_INTERCEPT_FREAD_UNLOCKED; INTERCEPT_FUNCTION(readlink); INTERCEPT_FUNCTION(memccpy); - INTERCEPT_FUNCTION(mempcpy); + MSAN_MAYBE_INTERCEPT_MEMPCPY; INTERCEPT_FUNCTION(bcopy); INTERCEPT_FUNCTION(wmemset); INTERCEPT_FUNCTION(wmemcpy); - INTERCEPT_FUNCTION(wmempcpy); + MSAN_MAYBE_INTERCEPT_WMEMPCPY; INTERCEPT_FUNCTION(wmemmove); INTERCEPT_FUNCTION(strcpy); // NOLINT - INTERCEPT_FUNCTION(stpcpy); // NOLINT + MSAN_MAYBE_INTERCEPT_STPCPY; // NOLINT INTERCEPT_FUNCTION(strdup); MSAN_MAYBE_INTERCEPT___STRDUP; INTERCEPT_FUNCTION(strncpy); // NOLINT - INTERCEPT_FUNCTION(gcvt); + MSAN_MAYBE_INTERCEPT_GCVT; INTERCEPT_FUNCTION(strcat); // NOLINT INTERCEPT_FUNCTION(strncat); // NOLINT INTERCEPT_STRTO(strtod); @@ -1570,7 +1606,7 @@ void InitializeInterceptors() { INTERCEPT_FUNCTION(setenv); INTERCEPT_FUNCTION(putenv); INTERCEPT_FUNCTION(gettimeofday); - INTERCEPT_FUNCTION(fcvt); + MSAN_MAYBE_INTERCEPT_FCVT; MSAN_MAYBE_INTERCEPT___FXSTAT; MSAN_INTERCEPT_FSTATAT; MSAN_MAYBE_INTERCEPT___FXSTAT64; |