summaryrefslogtreecommitdiff
path: root/lib/asan/asan_flags.cc
AgeCommit message (Collapse)Author
2017-11-16[asan] Ensure that the minimum redzone is at least SHADOW_GRANULARITYWalter Lee
This is required by the Asan run-time. Differential Revision: https://reviews.llvm.org/D39472 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318422 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-22[lsan] Add __lsan_default_optionsVitaly Buka
For consistency with asan, msan, tsan and ubsan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314048 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-01[asan] Add strndup/__strndup interceptors.Pierre Gousseau
Recommit of r302781 with Vitaly Buka's fix for non zero terminated strings. Differential Revision: https://reviews.llvm.org/D31457 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304399 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-18Revert r302781 and subsequent attempts to disable part of it.Daniel Jasper
The Msan unit tests are still broken and by this point, I think we should start over. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@303339 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-11[asan] Recommit of r301904: Add strndup/__strndup interceptorsPierre Gousseau
Fix undeclared __interceptor_malloc in esan_interceptors.cc Fix undeclared strnlen on OSX Differential Revision: https://reviews.llvm.org/D31457 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302781 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02Revert r301904 causing tsan test failure in x86_64-linux-autoconfPierre Gousseau
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301909 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02[asan] Add strndup/__strndup interceptors if targeting linux.Pierre Gousseau
Differential Revision: https://reviews.llvm.org/D31457 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301904 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-06Enable builds of darwin lsan by defaultFrancis Ricci
Summary: Testing and asan leak detection are disabled by default. Reviewers: kubamracek, kcc Subscribers: srhines, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D31307 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299669 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-30[asan] Implement "scribble" flags, which overwrite free'd memory with 0x55Kuba Mracek
This patch implements "Malloc Scribble" in ASan via "max_free_fill_size" and "free_fill_byte" flags, which can be used to overwrite free()'d memory. We also match the behavior of MallocScribble and MallocPreScribble env vars on macOS (see https://developer.apple.com/library/content/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html), which is a helpful tool to detect use-after-free bugs that happen in non-instrumented code. Differential Revision: https://reviews.llvm.org/D30101 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299085 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-29General definition for weak functionsMarcos Pividori
In this diff, I define a general macro for defining weak functions with a default implementation: "SANITIZER_INTERFACE_WEAK_DEF()". This way, we simplify the implementation for different platforms. For example, we cannot define weak functions on Windows, but we can use linker pragmas to create an alias to a default implementation. All of these implementation details are hidden in the new macro. Also, as I modify the name for exported weak symbols on Windows, I needed to temporarily disable "dll_host" test for asan, which checks the list of functions included in asan_win_dll_thunk. Differential Revision: https://reviews.llvm.org/D28596 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293419 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12ASAN activate/deactive controls thread_local_quarantine_size_kb option.Alex Shlyapnikov
Summary: Bypass quarantine altogether when quarantine size is set ot zero. Also, relax atomic load/store of quarantine parameters, the release/acquire semantics is an overkill here. Reviewers: eugenis Subscribers: kubabrecka, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D28586 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291791 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-10Revert r291509, 291510 and 291511Diana Picus
Revert "ASAN activate/deactive controls thread_local_quarantine_size_kb option." Revert "Bypass quarantine when quarantine size is set ot zero." Revert "ASAN activate/deactive controls thread_local_quarantine_size_kb option." One of these commits broke some of the ARM / AArch64 buildbots: TEST 'AddressSanitizer-aarch64-linux :: TestCases/Posix/start-deactivated.cc' FAILED Command Output (stderr): -- /home/buildslave/buildslave/clang-cmake-aarch64-42vma/llvm/projects/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc:85:12: error: expected string not found in input // CHECK: WARNING: AddressSanitizer failed to allocate 0xfff{{.*}} bytes ^ <stdin>:1:1: note: scanning from here start-deactivated.cc.tmp: /home/buildslave/buildslave/clang-cmake-aarch64-42vma/llvm/projects/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc:40: void test_malloc_shadow(char *, size_t, bool): Assertion `(char *)__asan_region_is_poisoned(p - 1, sz + 1) == (expect_redzones ? p - 1 : nullptr)' failed. ^ <stdin>:2:1: note: possible intended match here Error: Aborted (core dumped) ^ git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291560 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-09ASAN activate/deactive controls thread_local_quarantine_size_kb option.Alex Shlyapnikov
Summary: Also, bypass quarantine altogether when quarantine size is set ot zero. Reviewers: eugenis Subscribers: kubabrecka, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D28480 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291511 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-22Expose thread local quarantine size as ASAN option.Evgeniy Stepanov
Summary: Make thread local quarantine size an option so it can be turned off to save memory. Reviewers: eugenis Patch by Alex Shlyapnikov. Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D28027 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290373 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-21Reduce the size of quarantine cache in ASAN_LOW_MEMORY configuration.Evgeniy Stepanov
Summary: Experiments show that on Android the current values result in too much of the memory consumption for all quarantined chunks. Reviewers: kcc, eugenis Subscribers: mgorny, danalbert, srhines, llvm-commits, kubabrecka Patch by Aleksey Shlyapnikov. Differential Revision: https://reviews.llvm.org/D27873 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290218 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-21[sanitizer] Add strchr* to the common interceptorsEvgeniy Stepanov
Adds strchr, strchrnul, and strrchr to the common interceptors, under a new common flag intercept_strchr. Removes the now-duplicate strchr interceptor from asan and all 3 interceptors from tsan. Previously, asan did not intercept strchrnul, but does now; previously, msan did not intercept strchr, strchrnul, or strrchr, but does now. http://reviews.llvm.org/D18329 Patch by Derek Bruening! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263992 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-18[sancov] common flags initialization.Mike Aizatsky
Summary: Introducing InitializeCommonFlags accross all sanitizers to simplify common flags management. Setting coverage=1 when html_cov_report is requested. Differential Revision: http://reviews.llvm.org/D18273 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263820 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-11[sanitizer] Add strlen to the common interceptorsAlexey Samsonov
Summary: Adds strlen to the common interceptors, under a new common flag intercept_strlen. This provides better sharing of interception code among sanitizers and cleans up the inconsistent type declarations of the previously duplicated interceptors. Removes the now-duplicate strlen interceptor from asan, msan, and tsan. The entry check semantics are normalized now for msan and asan, whose private strlen interceptors contained multiple layers of checks that included impossible-to-reach code. The new semantics are identical to the old: bypass interception if in the middle of init or if both on Mac and not initialized; else, call the init routine and proceed. Patch by Derek Bruening! Reviewers: samsonov, vitalybuka Subscribers: llvm-commits, kcc, zhaoqin Differential Revision: http://reviews.llvm.org/D18020 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263177 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-04[asan] Remove the use of system properties on Android.Evgeniy Stepanov
System properties are not accessible through NDK (we've been using hacks to get to them) and they are unavailable during ASan initialization in .preinit_array. Use environment variables and files instead (ex. ASAN_OPTIONS=include_if_exists=/path). No test changes. This feature was not tested because the properties are system-wide and would conflict with the parallel test runner. Yet another reason to get rid of it. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254783 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-21[Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across ↵Alexey Samsonov
all sanitizers. Summary: Merge "exitcode" flag from ASan, LSan, TSan and "exit_code" from MSan into one entity. Additionally, make sure sanitizer_common now uses the value of common_flags()->exitcode when dying on error, so that this flag will automatically work for other sanitizers (UBSan and DFSan) as well. User-visible changes: * "exit_code" MSan runtime flag is now deprecated. If explicitly specified, this flag will take precedence over "exitcode". The users are encouraged to migrate to the new version. * __asan_set_error_exit_code() and __msan_set_exit_code() functions are removed. With few exceptions, we don't support changing runtime flags during program execution - we can't make them thread-safe. The users should use __sanitizer_set_death_callback() that would call _exit() with proper exit code instead. * Plugin tools (LSan and UBSan) now inherit the exit code of the parent tool. In particular, this means that ASan would now crash the program with exit code "1" instead of "23" if it detects leaks. Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12120 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245734 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-01[UBSan] Embed UBSan into ASan runtime (compiler-rt part).Alexey Samsonov
Summary: Change the way we use ASan and UBSan together. Instead of keeping two separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on a platform, all UBSan sources are just compiled into dummy empty object files. UBSan initialization code (e.g. flag parsing) is directly called from ASan initialization, so we are able to enforce correct initialization order. This mirrors the approach we already use for ASan+LSan. This change doesn't modify the way we use standalone UBSan. Test Plan: regression test suite Reviewers: kubabrecka, zaks.anna, rsmith, kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8646 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@233861 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-17[LSan] Make parent tool responsible for initializing LSan flags.Alexey Samsonov
Summary: LSan can be combined with a parent tool (for now it's only ASan). Also, we allow LSAN_OPTIONS to override certain common flags. It means we have to parse LSAN_OPTIONS early enough, before the rest of the parent tool (including chunks of sanitizer_common) is initialized. In future, we can use the same approach for UBSan, after we embed it into ASan runtime in a similar way. Test Plan: regression test suite Reviewers: earthdok, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7577 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229519 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-12[Sanitizer] Change InitializeFlags() signatures. NFC.Alexey Samsonov
These functions are always used to initialize singleton flags(), as well as other global data (common_flags()). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228894 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20[asan] Allow changing verbosity in activation flags.Evgeniy Stepanov
This change removes some debug output in asan_flags.cc that was reading the verbosity level before all the flags were parsed. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226566 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19[sanitizer] Make unrecognized flags not fatal.Evgeniy Stepanov
Print a warning at verbosity=1 and higher instead of dying immediately. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226458 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15[sanitizer] Flag parser rewrite.Evgeniy Stepanov
The new parser is a lot stricter about syntax, reports unrecognized flags, and will make it easier to implemented some of the planned features. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226169 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-07[asan] add flag quarantine_size_mb, deprecate quarantine_sizeKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225337 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-07[Sanitizer] Change the runtime flag representation.Alexey Samsonov
This mirrors r225239 to all the rest sanitizers: ASan, DFSan, LSan, MSan, TSan, UBSan. Now the runtime flag type, name, default value and description is located in the single place in the .inc file. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225327 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-02Revert "Revert r224736: "[Sanitizer] Make CommonFlags immutable after ↵Alexey Samsonov
initialization."" Fix test failures by introducing CommonFlags::CopyFrom() to make sure compiler doesn't insert memcpy() calls into runtime code. Original commit message: Protect CommonFlags singleton by adding const qualifier to common_flags() accessor. The only ways to modify the flags are SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and OverrideCommonFlags() functions, which are only supposed to be called during initialization. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225088 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-02Revert r224736: "[Sanitizer] Make CommonFlags immutable after initialization."Chandler Carruth
We've got some internal users that either aren't compatible with this or have found a bug with it. Either way, this is an isolated cleanup and so I'm reverting it to un-block folks while we investigate. Alexey and I will be working on fixing everything up so this can be re-committed soon. Sorry for the noise and any inconvenience. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225079 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-22[Sanitizer] Make CommonFlags immutable after initialization.Alexey Samsonov
Summary: Protect CommonFlags singleton by adding const qualifier to common_flags() accessor. The only ways to modify the flags are SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and OverrideCommonFlags() functions, which are only supposed to be called during initialization. Test Plan: regression test suite Reviewers: kcc, eugenis, glider Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6741 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224736 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-22AddressSanitizer: Abort after failed exec() and get rid of the allow_reexec ↵Kuba Brecka
ASan flag As mentioned in https://code.google.com/p/address-sanitizer/issues/detail?id=365, when the re-exec that adds the required DYLD_INSERT_LIBRARIES variable fails, ASan currently continues to run, but things are broken (some memory can be overwritten, interceptors don't work, ...). This patch aborts if the execv() fails and prints an error message that DYLD_INSERT_LIBRARIES is required. It also removes the "alllow_reexec" flag, since using it causes the same issues. Reviewed at http://reviews.llvm.org/D6752 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224712 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19[Sanitizer] Refactor CommonFlags interface. NFC.Alexey Samsonov
Add CommonFlags::SetDefaults() and CommonFlags::ParseFromString(), so that this object can be easily tested. Enforce that ParseCommonFlagsFromString() and SetCommonFlagsDefaults() work only with singleton CommonFlags, shared across all sanitizer runtimes. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224617 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19[ASan] Change activation strategy.Alexey Samsonov
Now ASan deactivation doesn't modify common or ASan-specific runtime flags. Flags stay constant after initialization, and "deactivation" instead stashes initialized runtime state, and deactivates the runtime. Activation then just restores the original state (possibly, overriden by some activation flags provided in system property on Android). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224614 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19[ASan] Move flag validation from ParseFlagsFromString() to InitializeFlags().Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224600 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-17[ASan] Move flag parsing logic to asan_flags.cc. NFC.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224450 91177308-0d34-0410-b5e6-96231b3b80d8