summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/asan/asan_flags.h2
-rw-r--r--lib/interception/interception.h2
-rw-r--r--lib/msan/msan_interface_internal.h2
-rw-r--r--lib/msan/tests/msan_test.cc32
-rw-r--r--lib/sanitizer_common/sanitizer_internal_defs.h73
-rw-r--r--lib/sanitizer_common/sanitizer_libc.h3
-rw-r--r--lib/sanitizer_common/sanitizer_stackdepot.h2
-rw-r--r--lib/tsan/rtl/tsan_interface.h2
-rw-r--r--lib/tsan/rtl/tsan_interface_ann.h2
9 files changed, 95 insertions, 25 deletions
diff --git a/lib/asan/asan_flags.h b/lib/asan/asan_flags.h
index 6c235bfba..236951e60 100644
--- a/lib/asan/asan_flags.h
+++ b/lib/asan/asan_flags.h
@@ -15,7 +15,7 @@
#ifndef ASAN_FLAGS_H
#define ASAN_FLAGS_H
-#include "sanitizer/common_interface_defs.h"
+#include "sanitizer_common/sanitizer_internal_defs.h"
// ASan flag values can be defined in three ways:
// 1) initialized with default values at startup.
diff --git a/lib/interception/interception.h b/lib/interception/interception.h
index 030bda7cb..63c5a0034 100644
--- a/lib/interception/interception.h
+++ b/lib/interception/interception.h
@@ -19,7 +19,7 @@
# error "Interception doesn't work on this operating system."
#endif
-#include "sanitizer/common_interface_defs.h"
+#include "../sanitizer_common/sanitizer_internal_defs.h"
// These typedefs should be used only in the interceptor definitions to replace
// the standard system types (e.g. SSIZE_T instead of ssize_t)
diff --git a/lib/msan/msan_interface_internal.h b/lib/msan/msan_interface_internal.h
index f9656335c..b7328eaba 100644
--- a/lib/msan/msan_interface_internal.h
+++ b/lib/msan/msan_interface_internal.h
@@ -15,7 +15,7 @@
#ifndef MSAN_INTERFACE_INTERNAL_H
#define MSAN_INTERFACE_INTERNAL_H
-#include <sanitizer/common_interface_defs.h>
+#include "sanitizer_common/sanitizer_internal_defs.h"
extern "C" {
// FIXME: document all interface functions.
diff --git a/lib/msan/tests/msan_test.cc b/lib/msan/tests/msan_test.cc
index 3adf70940..a094360bc 100644
--- a/lib/msan/tests/msan_test.cc
+++ b/lib/msan/tests/msan_test.cc
@@ -56,7 +56,7 @@ typedef signed long long S8; // NOLINT
static bool TrackingOrigins() {
S8 x;
__msan_set_origin(&x, sizeof(x), 0x1234);
- u32 origin = __msan_get_origin(&x);
+ U4 origin = __msan_get_origin(&x);
__msan_set_origin(&x, sizeof(x), 0);
return origin == 0x1234;
}
@@ -82,7 +82,7 @@ static bool TrackingOrigins() {
__msan_set_expect_umr(1); \
action; \
__msan_set_expect_umr(0); \
- u32 id = __msan_get_umr_origin(); \
+ U4 id = __msan_get_umr_origin(); \
const char *str = __msan_get_origin_descr_if_stack(id); \
if (!str || strcmp(str, stack_origin)) { \
fprintf(stderr, "EXPECT_POISONED_S: id=%u %s, %s", \
@@ -114,7 +114,7 @@ void ExpectPoisonedWithOrigin(const T& t, unsigned origin) {
template<typename T>
void ExpectPoisonedWithStackOrigin(const T& t, const char *stack_origin) {
EXPECT_NE(-1, __msan_test_shadow((void*)&t, sizeof(t)));
- u32 id = __msan_get_origin((void*)&t);
+ U4 id = __msan_get_origin((void*)&t);
const char *str = __msan_get_origin_descr_if_stack(id);
if (!str || strcmp(str, stack_origin)) {
fprintf(stderr, "EXPECT_POISONED_S: id=%u %s, %s",
@@ -140,7 +140,7 @@ T *GetPoisoned(int i = 0, T val = 0) {
}
template<class T>
-T *GetPoisonedO(int i, u32 origin, T val = 0) {
+T *GetPoisonedO(int i, U4 origin, T val = 0) {
T *res = (T*)&poisoned_array[i];
*res = val;
__msan_poison(&poisoned_array[i], sizeof(T));
@@ -853,11 +853,11 @@ TEST(MemorySanitizer, ptrtoint) {
// Test that shadow is propagated through pointer-to-integer conversion.
void* p = (void*)0xABCD;
__msan_poison(((char*)&p) + 1, sizeof(p));
- EXPECT_NOT_POISONED((((uptr)p) & 0xFF) == 0);
+ EXPECT_NOT_POISONED((((uintptr_t)p) & 0xFF) == 0);
void* q = (void*)0xABCD;
__msan_poison(&q, sizeof(q) - 1);
- EXPECT_POISONED((((uptr)q) & 0xFF) == 0);
+ EXPECT_POISONED((((uintptr_t)q) & 0xFF) == 0);
}
static void vaargsfn2(int guard, ...) {
@@ -1490,7 +1490,7 @@ TEST(MemorySanitizerOrigins, DISABLED_InitializedStoreDoesNotChangeOrigin) {
if (!TrackingOrigins()) return;
S s;
- u32 origin = rand(); // NOLINT
+ U4 origin = rand(); // NOLINT
s.a = *GetPoisonedO<U2>(0, origin);
EXPECT_EQ(origin, __msan_get_origin(&s.a));
EXPECT_EQ(origin, __msan_get_origin(&s.b));
@@ -1504,14 +1504,14 @@ TEST(MemorySanitizerOrigins, DISABLED_InitializedStoreDoesNotChangeOrigin) {
template<class T, class BinaryOp>
INLINE
void BinaryOpOriginTest(BinaryOp op) {
- u32 ox = rand(); //NOLINT
- u32 oy = rand(); //NOLINT
+ U4 ox = rand(); //NOLINT
+ U4 oy = rand(); //NOLINT
T *x = GetPoisonedO<T>(0, ox, 0);
T *y = GetPoisonedO<T>(1, oy, 0);
T *z = GetPoisonedO<T>(2, 0, 0);
*z = op(*x, *y);
- u32 origin = __msan_get_origin(z);
+ U4 origin = __msan_get_origin(z);
EXPECT_POISONED_O(*z, origin);
EXPECT_EQ(true, origin == ox || origin == oy);
@@ -1675,7 +1675,7 @@ TEST(MemorySanitizerOrigins, DISABLED_AllocaDeath) {
EXPECT_DEATH(AllocaTO(), "ORIGIN: stack allocation: ar@AllocaTO");
}
-NOINLINE int RetvalOriginTest(u32 origin) {
+NOINLINE int RetvalOriginTest(U4 origin) {
int *a = new int;
break_optimization(a);
__msan_set_origin(a, sizeof(*a), origin);
@@ -1689,14 +1689,14 @@ TEST(MemorySanitizerOrigins, Retval) {
EXPECT_POISONED_O(RetvalOriginTest(__LINE__), __LINE__);
}
-NOINLINE void ParamOriginTest(int param, u32 origin) {
+NOINLINE void ParamOriginTest(int param, U4 origin) {
EXPECT_POISONED_O(param, origin);
}
TEST(MemorySanitizerOrigins, Param) {
if (!TrackingOrigins()) return;
int *a = new int;
- u32 origin = __LINE__;
+ U4 origin = __LINE__;
break_optimization(a);
__msan_set_origin(a, sizeof(*a), origin);
ParamOriginTest(*a, origin);
@@ -1714,14 +1714,14 @@ TEST(MemorySanitizerOrigins, strlen) {
break_optimization(&alignment);
char x[4] = {'a', 'b', 0, 0};
__msan_poison(&x[2], 1);
- u32 origin = __LINE__;
+ U4 origin = __LINE__;
__msan_set_origin(x, sizeof(x), origin);
EXPECT_UMR_O(volatile unsigned y = strlen(x), origin);
}
TEST(MemorySanitizerOrigins, wcslen) {
wchar_t w[3] = {'a', 'b', 0};
- u32 origin = __LINE__;
+ U4 origin = __LINE__;
__msan_set_origin(w, sizeof(w), origin);
__msan_poison(&w[2], sizeof(wchar_t));
EXPECT_UMR_O(volatile unsigned y = wcslen(w), origin);
@@ -1730,7 +1730,7 @@ TEST(MemorySanitizerOrigins, wcslen) {
#if MSAN_HAS_M128
TEST(MemorySanitizerOrigins, StoreIntrinsic) {
__m128 x, y;
- u32 origin = __LINE__;
+ U4 origin = __LINE__;
__msan_set_origin(&x, sizeof(x), origin);
__msan_poison(&x, sizeof(x));
__builtin_ia32_storeups((float*)&y, x);
diff --git a/lib/sanitizer_common/sanitizer_internal_defs.h b/lib/sanitizer_common/sanitizer_internal_defs.h
index 7ff273381..5d368040a 100644
--- a/lib/sanitizer_common/sanitizer_internal_defs.h
+++ b/lib/sanitizer_common/sanitizer_internal_defs.h
@@ -13,7 +13,78 @@
#ifndef SANITIZER_DEFS_H
#define SANITIZER_DEFS_H
-#include "sanitizer/common_interface_defs.h"
+#if defined(_WIN32)
+// FIXME find out what we need on Windows. __declspec(dllexport) ?
+# define SANITIZER_INTERFACE_ATTRIBUTE
+# define SANITIZER_WEAK_ATTRIBUTE
+#elif defined(SANITIZER_GO)
+# define SANITIZER_INTERFACE_ATTRIBUTE
+# define SANITIZER_WEAK_ATTRIBUTE
+#else
+# define SANITIZER_INTERFACE_ATTRIBUTE __attribute__((visibility("default")))
+# define SANITIZER_WEAK_ATTRIBUTE __attribute__((weak))
+#endif
+
+#ifdef __linux__
+# define SANITIZER_SUPPORTS_WEAK_HOOKS 1
+#else
+# define SANITIZER_SUPPORTS_WEAK_HOOKS 0
+#endif
+
+// __has_feature
+#if !defined(__has_feature)
+# define __has_feature(x) 0
+#endif
+
+// For portability reasons we do not include stddef.h, stdint.h or any other
+// system header, but we do need some basic types that are not defined
+// in a portable way by the language itself.
+namespace __sanitizer {
+
+#if defined(_WIN64)
+// 64-bit Windows uses LLP64 data model.
+typedef unsigned long long uptr; // NOLINT
+typedef signed long long sptr; // NOLINT
+#else
+typedef unsigned long uptr; // NOLINT
+typedef signed long sptr; // NOLINT
+#endif // defined(_WIN64)
+#if defined(__x86_64__)
+// Since x32 uses ILP32 data model in 64-bit hardware mode, we must use
+// 64-bit pointer to unwind stack frame.
+typedef unsigned long long uhwptr; // NOLINT
+#else
+typedef uptr uhwptr; // NOLINT
+#endif
+typedef unsigned char u8;
+typedef unsigned short u16; // NOLINT
+typedef unsigned int u32;
+typedef unsigned long long u64; // NOLINT
+typedef signed char s8;
+typedef signed short s16; // NOLINT
+typedef signed int s32;
+typedef signed long long s64; // NOLINT
+
+} // namespace __sanitizer
+
+extern "C" {
+ // Tell the tools to write their reports to "path.<pid>" instead of stderr.
+ void __sanitizer_set_report_path(const char *path)
+ SANITIZER_INTERFACE_ATTRIBUTE;
+
+ // Tell the tools to write their reports to given file descriptor instead of
+ // stderr.
+ void __sanitizer_set_report_fd(int fd)
+ SANITIZER_INTERFACE_ATTRIBUTE;
+
+ // Notify the tools that the sandbox is going to be turned on. The reserved
+ // parameter will be used in the future to hold a structure with functions
+ // that the tools may call to bypass the sandbox.
+ void __sanitizer_sandbox_on_notify(void *reserved)
+ SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE;
+} // extern "C"
+
+
using namespace __sanitizer; // NOLINT
// ----------- ATTENTION -------------
// This header should NOT include any other headers to avoid portability issues.
diff --git a/lib/sanitizer_common/sanitizer_libc.h b/lib/sanitizer_common/sanitizer_libc.h
index aa052c654..7c1acdeb6 100644
--- a/lib/sanitizer_common/sanitizer_libc.h
+++ b/lib/sanitizer_common/sanitizer_libc.h
@@ -11,14 +11,13 @@
// run-time libraries.
// These tools can not use some of the libc functions directly because those
// functions are intercepted. Instead, we implement a tiny subset of libc here.
-// NOTE: This file may be included into user code.
//===----------------------------------------------------------------------===//
#ifndef SANITIZER_LIBC_H
#define SANITIZER_LIBC_H
// ----------- ATTENTION -------------
// This header should NOT include any other headers from sanitizer runtime.
-#include "sanitizer/common_interface_defs.h"
+#include "sanitizer_internal_defs.h"
namespace __sanitizer {
diff --git a/lib/sanitizer_common/sanitizer_stackdepot.h b/lib/sanitizer_common/sanitizer_stackdepot.h
index 49e6669dd..5915fdbb4 100644
--- a/lib/sanitizer_common/sanitizer_stackdepot.h
+++ b/lib/sanitizer_common/sanitizer_stackdepot.h
@@ -13,7 +13,7 @@
#ifndef SANITIZER_STACKDEPOT_H
#define SANITIZER_STACKDEPOT_H
-#include "sanitizer/common_interface_defs.h"
+#include "sanitizer_internal_defs.h"
namespace __sanitizer {
diff --git a/lib/tsan/rtl/tsan_interface.h b/lib/tsan/rtl/tsan_interface.h
index 7480fc893..28eea1421 100644
--- a/lib/tsan/rtl/tsan_interface.h
+++ b/lib/tsan/rtl/tsan_interface.h
@@ -16,7 +16,7 @@
#ifndef TSAN_INTERFACE_H
#define TSAN_INTERFACE_H
-#include <sanitizer/common_interface_defs.h>
+#include <sanitizer_common/sanitizer_internal_defs.h>
// This header should NOT include any other headers.
// All functions in this header are extern "C" and start with __tsan_.
diff --git a/lib/tsan/rtl/tsan_interface_ann.h b/lib/tsan/rtl/tsan_interface_ann.h
index ed8090733..8e45328e7 100644
--- a/lib/tsan/rtl/tsan_interface_ann.h
+++ b/lib/tsan/rtl/tsan_interface_ann.h
@@ -14,7 +14,7 @@
#ifndef TSAN_INTERFACE_ANN_H
#define TSAN_INTERFACE_ANN_H
-#include <sanitizer/common_interface_defs.h>
+#include <sanitizer_common/sanitizer_internal_defs.h>
// This header should NOT include any other headers.
// All functions in this header are extern "C" and start with __tsan_.