CChristopher Ferris[scudo] Clean up tests.
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[scudo] Get rid of initLinkerInitialized Now that everything is forcibly linker initialized, it feels like a good time to get rid of the init/initLinkerInitialized split. This allows to get rid of various memset construct in init that gcc complains about (this fixes a Fuchsia open issue). I added various DCHECKs to ensure that we would get a zero-inited object when entering init, which required ensuring that unmapTestOnly leaves the object in a good state (tests are currently the only location where an allocator can be "de-initialized"). Running the tests with --gtest_repeat= showed no issue. Differential Revision: https://reviews.llvm.org/D103119 | 5 年前 | |
Dynamically allocate scudo allocation buffer. This is so we can increase the buffer size for finding elusive bugs. Tested by hand with this program int main(int argc, char** argv) { if (argc < 2) return 1; int n = atoi(argv[1]); char* x = reinterpret_cast<char*>(malloc(1)); *((volatile char*)x) = 1; free(x); for (; n > 0; --n) { char* y = reinterpret_cast<char*>(malloc(1024)); *((volatile char*)y) = 1; free(y); } *x = 2; return 0; } SCUDO_OPTIONS=allocation_ring_buffer_size=30000 ./uaf 1000000 -> no allocation trace SCUDO_OPTIONS=allocation_ring_buffer_size=30000000 ./uaf 1000000 -> allocation trace Reviewed By: hctim, eugenis Differential Revision: https://reviews.llvm.org/D140932 | 3 年前 | |
[scudo] Add mallopt to print stats to the log. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D153094 | 3 年前 | |
[scudo] Clean up tests. Modify the tests so that all clang warnings can be turned up to high. Fix all places flagged by -Wconversion. Fix a few unused variables not marked with UNUSED. For the memtag testing, only compile some tests for 64 bit since compiling them on 32 bit leads to warnings/errors. All of the tests are already skipped on 32 bit OSes, so this will not affect any real tests. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D155749 | 2 年前 | |
Use u16 to store Count/MaxCount The Count/MaxCount used in TransferBatch and PerClass can be fit in u16 in current configurations and it's also reasonable to have a u16 limit. The spare 16 bits will be used for additional status like pages mapping status in a TransferBatch. Reviewed By: cryptoad, cferris, vitalybuka Differential Revision: https://reviews.llvm.org/D133145 | 3 年前 | |
[scudo] Implement Fuchsia backend for the new MemMap API Reviewed By: Caslyn, Chia-hungDuan Differential Revision: https://reviews.llvm.org/D153888 | 2 年前 | |
[scudo] Enable MTE in Trusty Trusty now has MTE support. Back-ported from https://r.android.com/2332745. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D152219 | 3 年前 | |
scudo: Make it thread-safe to set some runtime configuration flags. Move some of the flags previously in Options, as well as the UseMemoryTagging flag previously in the primary allocator, into an atomic variable so that it can be updated while other threads are running. Relaxed accesses are used because we only have the requirement that the other threads see the new value eventually. The code is set up so that the variable is generally loaded once per allocation function call with the exception of some rarely used code such as error handlers. The flag bits can generally stay in a register during the execution of the allocation function which means that they can be branched on with minimal overhead (e.g. TBZ on aarch64). Differential Revision: https://reviews.llvm.org/D88523 | 5 年前 | |
[scudo] Get rid of initLinkerInitialized Now that everything is forcibly linker initialized, it feels like a good time to get rid of the init/initLinkerInitialized split. This allows to get rid of various memset construct in init that gcc complains about (this fixes a Fuchsia open issue). I added various DCHECKs to ensure that we would get a zero-inited object when entering init, which required ensuring that unmapTestOnly leaves the object in a good state (tests are currently the only location where an allocator can be "de-initialized"). Running the tests with --gtest_repeat= showed no issue. Differential Revision: https://reviews.llvm.org/D103119 | 5 年前 | |
[scudo] Add missing include for extern variable declaration Add include to resolve compiler warning about no previous extern declaration for non-static HashAlgorithm Differential Revision: https://reviews.llvm.org/D122630 | 4 年前 | |
[NFCI] clang-format scudo standalone | 4 年前 | |
[scudo] Improve the uses of roundUpTo/roundDownTo/isAligned The implementations of those functions require the rounding target to be power-of-two. It's better to add a debugging check to avoid misuse. Besides, add a general verion of those three to accommadate non power-of-two cases. Also change the name to roundUp/roundDown/isAligned Reviewed By: cferris, cryptoad Differential Revision: https://reviews.llvm.org/D142658 | 3 年前 | |
[scudo] Try to release pages after unlocking the TSDs This increases the parallelism and the usage of TSDs Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D152988 | 2 年前 | |
[scudo] Fix return type of GetRSS() | 3 年前 | |
[scudo] Add a method to force release everything. The force flag to releaseToOSMaybe does not release everything since it is an expensive operation. Modify the release flag to have three states: normal, force, forceall. Force behaves the same as setting Force to true from before this change. Forceall will release everything regardless of how much time it takes, or how much there is to release. In addition, add a new mallopt that will call the release function with the forceall flag set. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D146106 | 3 年前 | |
[NFCI] clang-format scudo standalone | 4 年前 | |
[scudo][standalone] Restore GWP-ASan flag parsing With D92696, the Scudo Standalone GWP-ASan flag parsing was changed to the new GWP-ASan optional one. We do not necessarily want this, as this duplicates flag parsing code in Scudo Standalone when using the GWP-ASan integration. This CL reverts the changes within Scudo Standalone, and increases MaxFlags to 20 as an addionnal option got us to the current max. Differential Revision: https://reviews.llvm.org/D95542 | 5 年前 | |
[Scudo] [GWP-ASan] Add GWP-ASan to Scudo Standalone. Summary: Adds GWP-ASan to Scudo standalone. Default parameters are pulled across from the GWP-ASan build. No backtrace support as of yet. Reviewers: cryptoad, eugenis, pcc Reviewed By: cryptoad Subscribers: merge_guards_bot, mgorny, #sanitizers, llvm-commits, cferris, vlad.tsyrklevich, pcc Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71229 | 6 年前 | |
Dynamically allocate scudo allocation buffer. This is so we can increase the buffer size for finding elusive bugs. Tested by hand with this program int main(int argc, char** argv) { if (argc < 2) return 1; int n = atoi(argv[1]); char* x = reinterpret_cast<char*>(malloc(1)); *((volatile char*)x) = 1; free(x); for (; n > 0; --n) { char* y = reinterpret_cast<char*>(malloc(1024)); *((volatile char*)y) = 1; free(y); } *x = 2; return 0; } SCUDO_OPTIONS=allocation_ring_buffer_size=30000 ./uaf 1000000 -> no allocation trace SCUDO_OPTIONS=allocation_ring_buffer_size=30000000 ./uaf 1000000 -> allocation trace Reviewed By: hctim, eugenis Differential Revision: https://reviews.llvm.org/D140932 | 3 年前 | |
scudo: Replace a couple of macros with their expansions. The macros INLINE and COMPILER_CHECK always expand to the same thing (inline and static_assert respectively). Both expansions are standards compliant C++ and are used consistently in the rest of LLVM, so let's improve consistency with the rest of LLVM by replacing them with the expansions. Differential Revision: https://reviews.llvm.org/D70793 | 6 年前 | |
[scudo][standalone] Restore GWP-ASan flag parsing With D92696, the Scudo Standalone GWP-ASan flag parsing was changed to the new GWP-ASan optional one. We do not necessarily want this, as this duplicates flag parsing code in Scudo Standalone when using the GWP-ASan integration. This CL reverts the changes within Scudo Standalone, and increases MaxFlags to 20 as an addionnal option got us to the current max. Differential Revision: https://reviews.llvm.org/D95542 | 5 年前 | |
[scudo] Descriptive Fucshia errors dieOnError in fuchsia.cpp takes the syscall name, status code, and relevant size parameter to describe what failed, the reason, and size context. Several different Fuchsia syscalls can fail underlying Scudo's map operation and gets hidden if using dieOnMapUnmapError. The reason for this change is to provide an error status code and more helpful information to debug failures. | 3 年前 | |
[scudo] Clean up Zircon header file uses Make fuchsia.h and fuchsia.cpp each include what they use. | 4 年前 | |
[NFC] [scudo] syntax-check DCHECK arguments if DCHECK is off This is a widespread technique, used in at least: * ABSL: https://github.com/abseil/abseil-cpp/blob/master/absl/log/internal/check_op.h#L52 * Chromium: https://source.chromium.org/chromium/chromium/src/+/main:base/check.h;l=185?q=DCHECK%20f:base&ss=chromium * Android: https://cs.android.com/android/platform/superproject/+/master:system/libbase/include/android-base/logging.h;drc=bda7f0a0cc945c860713a1dc497919f17fad1651;l=321 Reviewed By: Chia-hungDuan, vitalybuka Differential Revision: https://reviews.llvm.org/D141713 | 3 年前 | |
[scudo] Add a fast get time version. On Android, the _COARSE version of clock_gettime is about twice as fast. Therefore, add a getMonotonicTimeFast function that is used in the releaseToOSMaybe functions. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D145636 | 3 年前 | |
scudo: Introduce a new mechanism to let Scudo access a platform-specific TLS slot An upcoming change to Scudo will change how we use the TLS slot in tsd_shared.h, which will be a little easier to deal with if we can remove the code path that calls pthread_getspecific and pthread_setspecific. The only known user of this code path is Fuchsia. We can't eliminate this code path by making Fuchsia use ELF TLS because although Fuchsia supports ELF TLS, it is not supported within libc itself. To address this, Roland McGrath on the Fuchsia team has proposed that Scudo will optionally call a platform-provided function to access a TLS slot reserved for Scudo. Android also has a reserved TLS slot, but the code that accesses the TLS slot lives in Scudo. We can eliminate some complexity and duplicated code by having Android use the same mechanism that was proposed for Fuchsia, which is what this change does. A separate change to Android implements it. Differential Revision: https://reviews.llvm.org/D87420 | 5 年前 | |
Reland "[scudo] Manage free blocks in BatchGroup." This is not a pure revert of c929bcb7d85700494217f3a2148549f8757e0eed. It also includes a bug fix. Differential Revision: https://reviews.llvm.org/D136029 | 3 年前 | |
Reland "[scudo] Support partial concurrent page release in SizeClassAllocator64" This reverts commit 2f04b688aadef747172a8f4a7d1658dc049b1e24. Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D155015 | 2 年前 | |
[scudo] The BaseAddr should be MappedBase in releasePagesToOS() This is used to make MemMapDefault be compliant with legacy APIs. Reviewed By: fabio-d Differential Revision: https://reviews.llvm.org/D148141 | 3 年前 | |
[scudo] SCUDO_FUCHSIA uses ReservedMemoryDefault Some Fuchsia zx tests failed from https://reviews.llvm.org/D153888: https://turquoise-internal-review.git.corp.google.com/c/integration/+/729619 Use ReservedMemoryDefault for SCUDO_FUCHSIA to use the default MemMap API, while test failures are debugged. Differential Revision: https://reviews.llvm.org/D154538 | 2 年前 | |
[scudo] Simple coding style fix in mem_map_base.h (NFC) Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D154894 | 2 年前 | |
[scudo] Implement Fuchsia backend for the new MemMap API Reviewed By: Caslyn, Chia-hungDuan Differential Revision: https://reviews.llvm.org/D153888 | 2 年前 | |
[scudo] Implement Fuchsia backend for the new MemMap API Reviewed By: Caslyn, Chia-hungDuan Differential Revision: https://reviews.llvm.org/D153888 | 2 年前 | |
[scudo] Enable MTE in Trusty Trusty now has MTE support. Back-ported from https://r.android.com/2332745. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D152219 | 3 年前 | |
[scudo] Add the thread-safety annotations This CL adds the proper thread-safety annotations for most of the functions and variables. However, given the restriction of the current architecture, in some cases, we may not be able to use the annotations easily. The followings are two exceptions, 1. enable()/disable(): Many structures in scudo are enabled/disabled by acquiring the lock in each instance. This makes those structure act like a lock. We can't mark those functions with ACQUIRE()/RELEASE() because that makes the entire allocator become another lock. In the end, that implies we need to *acquire* the allocator before each malloc et al. request. Therefore, adding a variable to tell the status of those structures may be a better way to cooperate with thread-safety annotation. 2. TSD/TSD shared/TSD exclusive: These three have simiar restrictions as mentioned above. In addition, they don't always need to be released if it's a thread local instance. However, thread-safety analysis doesn't support conditional branch. Which means we can't mark the proper annotations around the uses of TSDs. We may consider to make it consistent and which makes the code structure simpler. This CL is supposed to introduce the annotations with the least code refactoring. So only trivial thread safety issues will be addressed here. For example, lacking of acquiring certain lock before accessing certain variables will have the ScopedLock inserted. Other than that, they are supposed to be done in the later changes. Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D140706 | 3 年前 | |
[scudo] Use require_constant_initialization Attribute guaranties safe static initialization of globals. Reviewed By: hctim Differential Revision: https://reviews.llvm.org/D101514 | 5 年前 | |
[scudo] Enable MTE in Trusty Trusty now has MTE support. Back-ported from https://r.android.com/2332745. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D152219 | 3 年前 | |
[scudo] Print PushedBytesDelta in getStats() This gives a hint of potential bytes to release. Also remove the RSS which is not supported yet. Will add it back when it's available. Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D154551 | 2 年前 | |
Reland "[scudo] Support partial concurrent page release in SizeClassAllocator64" This reverts commit 2f04b688aadef747172a8f4a7d1658dc049b1e24. Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D155015 | 2 年前 | |
[scudo] Drain caches when release with M_PURGE_ALL This will drain both quarantine and local caches. Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D150242 | 3 年前 | |
[scudo] Adjust page map buffer size Given the memory group, we are unlikely to need a huge page map to record entire region. This CL reduces the size of default page map buffer from 2048 to 512 and increase the number of static buffers to 2. Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D144754 | 3 年前 | |
[scudo] Extract steps releaseToOSMaybe into functions in This refactor helps us identify which steps need FLLock so that we can reduce the holding time of FLLock in SizeClassAllocator64. Also move the data members to the end of class to align the style in SizeClassAllocator32. Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D152596 | 2 年前 | |
[scudo] Change overloaded function name append. The ScopedString class has two functions named append. One takes a va_list, but on some platforms va_list is typedef'd to char*. That means that this call: std::string value; Str.append("print this string %s", value.c_str()); The compiler can incorrectly think this is the va_list function, leading to crashes when calling this. To fix this, change the name of the va_list function to be vappend to avoid this. Fix https://github.com/llvm/llvm-project/issues/62893 Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D153389 | 3 年前 | |
[scudo] Call getStats when the region is exhausted Because of lock contention, we temporarily disabled the printing of regions' status when it's exhausted. Given that it's useful when the Region OOM happens, this CL brings it back without lock contention. Differential Revision: https://reviews.llvm.org/D141955 | 3 年前 | |
Add Soft/Hard RSS Limits to Scudo Standalone Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D126752 | 3 年前 | |
Add Soft/Hard RSS Limits to Scudo Standalone Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D126752 | 3 年前 | |
[scudo] Improve Secondary Cache Dump Exclude cached blocks with invalid start address. Mainly concerned with cached blocks that are still available/unused. Reviewed By: Chia-hungDuan, cferris Differential Revision: https://reviews.llvm.org/D154148 | 2 年前 | |
[scudo] Change configuration for Trusty, use mmap() Trusty runs in memory constrained environments, with many apps having only one page (4KB) of heap memory available. However, we still want to mmap() multiples of PAGE_SIZE at a time. Additionally, switch Scudo from using sbrk() to mmap(). Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D151968 | 3 年前 | |
[scudo] Use require_constant_initialization Attribute guaranties safe static initialization of globals. Reviewed By: hctim Differential Revision: https://reviews.llvm.org/D101514 | 5 年前 | |
[scudo] Add the thread-safety annotations This CL adds the proper thread-safety annotations for most of the functions and variables. However, given the restriction of the current architecture, in some cases, we may not be able to use the annotations easily. The followings are two exceptions, 1. enable()/disable(): Many structures in scudo are enabled/disabled by acquiring the lock in each instance. This makes those structure act like a lock. We can't mark those functions with ACQUIRE()/RELEASE() because that makes the entire allocator become another lock. In the end, that implies we need to *acquire* the allocator before each malloc et al. request. Therefore, adding a variable to tell the status of those structures may be a better way to cooperate with thread-safety annotation. 2. TSD/TSD shared/TSD exclusive: These three have simiar restrictions as mentioned above. In addition, they don't always need to be released if it's a thread local instance. However, thread-safety analysis doesn't support conditional branch. Which means we can't mark the proper annotations around the uses of TSDs. We may consider to make it consistent and which makes the code structure simpler. This CL is supposed to introduce the annotations with the least code refactoring. So only trivial thread safety issues will be addressed here. For example, lacking of acquiring certain lock before accessing certain variables will have the ScopedLock inserted. Other than that, they are supposed to be done in the later changes. Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D140706 | 3 年前 | |
[scudo] Change overloaded function name append. The ScopedString class has two functions named append. One takes a va_list, but on some platforms va_list is typedef'd to char*. That means that this call: std::string value; Str.append("print this string %s", value.c_str()); The compiler can incorrectly think this is the va_list function, leading to crashes when calling this. To fix this, change the name of the va_list function to be vappend to avoid this. Fix https://github.com/llvm/llvm-project/issues/62893 Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D153389 | 3 年前 | |
[scudo] Change overloaded function name append. The ScopedString class has two functions named append. One takes a va_list, but on some platforms va_list is typedef'd to char*. That means that this call: std::string value; Str.append("print this string %s", value.c_str()); The compiler can incorrectly think this is the va_list function, leading to crashes when calling this. To fix this, change the name of the va_list function to be vappend to avoid this. Fix https://github.com/llvm/llvm-project/issues/62893 Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D153389 | 3 年前 | |
[scudo] Add the thread-safety annotations This CL adds the proper thread-safety annotations for most of the functions and variables. However, given the restriction of the current architecture, in some cases, we may not be able to use the annotations easily. The followings are two exceptions, 1. enable()/disable(): Many structures in scudo are enabled/disabled by acquiring the lock in each instance. This makes those structure act like a lock. We can't mark those functions with ACQUIRE()/RELEASE() because that makes the entire allocator become another lock. In the end, that implies we need to *acquire* the allocator before each malloc et al. request. Therefore, adding a variable to tell the status of those structures may be a better way to cooperate with thread-safety annotation. 2. TSD/TSD shared/TSD exclusive: These three have simiar restrictions as mentioned above. In addition, they don't always need to be released if it's a thread local instance. However, thread-safety analysis doesn't support conditional branch. Which means we can't mark the proper annotations around the uses of TSDs. We may consider to make it consistent and which makes the code structure simpler. This CL is supposed to introduce the annotations with the least code refactoring. So only trivial thread safety issues will be addressed here. For example, lacking of acquiring certain lock before accessing certain variables will have the ScopedLock inserted. Other than that, they are supposed to be done in the later changes. Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D140706 | 3 年前 | |
Reland "[scudo] Add a Timer class to assist performance measurement" This reverts commit 2e9bcadb7c8acaa8f6ec7d807e5666246923e468. Differential Revision: https://reviews.llvm.org/D146772 | 3 年前 | |
[scudo] Make the placeholder type specifier be consistent with C/C++ This avoids -Wformat complains the placeholder type specifier mismatch on lld/llu(used for s64/u64) which have slightly different interpretation in string_utils.cpp. Also enable Timer build which was disabled because of the complaining of -Wformat. Differential Revision: https://reviews.llvm.org/D147496 | 3 年前 | |
[scudo] Enable MTE in Trusty Trusty now has MTE support. Back-ported from https://r.android.com/2332745. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D152219 | 3 年前 | |
[scudo] Add Scudo support for Trusty OS trusty.cpp and trusty.h define Trusty implementations of map and other platform-specific functions. In addition to adding Trusty configurations in allocator_config.h and size_class_map.h, MapSizeIncrement and PrimaryEnableRandomOffset are added as configurable options in allocator_config.h. Background on Trusty: https://source.android.com/security/trusty Differential Revision: https://reviews.llvm.org/D103578 | 5 年前 | |
[scudo] Use getMonotonicTimeFast for tryLock. In tryLock, the Precedence value is set using the fast time function now. This should speed up tryLock calls slightly. This should be okay even though the value is used as a kind of random value in getTSDAndLockSlow. The fast time call still sets enough bits to avoid getting the same TSD on every call. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D154039 | 2 年前 | |
[scudo] Lock FallbackTSD before draining it Differential Revision: https://reviews.llvm.org/D150301 | 3 年前 | |
[scudo] Drain caches when release with M_PURGE_ALL This will drain both quarantine and local caches. Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D150242 | 3 年前 | |
[scudo] Improve the uses of roundUpTo/roundDownTo/isAligned The implementations of those functions require the rounding target to be power-of-two. It's better to add a debugging check to avoid misuse. Besides, add a general verion of those three to accommadate non power-of-two cases. Also change the name to roundUp/roundDown/isAligned Reviewed By: cferris, cryptoad Differential Revision: https://reviews.llvm.org/D142658 | 3 年前 | |
[scudo] Provide allocator declaration Ensure that extern allocator declaration is visible before definition Differential Revision: https://reviews.llvm.org/D121848 | 4 年前 | |
[scudo] Provide allocator declaration Ensure that extern allocator declaration is visible before definition Differential Revision: https://reviews.llvm.org/D121848 | 4 年前 | |
[scudo] Add mallopt to print stats to the log. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D153094 | 3 年前 | |
[scudo] Do not instantiate Android svelte allocator. The Android svelte allocator is not used, and will likely require some configuration and experimentation to find a balanced config. Leave the svelte config and size map so they can be used as the basis for the future Android svelte config. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D145525 | 3 年前 | |
[scudo] Improve the uses of roundUpTo/roundDownTo/isAligned The implementations of those functions require the rounding target to be power-of-two. It's better to add a debugging check to avoid misuse. Besides, add a general verion of those three to accommadate non power-of-two cases. Also change the name to roundUp/roundDown/isAligned Reviewed By: cferris, cryptoad Differential Revision: https://reviews.llvm.org/D142658 | 3 年前 | |
[NFCI] clang-format scudo standalone | 4 年前 |