summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/msan
Commit message (Collapse)AuthorAgeFilesLines
* [SanitizerCommon] Print the current value of options when printing out help.Dan Liew2019-11-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously it wasn't obvious what the default value of various sanitizer options were. A very close approximation of the "default values" for the options are the current value of the options at the time of printing the help output. In the case that no other options are provided then the current values are the default values (apart from `help`). ``` ASAN_OPTIONS=help=1 ./program ``` This patch causes the current option values to be printed when the `help` output is enabled. The original intention for this patch was to append `(Default: <value>)` to an option's help text. However because this is technically wrong (and misleading) I've opted to append `(Current Value: <value>)` instead. When trying to implement a way of displaying the default value of the options I tried another solution where the default value used in `*.inc` files were used to create compile time strings that where used when printing the help output. This solution was not satisfactory for several reasons: * Stringifying the default values with the preprocessor did not work very well in several cases. Some options contain boolean operators which no amount of macro expansion can get rid of. * It was much more invasive than this patch. Every sanitizer had to be changed. * The settings of `__<sanitizer>_default_options()` are ignored. For those reasons I opted for the solution in this patch. rdar://problem/42567204 Reviewers: kubamracek, yln, kcc, dvyukov, vitalybuka, cryptoad, eugenis, samsonov Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D69546
* [compiler-rt] [msan] Correct the __libc_thr_keycreate prototypeKamil Rytarowski2019-11-041-2/+3
| | | | Fixes build with GCC8.
* [msan] Blacklist __gxx_personality_v0.Evgenii Stepanov2019-10-314-4/+39
| | | | | | | | | | | | | | | | | | | | Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=31877. Fixes https://github.com/google/sanitizers/issues/1155. Enables exceptions in msan/tsan buid of libcxx, and in msan tests. -fdepfile-entry stuff is a workaround for https://reviews.llvm.org/D69290 (default blacklist missing from -MMD output). Reviewers: pcc, dvyukov Subscribers: mgorny, christof, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D69587
* [sanitizer_common] Create max_allocation_size_mb flag.Matt Morehouse2019-10-301-2/+9
| | | | | | | | | | | | | | | | | Summary: The flag allows the user to specify a maximum allocation size that the sanitizers will honor. Any larger allocations will return nullptr or crash depending on allocator_may_return_null. Reviewers: kcc, eugenis Reviewed By: kcc, eugenis Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D69576
* [compiler-rt] Use GetNextInstructionPc in signal handlersVitaly Buka2019-10-021-1/+1
| | | | | | | | | | | | | | | | | | Summary: All other stack trace callers assume that PC contains return address. HWAsan already use GetNextInstructionPc in similar code. PR43339 Reviewers: eugenis, kcc, jfb Subscribers: dexonsmith, dberris, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68313 llvm-svn: 373529
* [msan] Intercept __getrlimit.Evgeniy Stepanov2019-09-301-7/+17
| | | | | | | | | | | | | | | | | | | | Summary: This interceptor is useful on its own, but the main purpose of this change is to intercept libpthread initialization on linux/glibc in order to run __msan_init before any .preinit_array constructors. We used to trigger on pthread_initialize_minimal -> getrlimit(), but that call has changed to __getrlimit at some point. Reviewers: vitalybuka, pcc Subscribers: jfb, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68168 llvm-svn: 373239
* [compiler-rt] Remove some cpplint filtersVitaly Buka2019-09-121-4/+5
| | | | llvm-svn: 371704
* Remove NOLINTs from compiler-rtVitaly Buka2019-09-114-59/+58
| | | | llvm-svn: 371687
* Update compiler-rt cpplint.pyVitaly Buka2019-09-111-1/+1
| | | | | | https://github.com/cpplint/cpplint/commit/adb3500107f409ac5491188ae652ac3f4d03d9d3 llvm-svn: 371675
* [Sanitizer] checks ASLR on FreeBSDDavid Carlier2019-08-221-1/+1
| | | | | | | | | | | | - Especially MemorySanitizer fails if those sysctl configs are enabled. Reviewers: vitalybuka, emaste, dim Reviewed By: dim Differential Revision: https://reviews.llvm.org/D66582 llvm-svn: 369708
* Remove a few straggler ".cc"s in compiler-rt/libNico Weber2019-08-011-1/+1
| | | | llvm-svn: 367589
* compiler-rt: Rename .cc file in lib/msan/tests to .cppNico Weber2019-08-014-6/+11
| | | | | | Like r367463, but for msan/tests. llvm-svn: 367563
* compiler-rt: Rename .cc file in lib/msan to .cppNico Weber2019-08-0110-17/+18
| | | | | | Like r367463, but for msan. llvm-svn: 367562
* [Sanitizer][ASAN][MSAN] Fix infinite recursion on FreeBSDAlexander Richardson2019-07-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: MSAN was broken on FreeBSD by https://reviews.llvm.org/D55703: after this change accesses to the key variable call __tls_get_addr, which is intercepted. The interceptor then calls GetCurrentThread which calls MsanTSDGet which again calls __tls_get_addr, etc... Using the default implementation in the SANITIZER_FREEBSD case fixes MSAN for me. I then applied the same change to ASAN (introduced in https://reviews.llvm.org/D55596) but that did not work yet. In the ASAN case, we get infinite recursion again during initialization, this time because calling pthread_key_create() early on results in infinite recursion. pthread_key_create() calls sysctlbyname() which is intercepted but COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED returns true, so the interceptor calls internal_sysctlbyname() which then ends up calling the interceptor again. I fixed this issue by using dlsym() to get the libc version of sysctlbyname() instead. This fixes https://llvm.org/PR40761 Reviewers: vitalybuka, krytarowski, devnexen, dim, bsdjhb, #sanitizers, MaskRay Reviewed By: MaskRay Subscribers: MaskRay, emaste, kubamracek, jfb, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D65221 llvm-svn: 367442
* Improve error message when '=' is missing in {ASAN,...}_OPTIONS.Vitaly Buka2019-06-151-4/+2
| | | | | | | | | | | | | | | | | | Summary: It's handling isses as described here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89832 Patch by Martin Liška. Reviewers: kcc, vitalybuka Reviewed By: vitalybuka Subscribers: cryptoad, kubamracek Differential Revision: https://reviews.llvm.org/D59876 llvm-svn: 363480
* [sanitizer] Don't generate "failed to intercept" constants for each functionVitaly Buka2019-05-161-9/+9
| | | | llvm-svn: 360958
* [MSan] Introduce __msan_unpoison_param().Matt Morehouse2019-05-092-0/+4
| | | | | | | | | | | | | | | | | | | Summary: This allows libFuzzer to unpoison parameter shadow before calling LLVMFuzzerTestOneInput to eliminate the false positives described in https://github.com/google/oss-fuzz/issues/2369. Reviewers: eugenis Reviewed By: eugenis Subscribers: llvm-commits, metzman, kcc Tags: #llvm Differential Revision: https://reviews.llvm.org/D61751 llvm-svn: 360379
* [compiler-rt][tests] Propagate COMPILER_RT_UNITTEST_LINK_FLAGSHubert Tong2019-05-011-1/+2
| | | | | | | | | | | | | | | | | | | | `COMPILER_RT_UNITTEST_LINK_FLAGS` is dropped in many places, unlike `COMPILER_RT_UNITTEST_CFLAGS`. This patch attempts to remove that inconsistency. Previously reviewed as part of D58951. Reviewers: sfertile, peter.smith, pzheng, phosek, Hahnfeld, nemanjai, jasonliu Reviewed By: sfertile Subscribers: jsji, kubamracek, dberris, mgorny, delcypher, jdoerfert, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D60143 llvm-svn: 359733
* [Sanitizer] Reland "Cleanup INTERCEPT_FUNCTION macro"Julian Lettner2019-05-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | On Linux both version of the INTERCEPT_FUNCTION macro now return true when interception was successful. Adapt and cleanup some usages. Also note that `&(func) == &WRAP(func)` is a link-time property, but we do a runtime check. Tested on Linux and macOS. Previous attempt reverted by: 5642c3feb03d020dc06a62e3dc54f3206a97a391 This attempt to bring order to the interceptor macro goes the other direction and aligns the Linux implementation with the way things are done on Windows. Reviewed By: vitalybuka, rnk Differential Revision: https://reviews.llvm.org/D61358 llvm-svn: 359725
* [sanitizer][NFC] Set LargeMmapAllocator type from PrimaryAllocatorVitaly Buka2019-05-011-2/+1
| | | | | | | | | | | | | | They need to have same AddressSpaceView and MapUnmapCallback. Reviewers: eugenis Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61168 llvm-svn: 359719
* [sanitizer][NFC] Get type of AllocatorCache from CombinedAllocatorVitaly Buka2019-05-011-3/+2
| | | | | | | | | | | | | | Reviewers: eugenis, cryptoad, kcc Reviewed By: kcc Subscribers: kcc, kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61155 llvm-svn: 359715
* [sanitizer] Implement reallocarray.Evgeniy Stepanov2019-05-013-0/+17
| | | | | | | | | | | | | | | | Summary: It's a cross of calloc and realloc. Sanitizers implement calloc-like check for size overflow. Reviewers: vitalybuka, kcc Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61108 llvm-svn: 359708
* Revert r359325 "[NFC][Sanitizer] Change "return type" of INTERCEPT_FUNCTION ↵Reid Kleckner2019-04-301-5/+2
| | | | | | | | | | | | | | | to void" Changing INTERCEPT_FUNCTION to return void is not functionally correct. IMO the best way to communicate failure or success of interception is with a return value, not some external address comparison. This change was also creating link errors for _except_handler4_common, which is exported from ucrtbase.dll in 32-bit Windows. Also revert dependent changes r359362 and r359466. llvm-svn: 359611
* [Sanitizer] Cleanup {ASAN, MSAN}_INTERCEPT_FUNC[_VER] macroJulian Lettner2019-04-291-3/+2
| | | | | | | | | | | | Note that this change is not strictly NFC since we add the `(&(name) != &WRAP(name)` part to the conditional for the `_VER` variant of the macro. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D61204 llvm-svn: 359466
* [sanitizer] Calculate SizeClassAllocator32::ByteMap type from ↵Vitaly Buka2019-04-271-10/+2
| | | | | | | | | | | | | | Params::kSpaceSize and Params::kRegionSizeLog Reviewers: eugenis Subscribers: kubamracek, cryptoad, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61206 llvm-svn: 359374
* [NFC][Sanitizer] Change "return type" of INTERCEPT_FUNCTION to voidJulian Lettner2019-04-261-2/+6
| | | | | | | | | | | | This temporary change tells us about all the places where the return value of the INTERCEPT_FUNCTION macro is actually used. In the next patch I will cleanup the macro and remove GetRealFuncAddress. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D61145 llvm-svn: 359325
* NFC: Clang-format msan_allocator.ccVitaly Buka2019-04-261-61/+61
| | | | llvm-svn: 359270
* [NFC] Use clearer naming for local variablesJF Bastien2019-04-101-7/+7
| | | | llvm-svn: 358145
* [Sanitizer] Add interceptor for wctombPavel Labath2019-03-291-0/+10
| | | | | | | | | | | | | | | | | Summary: This is required to avoid msan false positives for code using this function (although generally one should avoid using this function in favor of wcrtomb). Reviewers: eugenis, EricWF, vitalybuka Subscribers: srhines, kubamracek, fedor.sergeev, delcypher, llvm-commits, #sanitizers Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D59548 llvm-svn: 357240
* [msan] Fix BMI2 detection in msan tests, take 2.Jonas Hahnfeld2019-03-151-1/+1
| | | | | | | It's not enough if only one bit is present, we need to check that both are set. This finally fixes the test failures for me. llvm-svn: 356242
* [msan] Fix BMI2 detection in msan tests.Evgeniy Stepanov2019-03-121-1/+1
| | | | llvm-svn: 355885
* [msan] Properly guard tests added by r355348; NFCHubert Tong2019-03-081-4/+2
| | | | | | | r355348 uses builtins without proper guards, breaking the test on various platforms. llvm-svn: 355718
* [msan] Instrument x86 BMI intrinsics.Evgeniy Stepanov2019-03-041-1/+147
| | | | | | | | | | | | | | | | Summary: They simply shuffle bits. MSan needs to do the same with shadow bits, after making sure that the shuffle mask is fully initialized. Reviewers: pcc, vitalybuka Subscribers: hiraditya, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58858 llvm-svn: 355348
* Revert "[sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors."Evgeniy Stepanov2019-03-021-3/+3
| | | | | | | | | Breaks TSan on Mac, which does return REAL(func)(... in COMMON_INTERCEPTOR_ENTER, which is not OK when REAL(func) has return type of void. llvm-svn: 355256
* [NFC][Sanitizer] Make GetStackTrace a private method of BufferedStackTraceJulian Lettner2019-03-011-9/+7
| | | | | | | | | | GetStackTrace is a implementation detail of BufferedStackTrace. Make it a private method. Reviewed By: vitalybuka Differential-Revision: https://reviews.llvm.org/D58753 llvm-svn: 355232
* [sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors.Evgeniy Stepanov2019-03-011-3/+3
| | | | llvm-svn: 355231
* Revert "[sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors."Evgeniy Stepanov2019-03-011-3/+3
| | | | | | This change is incomplete. llvm-svn: 355230
* [sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors.Evgeniy Stepanov2019-03-011-3/+3
| | | | | | They return void, unlike memset/memcpy/memmove. llvm-svn: 355225
* [NFC][Sanitizer] Add new BufferedStackTrace::Unwind APIJulian Lettner2019-03-012-15/+12
| | | | | | | | | | | | | | | | | | | | | Retrying without replacing call sites in sanitizer_common (which might not have a symbol definition). Add new Unwind API. This is the final envisioned API with the correct abstraction level. It hides/slow fast unwinder selection from the caller and doesn't take any arguments that would leak that abstraction (i.e., arguments like stack_top/stack_bottom). GetStackTrace will become an implementation detail (private method) of the BufferedStackTrace class. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58741 > llvm-svn: 355168 llvm-svn: 355172
* Revert "[NFC][Sanitizer] Add new BufferedStackTrace::Unwind API"Julian Lettner2019-03-012-12/+15
| | | | | | This reverts commit 6112f37e758ebf2405955e091a745f5003c1f562. llvm-svn: 355171
* [NFC][Sanitizer] Add new BufferedStackTrace::Unwind APIJulian Lettner2019-03-012-15/+12
| | | | | | | | | | | | | | | | Add new Unwind API. This is the final envisioned API with the correct abstraction level. It hides/slow fast unwinder selection from the caller and doesn't take any arguments that would leak that abstraction (i.e., arguments like stack_top/stack_bottom). GetStackTrace will become an implementation detail (private method) of the BufferedStackTrace class. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58741 llvm-svn: 355168
* [NFC][Sanitizer] Pull up GetStackTrace into sanitizer_commonJulian Lettner2019-02-272-18/+17
| | | | | | | | | | | | | | | | | | | | We already independently declare GetStackTrace in all (except TSan) sanitizer runtime headers. Lets move it to sanitizer_stacktrace.h to have one canonical way to fill in a BufferedStackFrame. Also enables us to use it in sanitizer_common itself. This patch defines GetStackTrace for TSan and moves the function from ubsan_diag.cc to ubsan_diag_standalone.cc to avoid duplicate symbols for the UBSan-ASan runtime. Other than that this patch just moves the code out of headers and into the correct namespace. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58651 llvm-svn: 355039
* [NFC][Sanitizer] Hard-code fast/slow unwinder at call siteJulian Lettner2019-02-271-3/+6
| | | | | | | | | | | | | Also assert that the caller always gets what it requested. This purely mechanical change simplifies future refactorings and eventual removal of BufferedStackTrace::Unwind. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58557 llvm-svn: 355022
* [Sanitizer] Add interceptor for pthread_sigmaskPavel Labath2019-02-261-0/+8
| | | | | | | | | | | | | | | | | | | | | | Summary: pthread_sigmask is just like sigprocmask, except that its behavior in multithreaded programs is explicitly specified. Sanitizers were lacking a common interceptor for pthread_sigmask (although some specific sanitizers defined custom version), which lead to false positives (at least in msan) when using this function. The interceptor implementation, and its test are based on the equivalent code for sigprocmask. Reviewers: eugenis, vitalybuka Subscribers: kubamracek, delcypher, jfb, jdoerfert, llvm-commits, #sanitizers Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D58382 llvm-svn: 354874
* [compiler-rt] Build custom libcxx with libcxxabiJonas Hahnfeld2019-02-171-9/+7
| | | | | | | | | | | | | | | This changes add_custom_libcxx to also build libcxxabi and merges the two into a static and hermetic library. There are multiple advantages: 1) The resulting libFuzzer doesn't expose C++ internals and looks like a plain C library. 2) We don't have to manually link in libstdc++ to provide cxxabi. 3) The sanitizer tests cannot interfere with an installed version of libc++.so in LD_LIBRARY_PATH. Differential Revision: https://reviews.llvm.org/D58013 llvm-svn: 354212
* [msan] Don't delete MSanAtExitRecordVitaly Buka2019-02-141-1/+5
| | | | | | | | | | | | | | | | | | Summary: Pre 2.27 libc can run same atexit handler twice We will keep MSanAtExitRecord and reset fun to mark it as executed. Fix PR40162 Reviewers: eugenis Subscribers: jfb, jdoerfert, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58221 llvm-svn: 354005
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1922-88/+66
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Reimplement Thread Static Data MSan routines with TLSKamil Rytarowski2018-12-271-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Thread Static Data cannot be used in early init on NetBSD and FreeBSD. Reuse the MSan TSD API for compatibility with existing code with an alternative implementation using Thread Local Storage. New version uses Thread Local Storage to store a pointer with thread specific data. The destructor from TSD has been replaced with a TLS destrucutor that is called upon thread exit. Reviewers: joerg, vitalybuka, jfb Reviewed By: vitalybuka Subscribers: emaste, jfb, llvm-commits, #sanitizers, mgorny Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D55703 llvm-svn: 350102
* Revert "[msan] Disable tail call optimization in msan rtl."Evgeniy Stepanov2018-12-271-5/+0
| | | | | | | | This reverts commit r350080, which breaks * gcc as the host compiler * some tests on ppc64 llvm-svn: 350083
* [msan] Disable tail call optimization in msan rtl.Evgeniy Stepanov2018-12-271-0/+5
| | | | | | | This should give us better error stack traces on the bots, in particular, for https://bugs.llvm.org/show_bug.cgi?id=40162 llvm-svn: 350080
OpenPOWER on IntegriCloud