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"
|
||||
|
||||
#if defined(THREAD_SANITIZER)
|
||||
#include <sanitizer/tsan_interface.h>
|
||||
#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 <sanitizer/common_interface_defs.h>
|
||||
#endif
|
||||
|
||||
#include <dirent.h>
|
||||
|
@ -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;
|
||||
}();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user