diff --git a/sandboxed_api/sandbox2/sanitizer.cc b/sandboxed_api/sandbox2/sanitizer.cc index a016b60..5c4d955 100644 --- a/sandboxed_api/sandbox2/sanitizer.cc +++ b/sandboxed_api/sandbox2/sanitizer.cc @@ -16,8 +16,11 @@ #include "sandboxed_api/sandbox2/sanitizer.h" -#if defined(THREAD_SANITIZER) -#include +#if defined(ABSL_HAVE_ADDRESS_SANITIZER) || \ + defined(ABSL_HAVE_HWADDRESS_SANITIZER) || \ + defined(ABSL_HAVE_LEAK_SANITIZER) || \ + defined(ABSL_HAVE_MEMORY_SANITIZER) || defined(ABSL_HAVE_THREAD_SANITIZER) +#include #endif #include @@ -150,9 +153,12 @@ int GetNumberOfThreads(int pid) { return threads; } -void WaitForTsan() { -#if defined(THREAD_SANITIZER) - static bool ABSL_ATTRIBUTE_UNUSED dummy_tsan_once = []() { +void WaitForSanitizer() { +#if defined(ABSL_HAVE_ADDRESS_SANITIZER) || \ + defined(ABSL_HAVE_HWADDRESS_SANITIZER) || \ + defined(ABSL_HAVE_LEAK_SANITIZER) || \ + defined(ABSL_HAVE_MEMORY_SANITIZER) || defined(ABSL_HAVE_THREAD_SANITIZER) + static bool ABSL_ATTRIBUTE_UNUSED dummy_once = []() { __sanitizer_sandbox_on_notify(nullptr); return true; }(); diff --git a/sandboxed_api/sandbox2/sanitizer.h b/sandboxed_api/sandbox2/sanitizer.h index 1203fc9..364e1b7 100644 --- a/sandboxed_api/sandbox2/sanitizer.h +++ b/sandboxed_api/sandbox2/sanitizer.h @@ -42,13 +42,16 @@ absl::Status MarkAllFDsAsCOEExcept( // errors. int GetNumberOfThreads(int pid); -// When running under TSAN, it will spawn a background thread. This is not -// desirable for sandboxing purposes. We will notify its background thread -// that we wish for it to finish and then wait for it to be done. It is safe -// to call this function more than once, since it keeps track of whether it -// has already notified TSAN. -// This function does nothing if not running under TSAN. -void WaitForTsan(); +// When running under a sanitizer, it may spawn a background threads. This is +// not desirable for sandboxing purposes. We will notify its background thread +// that we wish for it to finish and then wait for it to be done. It is safe to +// call this function more than once, since it keeps track of whether it has +// already notified the sanitizer. This function does nothing if not running +// under a sanitizer. +void WaitForSanitizer(); + +ABSL_DEPRECATED("Use `sandbox2::sanitizer::WaitForSanitizer()`.") +inline void WaitForTsan() { WaitForSanitizer(); } // Sanitizes current process (which will not execve a sandboxed binary). // File-descriptors in fd_exceptions will be either closed