summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
Commit message (Collapse)AuthorAgeFilesLines
...
* [compiler-rt] Use NOINLE to shrink stack framesVitaly Buka2017-07-201-5/+7
| | | | llvm-svn: 308654
* [compiler-rt] Reorder functions to shrink stack framesVitaly Buka2017-07-201-8/+14
| | | | llvm-svn: 308652
* Revert "[compiler-rt] Reorder functions to have smaller stack frames"Vitaly Buka2017-07-201-10/+4
| | | | | | | | Does not compile. This reverts commit r308650. llvm-svn: 308651
* [compiler-rt] Reorder functions to have smaller stack framesVitaly Buka2017-07-201-4/+10
| | | | llvm-svn: 308650
* Revert "[sanitizer_common] Move filesystem-related code out of ↵Vitaly Buka2017-07-2016-295/+220
| | | | | | | | | | sanitizer_common.cc" Breaks Windows build. This reverts commit r308640. llvm-svn: 308648
* Add MemoryMappedSection struct for two-level memory map iterationFrancis Ricci2017-07-202-9/+57
| | | | | | | | | | | | Summary: This will allow sanitizer_procmaps on mac to expose section information. Reviewers: kubamracek, alekseyshl, kcc Subscribers: llvm-commits, emaste Differential Revision: https://reviews.llvm.org/D35422 llvm-svn: 308644
* [sanitizer_common] Move filesystem-related code out of sanitizer_common.ccAlex Shlyapnikov2017-07-2016-220/+295
| | | | | | | | | | | | | | | | | This is a pure refactoring change. It just moves code that is related to filesystem operations from sanitizer_common.{cc,h} to sanitizer_file.{cc,h}. This makes it cleaner to disable the filesystem-related code for a new port that doesn't want it. Commiting for mcgrathr. Reviewers: alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35591 llvm-svn: 308640
* [compiler-rt] Include thread ID into sanitizers logsVitaly Buka2017-07-201-5/+4
| | | | | | | | | | Reviewers: kcc, alekseyshl Subscribers: kubamracek, llvm-commits, dberris Differential Revision: https://reviews.llvm.org/D35654 llvm-svn: 308637
* Honour 80-character line limitKamil Rytarowski2017-07-201-1/+2
| | | | llvm-svn: 308620
* Add NetBSD support in sanitizer_libignore.ccKamil Rytarowski2017-07-201-2/+2
| | | | | | | | | | | | | | | | | | | | | Summary: Reuse Linux, FreeBSD and Apple code - no NetBSD specific changes. Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, filcab, kcc Reviewed By: filcab Subscribers: emaste, kubamracek, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35628 llvm-svn: 308616
* Add NetBSD support in sanitizer_procmaps.hKamil Rytarowski2017-07-201-3/+3
| | | | | | | | | | | | | | | | | | | | | Summary: Reuse Linux and FreeBSD - no NetBSD specific changes. Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, filcab, kcc, vitalybuka Reviewed By: filcab Subscribers: llvm-commits, emaste, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35629 llvm-svn: 308615
* Add NetBSD support in sanitizer_procmaps_common.ccKamil Rytarowski2017-07-201-2/+2
| | | | | | | | | | | | | | | | | | | | | Summary: Reuse Linux and FreeBSD code - no NetBSD specific changes. Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, vitalybuka, filcab Reviewed By: filcab Subscribers: emaste, kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35632 llvm-svn: 308614
* [compiler-rt] Replace VPrintf with VReport in sanitizer_tls_get_addr.ccVitaly Buka2017-07-201-9/+9
| | | | | | | | | | | | | | | Summary: Thread id will be added to VRerort. Having thread here is useful. This is also common place for logging for all sanitizers, so I can use this in common test. Reviewers: kcc, alekseyshl Subscribers: kubamracek, llvm-commits, dberris Differential Revision: https://reviews.llvm.org/D35655 llvm-svn: 308578
* Revert "Add MemoryMappedSection struct for two-level memory map iteration"Francis Ricci2017-07-182-54/+9
| | | | | | | | This reverts commit c8095ce74118dee8544b0f1ffaba8f46aa10215c. Reverted due to some buildbot timeouts, perhaps due to 10.11 issues. llvm-svn: 308395
* Revert "Only scan global sections containing data in LSan on darwin"Francis Ricci2017-07-184-17/+7
| | | | | | This reverts commit 7e46d78d47832f03ce42adcf56417fbfd47cbaad. llvm-svn: 308394
* [Sanitizers] ASan/MSan/LSan allocators set errno on failure.Alex Shlyapnikov2017-07-183-12/+66
| | | | | | | | | | | | | | | | | | | | | 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
* Only scan global sections containing data in LSan on darwinFrancis Ricci2017-07-174-7/+17
| | | | | | | | | | | | | | | | | | | | Summary: __DATA segments on Darwin contain a large number of separate sections, most of which cannot actually contain pointers, and contain const values or objc metadata. Only scanning sections which can contain pointers greatly improves performance. On a medium-sized (~4000 files) internal project, I saw a speedup of about 50% in standalone LSan's execution time (50% improvement in the time spent running LSan, not the total program time). Reviewers: kcc, kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35432 llvm-svn: 308231
* [sanitizers] Make sure that all complex macros uses parenthesisVitaly Buka2017-07-171-55/+61
| | | | | | | | | | | | | | Summary: Without them expressions like this may have different values. (SANITIZER_INTERCEPT_MEMRCHR && SANITIZER_INTERCEPT_PREADV) Reviewers: alekseyshl Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D35512 llvm-svn: 308228
* Add missing && to fix syntax.Kamil Rytarowski2017-07-171-1/+1
| | | | llvm-svn: 308221
* Add NetBSD support in platform_interceptors.hKamil Rytarowski2017-07-171-41/+57
| | | | | | | | | | | | | | | | | | | | | | | Summary: Introduce SI_NETBSD for NetBSD. Add NetBSD support for appropriate `SANITIZER_INTERCEPT_*`. Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, dim, kcc, alekseyshl, filcab, eugenis, vitalybuka Reviewed By: vitalybuka Subscribers: srhines, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35468 llvm-svn: 308217
* Introduce SANITIZER_NETBSD in sanitizer_platform.hKamil Rytarowski2017-07-171-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Add defines for new NetBSD: SANITIZER_NETBSD, it will be used across the codebase for sanitizers. NetBSD is a POSIX-like platform, add it to SANITIZER_POSIX. Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, dim, alekseyshl, filcab, eugenis, vitalybuka Reviewed By: kcc Subscribers: kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35467 llvm-svn: 308216
* Add MemoryMappedSection struct for two-level memory map iterationFrancis Ricci2017-07-172-9/+54
| | | | | | | | | | | | Summary: This will allow sanitizer_procmaps on mac to expose section information. Reviewers: kubamracek, alekseyshl, kcc Subscribers: llvm-commits, emaste Differential Revision: https://reviews.llvm.org/D35422 llvm-svn: 308210
* [asan] Attempt to fix test in Windows after r308064Vitaly Buka2017-07-161-0/+2
| | | | llvm-svn: 308120
* [compiler-rt] Fix fix format specifies type in testVitaly Buka2017-07-161-2/+2
| | | | llvm-svn: 308117
* Fix sanitizer build against latest glibcKostya Serebryany2017-07-133-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: libsanitizer doesn't build against latest glibc anymore, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81066 for details. One of the changes is that stack_t changed from typedef struct sigaltstack { ... } stack_t; to typedef struct { ... } stack_t; for conformance reasons. And the other change is that the glibc internal __need_res_state macro is now ignored, so when doing ``` #define __need_res_state #include <resolv.h> ``` the effect is now the same as just ``` #include <resolv.h> ``` and thus one doesn't get just the ``` struct __res_state { ... }; ``` definition, but newly also the ``` extern struct __res_state *__res_state(void) __attribute__ ((__const__)); ``` prototype. So __res_state is no longer a type, but a function. Reviewers: kcc, ygribov Reviewed By: kcc Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D35246 llvm-svn: 307969
* For Darwin's GetTaskInfoMaxAddress, define the real structure with real ↵Kuba Mracek2017-07-131-5/+26
| | | | | | fields to avoid confusion. NFC. llvm-svn: 307945
* [asan] For iOS/AArch64, if the dynamic shadow doesn't fit, restrict the VM spaceKuba Mracek2017-07-127-8/+51
| | | | | | | | | | On iOS/AArch64, the address space is very limited and has a dynamic maximum address based on the configuration of the device. We're already using a dynamic shadow, and we find a large-enough "gap" in the VM where we place the shadow memory. In some cases and some device configuration, we might not be able to find a large-enough gap: E.g. if the main executable is linked against a large number of libraries that are not part of the system, these libraries can fragment the address space, and this happens before ASan starts initializing. This patch has a solution, where we have a "backup plan" when we cannot find a large-enough gap: We will restrict the address space (via MmapFixedNoAccess) to a limit, for which the shadow limit will fit. Differential Revision: https://reviews.llvm.org/D35098 llvm-svn: 307865
* Use internal_strncpy to copy filename in linux procmapsFrancis Ricci2017-07-111-6/+5
| | | | | | | | | | | | Cleaner than using a while loop to copy the string character by character. Reviewers: alekseyshl, glider Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35136 llvm-svn: 307696
* Inline function to get mac segment address rangeFrancis Ricci2017-07-112-63/+58
| | | | | | | | | | | | | | Summary: This function is only called once and is fairly simple. Inline to keep API simple. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35270 llvm-svn: 307695
* Refactor MemoryMappingLayout::Next to use a single struct instead of output ↵Francis Ricci2017-07-118-162/+118
| | | | | | | | | | | | | | | | | | | | | | | | | parameters. NFC. Summary: This is the first in a series of patches to refactor sanitizer_procmaps to allow MachO section information to be exposed on darwin. In addition, grouping all segment information in a single struct is cleaner than passing it through a large set of output parameters, and avoids the need for annotations of NULL parameters for unneeded information. The filename string is optional and must be managed and supplied by the calling function. This is to allow the MemoryMappedSegment struct to be stored on the stack without causing overly large stack sizes. Reviewers: alekseyshl, kubamracek, glider Subscribers: emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D35135 llvm-svn: 307688
* Remove duplicate assignments in stat64/kernel_stat_to_stat functionsPetar Jovanovic2017-07-111-2/+0
| | | | | | Remove duplicate assignments in stat64_to_stat() and kernel_stat_to_stat(). llvm-svn: 307657
* Do not crash with missing symbolication when running in DEDUP modeGeorge Karpenkov2017-07-101-1/+2
| | | | | | | | | Printing stacktrace from ASAN crashes with a segfault in DEDUP mode when symbolication is missing. Differential Revision: https://reviews.llvm.org/D34914 llvm-svn: 307577
* Fix-up for r307307: vm_info.max_address is the first non-addressable ↵Kuba Mracek2017-07-071-1/+1
| | | | | | pointer, so we need to subtract one. llvm-svn: 307408
* Fix whitespace lint issue (introduced in r307307).Kuba Mracek2017-07-061-1/+1
| | | | llvm-svn: 307309
* [sanitizer] Use TASK_VM_INFO to get the maximum VM address on iOS/AArch64Kuba Mracek2017-07-061-3/+27
| | | | | | | | We currently hardcode the maximum VM address on iOS/AArch64, which is not really correct and this value changes between device configurations. Let's use TASK_VM_INFO to retrieve the maximum VM address dynamically. Differential Revision: https://reviews.llvm.org/D35032 llvm-svn: 307307
* More fixup for r307281: Move the #includes to sanitizer_linux.ccKuba Mracek2017-07-062-8/+8
| | | | llvm-svn: 307284
* Fixup for r307281: Also move GetKernelAreaSize into sanitizer_linux.ccKuba Mracek2017-07-062-39/+39
| | | | llvm-svn: 307282
* [sanitizer] Split GetMaxVirtualAddress into separate Linux version and Mac ↵Kuba Mracek2017-07-063-35/+45
| | | | | | | | | | version [NFC] The logic in GetMaxVirtualAddress is already pretty complex, and I want to get rid of the hardcoded value for iOS/AArch64, which would need adding more Darwin-specific code, so let's split the implementation into sanitizer_linux.cc and sanitizer_mac.cc files. NFC. Differential Revision: https://reviews.llvm.org/D35031 llvm-svn: 307281
* [Sanitizers] Consolidate internal errno definitions.Alex Shlyapnikov2017-07-067-12/+108
| | | | | | | Move internal errno definitions to common to be shared by all sanitizers and to be used by allocators. llvm-svn: 307233
* [tsan] Use pthread_sigmask instead of sigprocmask to block signals in a ↵Kuba Mracek2017-07-051-1/+2
| | | | | | | | | | thread on Darwin On Darwin, sigprocmask changes the signal mask for the entire process. This has some unwanted consequences, because e.g. internal_start_thread wants to disable signals only in the current thread (to make the new thread inherit the signal mask), which is currently broken on Darwin. This patch switches to pthread_sigmask. Differential Revision: https://reviews.llvm.org/D35016 llvm-svn: 307212
* fix trivial typos in comments; NFCHiroshi Inoue2017-07-031-1/+1
| | | | llvm-svn: 307005
* [sanitizer] Small tweaks and fixes to allocator related functionsKostya Kortchinsky2017-06-303-16/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In `sanitizer_allocator_primary32.h`: - rounding up in `MapWithCallback` is not needed as `MmapOrDie` does it. Note that the 64-bit counterpart doesn't round up, this keeps the behavior consistent; - since `IsAligned` exists, use it in `AllocateRegion`; - in `PopulateFreeList`: - checking `b->Count` to be greater than 0 when `b->Count() == max_count` is redundant when done more than once. Just check that `max_count` is greater than 0 out of the loop; the compiler (at least on ARM) didn't optimize it; - mark the batch creation failure as `UNLIKELY`; In `sanitizer_allocator_primary64.h`: - in `MapWithCallback`, mark the failure condition as `UNLIKELY`; In `sanitizer_posix.h`: - mark a bunch of Mmap related failure conditions as `UNLIKELY`; - in `MmapAlignedOrDieOnFatalError`, we have `IsAligned`, so use it; rearrange the conditions as one test was redudant; - in `MmapFixedImpl`, 30 chars was not large enough to hold the message and a full 64-bit address (or at least a 48-bit usermode address), increase to 40. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: aemerson, kubamracek, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D34840 llvm-svn: 306834
* MergeAlex Shlyapnikov2017-06-292-4/+6
| | | | llvm-svn: 306746
* Fix WinASan after moving wcslen interceptor to sanitizer_commonReid Kleckner2017-06-292-5/+0
| | | | | | | | | | | Do this by removing SANITIZER_INTERCEPT_WCSLEN and intercept wcslen everywhere. Before this change, we were already intercepting wcslen on Windows, but the interceptor was in asan, not sanitizer_common. After this change, we stopped intercepting wcslen on Windows, which broke asan_dll_thunk.c, which attempts to thunk to __asan_wcslen in the ASan runtime. llvm-svn: 306706
* [Sanitizers] Operator new() interceptors always die on allocation errorAlex Shlyapnikov2017-06-282-4/+4
| | | | | | | | | | | | | | | | | | | | | 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-10/+69
| | | | | | | | | | | | | | 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] 64 bit allocator respects allocator_may_return_null flagAlex Shlyapnikov2017-06-266-98/+168
| | | | | | | | | | | | | | | | Summary: Make SizeClassAllocator64 return nullptr when it encounters OOM, which allows the entire sanitizer's allocator to follow allocator_may_return_null=1 policy (LargeMmapAllocator: D34243, SizeClassAllocator64: D34433). Reviewers: eugenis Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34540 llvm-svn: 306342
* [asan] Add support for Android debug message.Evgeniy Stepanov2017-06-232-0/+10
| | | | | | Add ASan report to the "debug message" field in Android tombstones. llvm-svn: 306184
* [Sanitizers] 32 bit allocator respects allocator_may_return_null flagAlex Shlyapnikov2017-06-226-24/+52
| | | | | | | | | | | | | | | | | | | Summary: Make SizeClassAllocator32 return nullptr when it encounters OOM, which allows the entire sanitizer's allocator to follow allocator_may_return_null=1 policy, even for small allocations (LargeMmapAllocator is already fixed by D34243). Will add a test for OOM in primary allocator later, when SizeClassAllocator64 can gracefully handle OOM too. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34433 llvm-svn: 305972
* [sanitizer] Add a function to gather random bytesKostya Kortchinsky2017-06-215-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: AFAICT compiler-rt doesn't have a function that would return 'good' random bytes to seed a PRNG. Currently, the `SizeClassAllocator64` uses addresses returned by `mmap` to seed its PRNG, which is not ideal, and `SizeClassAllocator32` doesn't benefit from the entropy offered by its 64-bit counterpart address space, so right now it has nothing. This function aims at solving this, allowing to implement good 32-bit chunk randomization. Scudo also has a function that does this for Cookie purposes, which would go away in a later CL once this lands. This function will try the `getrandom` syscall if available, and fallback to `/dev/urandom` if not. Unfortunately, I do not have a way to implement and test a Mac and Windows version, so those are unimplemented as of now. Note that `kRandomShuffleChunks` is only used on Linux for now. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: zturner, rnk, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34412 llvm-svn: 305922
OpenPOWER on IntegriCloud