forked from OSchip/llvm-project
db00fac2a2
This CL allows asan allocator in fuchsia to decommit shadow memory for memory allocated using mmap. Big allocations in asan end up being allocated via `mmap` and freed with `munmap`. However, when that memory is freed, asan returns the corresponding shadow memory back to the OS via a call to `ReleaseMemoryPagesToOs`. In fuchsia, `ReleaseMemoryPagesToOs` is a no-op: to be able to free memory back to the OS, you have to hold a handle to the vmo you want to modify, which is tricky at the ReleaseMemoryPagesToOs level as that function is not exclusively used for shadow memory. The function `__sanitizer_fill_shadow` fills a given shadow memory range with a specific value, and if that value is 0 (unpoison) and the memory range is bigger than a threshold parameter, it will decommit that memory if it is all zeroes. This CL modifies the `FlushUnneededASanShadowMemory` function in `asan_poisoning.cpp` to add a call to `__sanitizer_fill_shadow` with value and threshold = 0. This way, all the unneeded shadow memory gets returned back to the OS. A test for this behavior can be found in fxrev.dev/391974 Differential Revision: https://reviews.llvm.org/D80355 Change-Id: Id6dd85693e78a222f0329d5b2201e0da753e01c0 |
||
---|---|---|
.. | ||
scripts | ||
tests | ||
.clang-format | ||
CMakeLists.txt | ||
README.txt | ||
asan.syms.extra | ||
asan_activation.cpp | ||
asan_activation.h | ||
asan_activation_flags.inc | ||
asan_allocator.cpp | ||
asan_allocator.h | ||
asan_blacklist.txt | ||
asan_debugging.cpp | ||
asan_descriptions.cpp | ||
asan_descriptions.h | ||
asan_errors.cpp | ||
asan_errors.h | ||
asan_fake_stack.cpp | ||
asan_fake_stack.h | ||
asan_flags.cpp | ||
asan_flags.h | ||
asan_flags.inc | ||
asan_fuchsia.cpp | ||
asan_globals.cpp | ||
asan_globals_win.cpp | ||
asan_init_version.h | ||
asan_interceptors.cpp | ||
asan_interceptors.h | ||
asan_interceptors_memintrinsics.cpp | ||
asan_interceptors_memintrinsics.h | ||
asan_interceptors_vfork.S | ||
asan_interface.inc | ||
asan_interface_internal.h | ||
asan_internal.h | ||
asan_linux.cpp | ||
asan_lock.h | ||
asan_mac.cpp | ||
asan_malloc_linux.cpp | ||
asan_malloc_local.h | ||
asan_malloc_mac.cpp | ||
asan_malloc_win.cpp | ||
asan_mapping.h | ||
asan_mapping_myriad.h | ||
asan_mapping_sparc64.h | ||
asan_memory_profile.cpp | ||
asan_new_delete.cpp | ||
asan_poisoning.cpp | ||
asan_poisoning.h | ||
asan_posix.cpp | ||
asan_preinit.cpp | ||
asan_premap_shadow.cpp | ||
asan_premap_shadow.h | ||
asan_report.cpp | ||
asan_report.h | ||
asan_rtems.cpp | ||
asan_rtl.cpp | ||
asan_scariness_score.h | ||
asan_shadow_setup.cpp | ||
asan_stack.cpp | ||
asan_stack.h | ||
asan_stats.cpp | ||
asan_stats.h | ||
asan_suppressions.cpp | ||
asan_suppressions.h | ||
asan_thread.cpp | ||
asan_thread.h | ||
asan_win.cpp | ||
asan_win_dll_thunk.cpp | ||
asan_win_dynamic_runtime_thunk.cpp | ||
asan_win_weak_interception.cpp | ||
weak_symbols.txt |
README.txt
AddressSanitizer RT ================================ This directory contains sources of the AddressSanitizer (ASan) runtime library. Directory structure: README.txt : This file. Makefile.mk : File for make-based build. CMakeLists.txt : File for cmake-based build. asan_*.{cc,h} : Sources of the asan runtime library. scripts/* : Helper scripts. tests/* : ASan unit tests. Also ASan runtime needs the following libraries: lib/interception/ : Machinery used to intercept function calls. lib/sanitizer_common/ : Code shared between various sanitizers. ASan runtime currently also embeds part of LeakSanitizer runtime for leak detection (lib/lsan/lsan_common.{cc,h}). ASan runtime can only be built by CMake. You can run ASan tests from the root of your CMake build tree: make check-asan For more instructions see: https://github.com/google/sanitizers/wiki/AddressSanitizerHowToBuild