mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Implement WaitForTsan on other sanitizers
__sanitizer_sandbox_on_notify is not tsan specific. It's empty for other sanitizers now, but we are going to need it soon. PiperOrigin-RevId: 414873197 Change-Id: I251ac38e5c886980b4baa7f05306643599a25090
This commit is contained in:
parent
8979b47d7f
commit
46c09e0024
|
@ -16,8 +16,11 @@
|
||||||
|
|
||||||
#include "sandboxed_api/sandbox2/sanitizer.h"
|
#include "sandboxed_api/sandbox2/sanitizer.h"
|
||||||
|
|
||||||
#if defined(THREAD_SANITIZER)
|
#if defined(ABSL_HAVE_ADDRESS_SANITIZER) || \
|
||||||
#include <sanitizer/tsan_interface.h>
|
defined(ABSL_HAVE_HWADDRESS_SANITIZER) || \
|
||||||
|
defined(ABSL_HAVE_LEAK_SANITIZER) || \
|
||||||
|
defined(ABSL_HAVE_MEMORY_SANITIZER) || defined(ABSL_HAVE_THREAD_SANITIZER)
|
||||||
|
#include <sanitizer/common_interface_defs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
@ -150,9 +153,12 @@ int GetNumberOfThreads(int pid) {
|
||||||
return threads;
|
return threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitForTsan() {
|
void WaitForSanitizer() {
|
||||||
#if defined(THREAD_SANITIZER)
|
#if defined(ABSL_HAVE_ADDRESS_SANITIZER) || \
|
||||||
static bool ABSL_ATTRIBUTE_UNUSED dummy_tsan_once = []() {
|
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);
|
__sanitizer_sandbox_on_notify(nullptr);
|
||||||
return true;
|
return true;
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -42,13 +42,16 @@ absl::Status MarkAllFDsAsCOEExcept(
|
||||||
// errors.
|
// errors.
|
||||||
int GetNumberOfThreads(int pid);
|
int GetNumberOfThreads(int pid);
|
||||||
|
|
||||||
// When running under TSAN, it will spawn a background thread. This is not
|
// When running under a sanitizer, it may spawn a background threads. This is
|
||||||
// desirable for sandboxing purposes. We will notify its background thread
|
// 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
|
// that we wish for it to finish and then wait for it to be done. It is safe to
|
||||||
// to call this function more than once, since it keeps track of whether it
|
// call this function more than once, since it keeps track of whether it has
|
||||||
// has already notified TSAN.
|
// already notified the sanitizer. This function does nothing if not running
|
||||||
// This function does nothing if not running under TSAN.
|
// under a sanitizer.
|
||||||
void WaitForTsan();
|
void WaitForSanitizer();
|
||||||
|
|
||||||
|
ABSL_DEPRECATED("Use `sandbox2::sanitizer::WaitForSanitizer()`.")
|
||||||
|
inline void WaitForTsan() { WaitForSanitizer(); }
|
||||||
|
|
||||||
// Sanitizes current process (which will not execve a sandboxed binary).
|
// Sanitizes current process (which will not execve a sandboxed binary).
|
||||||
// File-descriptors in fd_exceptions will be either closed
|
// File-descriptors in fd_exceptions will be either closed
|
||||||
|
|
Loading…
Reference in New Issue
Block a user