summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/msan
Commit message (Collapse)AuthorAgeFilesLines
...
* Correct atexit(3) support in MSan/NetBSDKamil Rytarowski2017-12-061-3/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The NetBSD specific implementation of cxa_atexit() does not preserve the 2nd argument if dso is equal to NULL. Changes: - Split paths of handling intercepted __cxa_atexit() and atexit(3). This affects all supported Operating Systems. - Add a local stack-like structure to hold the __cxa_atexit() context. atexit(3) is documented in the C standard as calling callback from the earliest to the oldest entry. This path also fixes potential ABI problem of passing an argument to a function from the atexit(3) callback mechanism. - Allow usage of global vars with ctors in interceptors. This allows to use Vector without automatic cleaning up the structures. This code has been modeled after TSan implementation for the same functions. Sponsored by <The NetBSD Foundation> Reviewers: joerg, dvyukov, eugenis, vitalybuka, kcc Reviewed By: vitalybuka Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40714 llvm-svn: 319967
* Handle NetBSD symbol renaming in msan_interceptors.ccKamil Rytarowski2017-12-061-17/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: NetBSD renames symbols for historical and compat reasons. Add required symbol renames in sanitizer_common_interceptors.inc: - gettimeofday -> __gettimeofday50 - getrusage -> __getrusage50 - shmctl -> __shmctl50 Additionally handle sigaction symbol mangling. Rename the function symbol in the file to SIGACTION_SYMNAME and define it as __sigaction14 for NetBSD and sigaction for !NetBSD. We cannot use simple renaming with the proprocessor, as there are valid fields named sigaction and they must be left intact. Sponsored by <The NetBSD Foundation> Reviewers: joerg, eugenis, vitalybuka, dvyukov Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40766 llvm-svn: 319966
* Fix typo fcvr -> fcvt and attempt to unbreak MSan/!NetBSDKamil Rytarowski2017-12-061-1/+1
| | | | llvm-svn: 319872
* Fix typo gcvr -> gcvt and attempt to unbreak MSan/!NetBSDKamil Rytarowski2017-12-061-1/+1
| | | | llvm-svn: 319871
* Support pthread_key_create symbol alias in MSan/NetBSDKamil Rytarowski2017-12-061-0/+10
| | | | | | | | | | | | | | | | | | | | | Summary: NetBSD uses indirection symbol for a set of threading functions. Add alias to handle __libc_thr_keycreate the same way as pthread_key_create. Sponsored by <The NetBSD Foundation> Reviewers: joerg, dvyukov, eugenis, vitalybuka Reviewed By: vitalybuka Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40767 llvm-svn: 319868
* Disable absent functions in MSan/NetBSD interceptorsKamil Rytarowski2017-12-061-7/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Disable for NetBSD missing functions missing in this OS: - mempcpy, - __libc_memalign, - malloc_usable_size, - stpcpy, - gcvt, - wmempcpy, - fcvt. Sponsored by <The NetBSD Foundation> Reviewers: joerg, dvyukov, eugenis, vitalybuka, kcc Reviewed By: vitalybuka Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40764 llvm-svn: 319866
* [msan] Fix formattingVitaly Buka2017-12-051-1/+1
| | | | llvm-svn: 319844
* [msan] add strtouq msan interceptorVitaly Buka2017-12-052-0/+3
| | | | | | | | | | | | Summary: Fixes https://github.com/google/sanitizers/issues/892 Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40853 llvm-svn: 319843
* [msan] Fix return type of mbrtowcVitaly Buka2017-11-302-8/+11
| | | | | | | | | | | | Summary: Fixes https://github.com/google/oss-fuzz/issues/1009 Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40676 llvm-svn: 319484
* Linux needs to include sys/uio.h for readv, preadvStephan Bergmann2017-11-301-0/+3
| | | | | | ...at least when building against glibc-2.26-16.fc27.x86_64 llvm-svn: 319412
* [msan] Avoid shadowing a variable in common interceptors.Evgeniy Stepanov2017-11-271-16/+15
| | | | | | | | | "offset" declared in a macro may shadow a variable with the same name in the caller which is used in a macro argument. We are quite lucky that it does not actually happen, but rename the variable anyway to be on the safe side. llvm-svn: 319115
* [msan] Fix signal chainingVitaly Buka2017-11-111-1/+1
| | | | | | Return internally stored handlers only if handlers is set to wrapper llvm-svn: 317970
* [msan] Remove INTERCEPT_FUNCTION for sigaction and signalVitaly Buka2017-11-101-2/+0
| | | | | | Already done in InitializeSignalInterceptors() llvm-svn: 317906
* [tsan] Use __sanitizer_siginfo from sanitizer_commonVitaly Buka2017-11-101-2/+2
| | | | llvm-svn: 317872
* [msan] Deadly signal handler for msanVitaly Buka2017-11-102-14/+26
| | | | | | | | | | | | Summary: Part of https://github.com/google/sanitizers/issues/637 Reviewers: eugenis, alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D39826 llvm-svn: 317864
* [msan] Move sigaction_impl and signal_implVitaly Buka2017-11-101-52/+53
| | | | llvm-svn: 317863
* [msan] Extract signal_impl and sigaction_implVitaly Buka2017-11-091-5/+17
| | | | | | | | | | | | Summary: Preparation for using interceptor from sanitizer_common. Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39824 llvm-svn: 317844
* [msan] Replace CommonSanitizerReportMutex with ScopedErrorReportLockVitaly Buka2017-11-091-4/+4
| | | | llvm-svn: 317842
* [PowerPC][msan] Update msan to handle changed memory layouts in newer kernelsBill Seurer2017-11-091-11/+15
| | | | | | | | | | | | In more recent Linux kernels (including those with 47 bit VMAs) the layout of virtual memory for powerpc64 changed causing the memory sanitizer to not work properly. This patch adjusts the memory ranges in the tables for the memory sanitizer to work on the newer kernels while continuing to work on the older ones as well. Tested on several 4.x and 3.x kernel releases. llvm-svn: 317802
* [msan] Add context argument into GetStackTraceVitaly Buka2017-11-092-22/+22
| | | | llvm-svn: 317773
* (NFC) Rename GetMax{,User}VirtualAddress.Evgeniy Stepanov2017-11-071-1/+1
| | | | | | | Future change will introduce GetMaxVirtualAddress that will not take the kernel area into account. llvm-svn: 317638
* [msan] Intercept __strxfrm_l.Evgeniy Stepanov2017-10-251-0/+15
| | | | llvm-svn: 316613
* Add NetBSD improvements in sanitizersKamil Rytarowski2017-10-252-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Changes: * Add initial msan stub support. * Handle NetBSD specific pthread_setname_np(3). * NetBSD supports __attribute__((tls_model("initial-exec"))), define it in SANITIZER_TLS_INITIAL_EXEC_ATTRIBUTE. * Add ReExec() specific bits for NetBSD. * Simplify code and add syscall64 and syscall_ptr for !NetBSD. * Correct bunch of syscall wrappers for NetBSD. * Disable test/tsan/map32bit on NetBSD as not applicable. * Port test/tsan/strerror_r to a POSIX-compliant OSes. * Disable __libc_stack_end on NetBSD. * Disable ReadNullSepFileToArray() on NetBSD. * Define struct_ElfW_Phdr_sz, detected missing symbol by msan. * Change type of __sanitizer_FILE from void to char. This helps to reuse this type as an array. Long term it will be properly implemented along with SANITIZER_HAS_STRUCT_FILE setting to 1. * Add initial NetBSD support in lib/tsan/go/buildgo.sh. * Correct referencing stdout and stderr in tsan_interceptors.cc on NetBSD. * Document NetBSD x86_64 specific virtual memory layout in tsan_platform.h. * Port tests/rtl/tsan_test_util_posix.cc to NetBSD. * Enable NetBSD tests in test/msan/lit.cfg. * Enable NetBSD tests in test/tsan/lit.cfg. Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, eugenis, kcc, dvyukov Reviewed By: dvyukov Subscribers: #sanitizers, llvm-commits, kubamracek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D39124 llvm-svn: 316591
* [compiler-rt] Cleanup decoratorsVitaly Buka2017-09-111-12/+11
| | | | | | | | | | | | | | Summary: Removed redundant End*() methods which defined same way. Removed redundant Warning() methods. Reviewers: eugenis Subscribers: kubamracek, llvm-commits, dberris Differential Revision: https://reviews.llvm.org/D37549 llvm-svn: 312950
* [msan] Remove a stale fixme (NFC).Evgeniy Stepanov2017-09-061-2/+0
| | | | | | It was fixed in 312576. llvm-svn: 312597
* [msan] Check sigset_t and sigaction arguments.Evgeniy Stepanov2017-09-051-0/+10
| | | | | | | | | | | | | | | | Summary: Check sigset_t arguments in ppoll, sig*wait*, sigprocmask interceptors, and the entire "struct sigaction" in sigaction. This can be done because sigemptyset/sigfullset are intercepted and signal masks should be correctly marked as initialized. Reviewers: vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D37367 llvm-svn: 312576
* (NFC) Fix the use of do{}while(0) in a macro.Evgeniy Stepanov2017-09-021-3/+3
| | | | llvm-svn: 312396
* [msan] Switch the pvalloc overflow test to a lit testBenjamin Kramer2017-08-041-6/+0
| | | | | | | | | | | | The test was not passing on targets where allocator_may_return_null defaults to true. Change the test to a lit test so that we can test both situations. Patch by Kostya Kortchinsky! Differential Revision: https://reviews.llvm.org/D36302 llvm-svn: 310033
* [msan] Check for pvalloc overflowKostya Kortchinsky2017-08-022-0/+10
| | | | | | | | | | | | | | | | | | | | | Summary: CheckForPvallocOverflow was introduced with D35818 to detect when pvalloc would wrap when rounding up to the next multiple of the page size. Add this check to MSan's pvalloc implementation. This time I made sure I was actually running (and writing) the correct tests, and that they are passing... Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36164 llvm-svn: 309883
* [msan] Reverting D36093Kostya Kortchinsky2017-07-312-15/+0
| | | | | | | | | | | | | | | | Summary: Reverting D36093 until I can figure out how to launch the correct tests :/ My apologies. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36120 llvm-svn: 309637
* [msan] Check for pvalloc overflowKostya Kortchinsky2017-07-312-1/+16
| | | | | | | | | | | | | | | | | | Summary: `CheckForPvallocOverflow` was introduced with D35818 to detect when pvalloc would wrap when rounding up to the next multiple of the page size. Add this check to MSan's pvalloc implementation. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36093 llvm-svn: 309601
* [compiler-rt] Add missing quotation marks to msan_compile invocationKrzysztof Parzyszek2017-07-281-1/+1
| | | | llvm-svn: 309430
* [sanitizer tests CMake] Factor out CMake logic for compiling sanitizer testsGeorge Karpenkov2017-07-281-22/+15
| | | | | | | | | | | Currently there's a large amount of CMake logic duplication for compiling sanitizer tests. If we add more sanitizers, the duplication will get even worse. This change factors out common compilation commands into a macro available to all sanitizers. llvm-svn: 309405
* [Sanitizers] ASan/MSan/LSan allocators set errno on failure.Alex Shlyapnikov2017-07-184-54/+96
| | | | | | | | | | | | | | | | | | | | | Summary: ASan/MSan/LSan allocators set errno on allocation failures according to malloc/calloc/etc. expected behavior. MSan allocator was refactored a bit to make its structure more similar with other allocators. Also switch Scudo allocator to the internal errno definitions. TSan allocator changes will follow. Reviewers: eugenis Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D35275 llvm-svn: 308344
* [Sanitizers] Consolidate internal errno definitions.Alex Shlyapnikov2017-07-061-8/+3
| | | | | | | Move internal errno definitions to common to be shared by all sanitizers and to be used by allocators. llvm-svn: 307233
* MergeAlex Shlyapnikov2017-06-291-1/+1
| | | | llvm-svn: 306746
* [Sanitizers] Operator new() interceptors always die on allocation errorAlex Shlyapnikov2017-06-281-6/+14
| | | | | | | | | | | | | | | | | | | | | Summary: Operator new interceptors behavior is now controlled by their nothrow property as well as by allocator_may_return_null flag value: - allocator_may_return_null=* + new() - die on allocation error - allocator_may_return_null=0 + new(nothrow) - die on allocation error - allocator_may_return_null=1 + new(nothrow) - return null Ideally new() should throw std::bad_alloc exception, but that is not trivial to achieve, hence TODO. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34731 llvm-svn: 306604
* [msan] Intercept wcscat, wcsncat.Evgeniy Stepanov2017-06-272-48/+76
| | | | | | | | | | | | | | Also move wcslen, wscnlen to common interceptors. Reviewers: vitalybuka Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34656 llvm-svn: 306482
* [Sanitizers] Move cached allocator_may_return_null flag to sanitizer_allocatorAlex Shlyapnikov2017-06-201-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Move cached allocator_may_return_null flag to sanitizer_allocator.cc and provide API to consolidate and unify the behavior of all specific allocators. Make all sanitizers using CombinedAllocator to follow AllocatorReturnNullOrDieOnOOM() rules to behave the same way when OOM happens. When OOM happens, turn allocator_out_of_memory flag on regardless of allocator_may_return_null flag value (it used to not to be set when allocator_may_return_null == true). release_to_os_interval_ms and rss_limit_exceeded will likely be moved to sanitizer_allocator.cc too (later). Reviewers: eugenis Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34310 llvm-svn: 305858
* [Sanitizer] Remove CombinedAllocator::Allocate's 'cleared' parameterAlex Shlyapnikov2017-06-161-2/+2
| | | | | | | | | | | | | | Summary: CombinedAllocator::Allocate cleared parameter is not used anywhere and seem to be obsolete. Reviewers: eugenis Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34289 llvm-svn: 305590
* Revert r304285, r304297.Evgeniy Stepanov2017-06-053-101/+94
| | | | | | | | | | | r304285 - [sanitizer] Avoid possible deadlock in child process after fork r304297 - [sanitizer] Trying to fix MAC buildbots after r304285 These changes create deadlock when Tcl calls pthread_create from a pthread_atfork child handler. More info in the original review at https://reviews.llvm.org/D33325 llvm-svn: 304735
* [asan] Add strndup/__strndup interceptors.Pierre Gousseau2017-06-012-31/+18
| | | | | | | | Recommit of r302781 with Vitaly Buka's fix for non zero terminated strings. Differential Revision: https://reviews.llvm.org/D31457 llvm-svn: 304399
* [sanitizer] Avoid possible deadlock in child process after forkMaxim Ostapenko2017-05-313-94/+101
| | | | | | | | | | | | | | This patch addresses https://github.com/google/sanitizers/issues/774. When we fork a multi-threaded process it's possible to deadlock if some thread acquired StackDepot or allocator internal lock just before fork. In this case the lock will never be released in child process causing deadlock on following memory alloc/dealloc routine. While calling alloc/dealloc routines after multi-threaded fork is not allowed, most of modern allocators (Glibc, tcmalloc, jemalloc) are actually fork safe. Let's do the same for sanitizers except TSan that has complex locking rules. Differential Revision: https://reviews.llvm.org/D33325 llvm-svn: 304285
* Revert r302781 and subsequent attempts to disable part of it.Daniel Jasper2017-05-182-11/+31
| | | | | | | The Msan unit tests are still broken and by this point, I think we should start over. llvm-svn: 303339
* [sanitizer] Change SizeClassAllocator32 to accept just one templateKostya Kortchinsky2017-05-151-9/+22
| | | | | | | | | | | | | | | | | | | | | Summary: With rL279771, SizeClassAllocator64 was changed to accept only one template instead of 5, for the following reasons: "First, this will make the mangled names shorter. Second, this will make adding more parameters simpler". This patch mirrors that work for SizeClassAllocator32. This is in preparation for introducing the randomization of chunks in the 32-bit SizeClassAllocator in a later patch. Reviewers: kcc, alekseyshl, dvyukov Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D33141 llvm-svn: 303071
* [msan] Remove a failing test from MemorySanitizer.ICmpRelationalAlexander Potapenko2017-05-121-2/+4
| | | | | | | | | | | This is a follow-up to r302787, which broke MemorySanitizer.ICmpRelational. MSan is now reporting a false positive on the following test case: TestForNotPoisoned((poisoned(-1, 0x80000000U) >= poisoned(-1, 0U))) , which is sort of anticipated, because we're approximating the comparison with an OR of the arguments' shadow values. llvm-svn: 302887
* [asan] Recommit of r301904: Add strndup/__strndup interceptorsPierre Gousseau2017-05-112-31/+11
| | | | | | | | | Fix undeclared __interceptor_malloc in esan_interceptors.cc Fix undeclared strnlen on OSX Differential Revision: https://reviews.llvm.org/D31457 llvm-svn: 302781
* [msan] Fix getmntent{_r} for empty /etc/fstabAdhemerval Zanella2017-05-101-2/+46
| | | | | | | | | | | | | Some configuration (for instance default docker ubuntu images) uses a default empty and invalid /etc/fstab configuration file. It makes any call to getmntent return NULL and it leads to failures on Msan-aarch64{-with-call}-Test/MemorySanitizer.getmntent{_r}. This patch fixes it by creating a temporary file with some valid entries (although not valid for the system) to use along with setmntent/getmntent. llvm-svn: 302639
* Revert r301904 causing tsan test failure in x86_64-linux-autoconfPierre Gousseau2017-05-022-11/+31
| | | | llvm-svn: 301909
* [asan] Add strndup/__strndup interceptors if targeting linux.Pierre Gousseau2017-05-022-31/+11
| | | | | | Differential Revision: https://reviews.llvm.org/D31457 llvm-svn: 301904
OpenPOWER on IntegriCloud