696d846a56
libsanitizer/ 2015-10-20 Maxim Ostapenko <m.ostapenko@partner.samsung.com> * All source files: Merge from upstream r250806. * configure.ac (link_sanitizer_common): Add -lrt flag. * configure.tgt: Enable TSAN and LSAN for aarch64-linux targets. Set CXX_ABI_NEEDED=true for darwin. * asan/Makefile.am (asan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=0 and remove unused and legacy DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0. * asan/Makefile.in: Regenerate. * ubsan/Makefile.am (ubsan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=1. (libubsan_la_LIBADD): Add -lc++abi if CXX_ABI_NEEDED is true. * ubsan/Makefile.in: Regenerate. * tsan/Makefile.am (tsan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=0. * tsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.am (sanitizer_common_files): Add new files. * sanitizer_common/Makefile.in: Regenerate. * asan/libtool-version: Bump the libasan SONAME. From-SVN: r229111
109 lines
3.7 KiB
C++
109 lines
3.7 KiB
C++
//===-- asan_suppressions.cc ----------------------------------------------===//
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file is a part of AddressSanitizer, an address sanity checker.
|
|
//
|
|
// Issue suppression and suppression-related functions.
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "asan_suppressions.h"
|
|
|
|
#include "asan_stack.h"
|
|
#include "sanitizer_common/sanitizer_placement_new.h"
|
|
#include "sanitizer_common/sanitizer_suppressions.h"
|
|
#include "sanitizer_common/sanitizer_symbolizer.h"
|
|
|
|
namespace __asan {
|
|
|
|
ALIGNED(64) static char suppression_placeholder[sizeof(SuppressionContext)];
|
|
static SuppressionContext *suppression_ctx = nullptr;
|
|
static const char kInterceptorName[] = "interceptor_name";
|
|
static const char kInterceptorViaFunction[] = "interceptor_via_fun";
|
|
static const char kInterceptorViaLibrary[] = "interceptor_via_lib";
|
|
static const char kODRViolation[] = "odr_violation";
|
|
static const char *kSuppressionTypes[] = {
|
|
kInterceptorName, kInterceptorViaFunction, kInterceptorViaLibrary,
|
|
kODRViolation};
|
|
|
|
extern "C" {
|
|
#if SANITIZER_SUPPORTS_WEAK_HOOKS
|
|
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
|
|
const char *__asan_default_suppressions();
|
|
#else
|
|
// No week hooks, provide empty implementation.
|
|
const char *__asan_default_suppressions() { return ""; }
|
|
#endif // SANITIZER_SUPPORTS_WEAK_HOOKS
|
|
} // extern "C"
|
|
|
|
void InitializeSuppressions() {
|
|
CHECK_EQ(nullptr, suppression_ctx);
|
|
suppression_ctx = new (suppression_placeholder) // NOLINT
|
|
SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes));
|
|
suppression_ctx->ParseFromFile(flags()->suppressions);
|
|
if (&__asan_default_suppressions)
|
|
suppression_ctx->Parse(__asan_default_suppressions());
|
|
}
|
|
|
|
bool IsInterceptorSuppressed(const char *interceptor_name) {
|
|
CHECK(suppression_ctx);
|
|
Suppression *s;
|
|
// Match "interceptor_name" suppressions.
|
|
return suppression_ctx->Match(interceptor_name, kInterceptorName, &s);
|
|
}
|
|
|
|
bool HaveStackTraceBasedSuppressions() {
|
|
CHECK(suppression_ctx);
|
|
return suppression_ctx->HasSuppressionType(kInterceptorViaFunction) ||
|
|
suppression_ctx->HasSuppressionType(kInterceptorViaLibrary);
|
|
}
|
|
|
|
bool IsODRViolationSuppressed(const char *global_var_name) {
|
|
CHECK(suppression_ctx);
|
|
Suppression *s;
|
|
// Match "odr_violation" suppressions.
|
|
return suppression_ctx->Match(global_var_name, kODRViolation, &s);
|
|
}
|
|
|
|
bool IsStackTraceSuppressed(const StackTrace *stack) {
|
|
if (!HaveStackTraceBasedSuppressions())
|
|
return false;
|
|
|
|
CHECK(suppression_ctx);
|
|
Symbolizer *symbolizer = Symbolizer::GetOrInit();
|
|
Suppression *s;
|
|
for (uptr i = 0; i < stack->size && stack->trace[i]; i++) {
|
|
uptr addr = stack->trace[i];
|
|
|
|
if (suppression_ctx->HasSuppressionType(kInterceptorViaLibrary)) {
|
|
// Match "interceptor_via_lib" suppressions.
|
|
if (const char *module_name = symbolizer->GetModuleNameForPc(addr))
|
|
if (suppression_ctx->Match(module_name, kInterceptorViaLibrary, &s))
|
|
return true;
|
|
}
|
|
|
|
if (suppression_ctx->HasSuppressionType(kInterceptorViaFunction)) {
|
|
SymbolizedStack *frames = symbolizer->SymbolizePC(addr);
|
|
for (SymbolizedStack *cur = frames; cur; cur = cur->next) {
|
|
const char *function_name = cur->info.function;
|
|
if (!function_name) {
|
|
continue;
|
|
}
|
|
// Match "interceptor_via_fun" suppressions.
|
|
if (suppression_ctx->Match(function_name, kInterceptorViaFunction,
|
|
&s)) {
|
|
frames->ClearAll();
|
|
return true;
|
|
}
|
|
}
|
|
frames->ClearAll();
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} // namespace __asan
|