summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "Revert "[sanitizers] Restore internal_readlink for x32""H.J. Lu2019-02-282-1/+9
| | | | | | | | | This reverts revision 354601 and disables ReadBinaryNameCached check on Windows since Windows has no working ReadBinaryName. Differential Revision: https://reviews.llvm.org/D58788 llvm-svn: 355129
* [sanitizer] Fix vfork interceptor on i386 w/ dynamic runtime.Evgeniy Stepanov2019-02-281-2/+16
| | | | | | | | PLT calls on i386 expect GOT base address in %ebx. This call does not need to go through PLT strictly speaking, but I'd rather avoid future surprises and implement the most general case. llvm-svn: 355125
* [sanitizer] Got rid of text relocations in i386 vfork interceptor.Evgeniy Stepanov2019-02-281-2/+6
| | | | llvm-svn: 355064
* Add username to TODO comment in sanitizer to satisfy sanitizer lint check. NFCDouglas Yung2019-02-281-1/+1
| | | | llvm-svn: 355062
* [compiler-rt] Windows Trace Logging for error reports.Matthew G McGovern2019-02-272-2/+36
| | | | | | | | Adds option for collecting sanitixer dumps via trace logging. - Set log_to_syslog=1 to enable this output. - Consult https://aka.ms/windowstracelogging for details on use. llvm-svn: 355045
* [sanitizer] Fix compilation errors in r355030.Evgeniy Stepanov2019-02-272-2/+2
| | | | | | | | Disable hwasan interceptor on non-linux, non-x86-or-arm platforms. Add @plt to the asm call that clang intergrated-as infers but gcc does not. llvm-svn: 355041
* [NFC][Sanitizer] Pull up GetStackTrace into sanitizer_commonJulian Lettner2019-02-271-0/+6
| | | | | | | | | | | | | | | | | | | | 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
* Fixup compilation/test failures after r354960 and r355013.James Y Knight2019-02-271-4/+6
| | | | llvm-svn: 355034
* [hwasan, asan] Intercept vfork.Evgeniy Stepanov2019-02-276-1/+182
| | | | | | | | | | | | | | | Summary: Intercept vfork on arm, aarch64, i386 and x86_64. Reviewers: pcc, vitalybuka Subscribers: kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58533 llvm-svn: 355030
* [NFC][Sanitizer] Hard-code fast/slow unwinder at call siteJulian Lettner2019-02-272-2/+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
* Attempt to fix buildbot after r354972 [#1]. NFCI.Alexey Lapshin2019-02-271-2/+6
| | | | llvm-svn: 355013
* [NFC][Sanitizer] Add TODO commentsJulian Lettner2019-02-272-4/+2
| | | | llvm-svn: 354947
* Revert "[compiler-rt] Intercept the bcmp() function."Vlad Tsyrklevich2019-02-262-31/+7
| | | | | | | This reverts commits r354851, 354852, 354853 and r354888. They were causing build failures on the android sanitizer bot. llvm-svn: 354906
* [Sanitizer] Add interceptor for pthread_sigmaskPavel Labath2019-02-262-0/+21
| | | | | | | | | | | | | | | | | | | | | | 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] Intercept the bcmp() function.Clement Courbet2019-02-262-7/+31
| | | | | | | | | | | | | | | | | | | | | Summary: I have not introduced a separate hook for `bcmp()` as I don't think there should be any reason for a sanitizer to treat it differently from `memcmp()`. This is only enabled when building on POSIX with GNU extensions. Context: this is to avoid losing coverage when emitting `bcmp() == 0` instead of `memcmp() == 0` in llvm, see https://reviews.llvm.org/D56593. Reviewers: mgorny, krytarowski, vitalybuka, dvyukov Subscribers: kubamracek, dberris, delcypher, jdoerfert, #sanitizers, llvm-commits, jyknight Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D58379 llvm-svn: 354851
* Remove overly broad assert from r354717.Richard Trieu2019-02-231-2/+0
| | | | llvm-svn: 354720
* [NFC][Sanitizer] Comment out argument checksJulian Lettner2019-02-232-4/+4
| | | | | | These break clang-ppc64 bots. llvm-svn: 354718
* [NFC][Sanitizer] Add argument checks to BufferedStackTrace::Unwind* functionsJulian Lettner2019-02-236-10/+17
| | | | | | | | Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58555 llvm-svn: 354717
* [NFC][Sanitizer] Rename BufferedStackTrace::FastUnwindStackJulian Lettner2019-02-228-22/+21
| | | | | | | | | | | | | | | | FastUnwindStack -> UnwindFast SlowUnwindStack -> UnwindSlow Stack is redundant, verb should come first. SlowUnwindStackWithContext(uptr pc, void *context, u32 max_depth) -> SlowUnwindStack WithContext is redundant, since it is a required parameter. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58551 llvm-svn: 354696
* [Sanitizer] Fix uses of stack->Unwind(..., fast)Julian Lettner2019-02-221-1/+1
| | | | | | | | | | | Apply StackTrace::WillUseFastUnwind(fast) in a few more places missed by my previous patch (https://reviews.llvm.org/D58156). Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58550 llvm-svn: 354695
* [sanitizer] Common macro for .note.GNU-stack directives (NFC)Evgeniy Stepanov2019-02-213-6/+13
| | | | llvm-svn: 354632
* Revert "[asan] Fix vfork handling.", +1Evgeniy Stepanov2019-02-212-44/+0
| | | | | | Revert r354625, r354627 - multiple build failures. llvm-svn: 354629
* [hwasan,asan] Intercept vfork.Evgeniy Stepanov2019-02-212-0/+44
| | | | | | | | | | | | | | Summary: AArch64 only for now. Reviewers: vitalybuka, pcc Subscribers: srhines, kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, jdoerfert, #sanitizers, llvm-commits, kcc Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58313 llvm-svn: 354625
* Revert "[sanitizers] Restore internal_readlink for x32"Matt Morehouse2019-02-212-6/+1
| | | | | | This reverts r354451 since it broke the Windows sanitizer bot. llvm-svn: 354601
* [sanitizers] Restore internal_readlink for x32H.J. Lu2019-02-202-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | r316591 has @@ -389,13 +383,11 @@ uptr internal_dup2(int oldfd, int newfd) { } uptr internal_readlink(const char *path, char *buf, uptr bufsize) { -#if SANITIZER_NETBSD - return internal_syscall_ptr(SYSCALL(readlink), path, buf, bufsize); -#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS +#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS return internal_syscall(SYSCALL(readlinkat), AT_FDCWD, (uptr)path, (uptr)buf, bufsize); #else - return internal_syscall(SYSCALL(readlink), (uptr)path, (uptr)buf, bufsize); + return internal_syscall_ptr(SYSCALL(readlink), path, buf, bufsize); #endif } which dropped the (uptr) cast and broke x32. This patch puts back the (uptr) cast to restore x32 and fixes: https://bugs.llvm.org/show_bug.cgi?id=40783 Differential Revision: https://reviews.llvm.org/D58413 llvm-svn: 354451
* [sanitizers] add a regression test for the bug fixed in r354366Kostya Serebryany2019-02-191-0/+6
| | | | llvm-svn: 354373
* [sanitizer] fix a memory safety bug (!!!) in sanitizer suppressions code, ↵Kostya Serebryany2019-02-191-1/+1
| | | | | | discovered by Aaron Jacobs llvm-svn: 354366
* [Sanitizer] On Darwin `__sanitizer_print_stack_trace` only prints topmost frameJulian Lettner2019-02-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In compiler-rt we have the notion of a `fast` and a `slow` stack unwinder. Darwin currently only supports the fast unwinder. From reading the code, my understanding is that `BufferedStackTrace::Unwind` can be called with `bp=0, stack_top=0, stack_bottom=0, request_fast_unwind=false`. If `request_fast_unwind=true`, then we alos need to supply bp, stack_top, and stack_bottom. However, `BufferedStackTrace::Unwind` uses `StackTrace::WillUseFastUnwind` which will adapt `request_fast_unwind` if the requested unwinder is not supported. On Darwin, the result is that we don't pass actual values for bp, stack_top, and stack_bottom, but end up using the fast unwinder. The tests then fail because we only print the topmost stack frame. This patch adds a check to `WillUseFastUnwind` at the point of usage to avoid the mismatch between `request_fast_unwind` and what `Unwind` actually does. I am also interested in cleaning up the `request_fast_unwind` machinery so this patch just the simplest thing possible so I can enable the tests. Reviewers: vitalybuka, vsk Differential Revision: https://reviews.llvm.org/D58156 llvm-svn: 354282
* Fix invalid code that Clang trunk will soon diagnose.Richard Smith2019-02-151-1/+1
| | | | | | | | | | | | | There is an ambiguity between ::SizeClassMap (the typedef declared near the start of this file) and __sanitizer::SizeClassMap (found by the 'using namespace __sanitizer;' near the start of this file). Historically a Clang bug has meant that the error was not diagnosed, but soon Clang will start diagnosing it. Explicitly qualify this use of SizeClassMap so that it finds __sanitizer::SizeClassMap rather than being ill-formed due to ambiguity. llvm-svn: 354174
* Runtime flags for malloc bisection.Evgeniy Stepanov2019-02-153-17/+48
| | | | | | | | | | | | Reviewers: kcc, pcc Subscribers: kubamracek, mgorny, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58162 llvm-svn: 354156
* Dmitry Vyukov2019-02-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | tsan: add fiber support This patch adds functions for managing fibers: __tsan_get_current_fiber() __tsan_create_fiber() __tsan_destroy_fiber() __tsan_switch_to_fiber() __tsan_set_fiber_name() See the added tests for use examples. Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D54889 [The previous commit of this change was reverted, this is a resubmit with a squashed fix for check_analyze.sh and COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED] llvm-svn: 353947
* Revert "tsan: add fiber support"Diana Picus2019-02-131-1/+0
| | | | | | | This reverts commit r353817 because we think it broke AARch64 and PowerPC buildbots. llvm-svn: 353939
* tsan: add fiber supportDmitry Vyukov2019-02-121-0/+1
| | | | | | | | | | | | | | | | | This patch adds functions for managing fibers: __tsan_get_current_fiber() __tsan_create_fiber() __tsan_destroy_fiber() __tsan_switch_to_fiber() __tsan_set_fiber_name() See the added tests for use examples. Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D54889 llvm-svn: 353817
* [sanitizer] Don't compile GetPathAssumingFileIsRelativeToExec on FuchsiaPetr Hosek2019-02-121-9/+20
| | | | | | | | This avoids the unused function warning during compilation. Differential Revision: https://reviews.llvm.org/D58082 llvm-svn: 353787
* sanitizers: Introduce ThreadType enumDmitry Vyukov2019-02-073-15/+21
| | | | | | | | | | | | | Replace bool workerthread flag with ThreadType enum. This change is preparation for fiber support. [dvyukov: fixed build of sanitizer_thread_registry_test.cc] Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D57839 Context: https://reviews.llvm.org/D54889 llvm-svn: 353390
* [sanitizer] Remove unneeded pointer checkVitaly Buka2019-02-071-16/+16
| | | | | | | | | | | | | | Summary: unpoison_passwd and unpoison_group support nullptrs Reviewers: eugenis Subscribers: kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D57784 llvm-svn: 353365
* [sanitizer] Don't unpoison buffer in getpw/getgr functionsVitaly Buka2019-02-071-52/+36
| | | | | | | | | | | | | | | | | Summary: Buffer should be referenced by results so used parts will be unpoisoned with unpoison_group and unpoison_passwd. This fixes TSAN performance issue made us to disable this interceptors. Reviewers: eugenis, dvyukov Subscribers: srhines, kubamracek, krytarowski, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D57731 llvm-svn: 353351
* [sanitizer] Fix fuchsia and windows build.Evgeniy Stepanov2019-02-062-4/+7
| | | | llvm-svn: 353261
* [sanitizer] Decorate /proc/self/maps better.Evgeniy Stepanov2019-02-067-86/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Refactor the way /proc/self/maps entries are annotated to support most (all?) posix platforms, with a special implementation for Android. Extend the set of decorated Mmap* calls. Replace shm_open with internal_open("/dev/shm/%s"). Shm_open is problematic because it calls libc open() which may be intercepted. Generic implementation has limits (max number of files under /dev/shm is 64K on my machine), which can be conceivably reached when sanitizing multiple programs at once. Android implemenation is essentially free, and enabled by default. The test in sanitizer_common is copied to hwasan and not reused directly because hwasan fails way too many common tests at the moment. Reviewers: pcc, vitalybuka Subscribers: srhines, kubamracek, jfb, llvm-commits, kcc Differential Revision: https://reviews.llvm.org/D57720 llvm-svn: 353255
* Update the ioctl(2) list in sanitizers with NetBSD 8.99.34Kamil Rytarowski2019-02-053-15/+3
| | | | llvm-svn: 353224
* [sanitizer] Fix unused function 'unpoison_passwd'Vitaly Buka2019-02-051-12/+4
| | | | llvm-svn: 353205
* [ubsan] Make suppressions.cpp test pass for me on WindowsReid Kleckner2019-02-011-1/+7
| | | | | | | | | | | The test seems to be failing because the module suppression file contains a colon. I found that it was sufficient to just use the basename of the suppression file. While I was here, I noticed that we don't implement IsAbsolutePath for Windows, so I added it. llvm-svn: 352921
* [compiler-rt] Fix reporting unrecognized flags in unit tests.Igor Kudrin2019-01-291-0/+3
| | | | | | | | Previously, the warning messages might be issued within a wrong test case. Differential Revision: https://reviews.llvm.org/D57318 llvm-svn: 352447
* Make more allocator methods work correctly with in an out-of-process mode.Dan Liew2019-01-272-13/+18
| | | | | | | | | | | | | | | | | | | | | | Summary: This makes `GetBlockBegin()` and `GetBlockBeginFastLocked()` work correctly with `RemoteAddressSpaceView`. This has a knock on effect of also making the `PointerIsMine()` and `GetMetaData()` methods behave correctly when `RemoteAddressSpaceView` is used to instantiate the allocators. This will be used by future out-of-process allocator enumeration patches. rdar://problem/45284065 Reviewers: kcc, vitalybuka, dvyukov, cryptoad, eugenis, george.karpenkov, yln Subscribers: #sanitizers, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D56964 llvm-svn: 352335
* Revert https://reviews.llvm.org/D56485.Martin Liska2019-01-241-0/+6
| | | | llvm-svn: 352033
* Always compare C++ typeinfo (based on libstdc++ implementation).Martin Liska2019-01-241-6/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D56485. llvm-svn: 352032
* [libFuzzer][MSVC] Make Sanitizer Coverage MSVC-compatibleJonathan Metzman2019-01-211-20/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Make Sanitizer Coverage work when compiled work when compiler-rt is compiled with MSVC. The previous solution did not work for MSVC because MSVC tried to align the .SCOV$CZ section even though we used __declspec(align(1)) on its only symbol: __stop___sancov_cntrs. Because the counter array is composed of 1 byte elements, it does not always end on an 8 or 4 byte boundary. This means that padding was sometimes added to added to align the next section, .SCOV$CZ. Use a different strategy now: instead of only instructing the compiler not to align the symbol, make the section one byte long by making its only symbol a uint8_t, so that the linker won't try to align it. Reviewers: morehouse, rnk Reviewed By: rnk Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D56866 llvm-svn: 351714
* On Darwin add allocator address and size fields toDan Liew2019-01-211-0/+25
| | | | | | | | | | | | | | `sanitizer_malloc_introspection_t` and initialize them to zero. We allow sanitizer implementations to perform different initialization by defining `COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT` to be `1` and providing an implementation of `mi_extra_init(...)`. We use these changes in future patches to implement malloc zone enumeration. rdar://problem/45284065 llvm-svn: 351712
* On Darwin allow for sanitizer malloc implementations to provide a zoneDan Liew2019-01-211-4/+19
| | | | | | | | | | | | | | | | enumerator. This is done by defining `COMMON_MALLOC_HAS_ZONE_ENUMERATOR` to `1` and then by providing an implementation of the `mi_enumerator(...)` function. If a custom implementation isn't desired the macro is set to `0` which causes a stub version (that fails) to be used. Currently all Darwin sanitizers that have malloc implementations define this to be `0` so there is no functionality change. rdar://problem/45284065 llvm-svn: 351711
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-192-4/+6
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. 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: 351648
OpenPOWER on IntegriCloud