summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
Commit message (Collapse)AuthorAgeFilesLines
...
* [sanitizer] Fix Fuchsia ReadBinaryName not to crash when uninitializedPetr Hosek2018-05-021-2/+4
| | | | | | | | | | | | | If the sanitizer runtime is loaded in a binary that doesn't really support it, then __sanitizer_startup_hook will never have been called to initialize StoredArgv. This case can't be supported, but its failure mode shouldn't be to crash in sanitizer_common internals. Patch By: mcgrathr Differential Revision: https://reviews.llvm.org/D46344 llvm-svn: 331382
* [libFuzzer] Report at most one crash per input.Matt Morehouse2018-05-013-0/+14
| | | | | | | | | | | | | | | | | | Summary: Fixes https://github.com/google/sanitizers/issues/788/, a deadlock caused by multiple crashes happening at the same time. Before printing a crash report, we now test and set an atomic flag. If the flag was already set, the crash handler returns immediately. Reviewers: kcc Reviewed By: kcc Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D46277 llvm-svn: 331310
* [mips] Implement GetWriteFlag() for mipsPetar Jovanovic2018-04-251-0/+49
| | | | | | | | | | | | | The read/write flag is set by manually decoding the instruction that caused the exception. It is implemented this way because the cause register which contains the needed flag was removed from the signal context structure which the user handler receives from the kernel. Patch by Milos Stojanovic. Differential Revision: https://reviews.llvm.org/D45768 llvm-svn: 330840
* [sanitizer] More dead code removalKostya Kortchinsky2018-04-243-49/+0
| | | | | | | | | | | | | | | | | | Summary: The following functions are only used in tests: `SetEnv`, `SanitizerSetThreadName`, `SanitizerGetThreadName`. I don't think they are going to be used in the future, and I propose to get rid of them, and associated tests and include. Reviewers: alekseyshl, eugenis, vitalybuka Reviewed By: vitalybuka Subscribers: dvyukov, vitalybuka, kubamracek, delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D45838 llvm-svn: 330724
* The OpenBSD UBsan port introduced two typos that broke the Solaris sanitizer ↵Rainer Orth2018-04-241-1/+1
| | | | | | | | | | build. The following patch restores it, will shortly commit as obvious. Differential Revision: https://reviews.llvm.org/D46006 llvm-svn: 330712
* [Sanitizer] Internal Printf string width + left-justify.Alex Shlyapnikov2018-04-232-11/+35
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Example: Printf("%-5s", "123"); should yield: '123 ' In case Printf's requested string field width is larger than the string argument length, the resulting string should be padded up to the requested width. For the simplicity sake, implementing left-justified (right padding) only. Reviewers: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45906 llvm-svn: 330643
* Fix clang-cl warnings in compiler-rtReid Kleckner2018-04-232-3/+3
| | | | | | | | | The profile library was missing some includes and was erroneously using ftruncate. WinASan was using `= {0}` to initialize structs, which creates -Wmissing-field-initializers and -Wmissing-braces warnings with clang. Use `= {}` instead, since this is C++. llvm-svn: 330616
* Revert "[Sanitizer] Internal Printf string precision argument + padding."Alex Shlyapnikov2018-04-202-9/+2
| | | | | | | | | This reverts commit r330458. There are existing code using string precision as 'max len', need more work. llvm-svn: 330476
* [Sanitizer] Internal Printf string precision argument + padding.Alex Shlyapnikov2018-04-202-2/+9
| | | | | | | | | | | | | | | | | | | | | | Summary: Example: Printf("%.*s", 5, "123"); should yield: '123 ' In case Printf's requested string precision is larger than the string argument, the resulting string should be padded up to the requested precision. For the simplicity sake, implementing right padding only. Reviewers: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45844 llvm-svn: 330458
* Revert r330376 "[sanitizer] Generalize atomic_uint8_t, atomic_uint16_t, ... ↵Hans Wennborg2018-04-201-10/+28
| | | | | | | | | | into a template. NFC." This broke the Windows build, see e.g. http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10130 > Differential Revision: https://reviews.llvm.org/D44246 llvm-svn: 330395
* [sanitizer] Generalize atomic_uint8_t, atomic_uint16_t, ... into a template. ↵Kuba Mracek2018-04-191-28/+10
| | | | | | | | NFC. Differential Revision: https://reviews.llvm.org/D44246 llvm-svn: 330376
* [sanitizer] Minor refactor of some ReservedAddressRange functionsKostya Kortchinsky2018-04-193-37/+20
| | | | | | | | | | | | | | | | | | | Summary: Some of the functions had spurious conditional statements and checks, and some intermediary variables that I feel made the code more complicated than it needs to be. Also, when unmapping the whole range, the range size would be 0, but the base was set to the address of the end of the range, which sounds prone to error. I think nulling out the base in this scenario is a better way to go. Reviewers: alekseyshl, flowerhack Reviewed By: alekseyshl Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45775 llvm-svn: 330355
* [sanitizer] Minor refactor of ThreadDescriptorSizeKostya Kortchinsky2018-04-181-14/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: While I was sifting through dead code findings, I stumbled on this function. First, for `__s390__` it always returned 0 for the 1st call, which doesn't seem right. 2nd call & beyond would return the correct value though. Then it duplicated the `atomic_store` multiple times, sometimes with a `if`, sometimes without. Finally it used a capitalized variable name starting with `k` which indicates a constant, and it is not. So: - rename the static global variable; - change the atomic functions to their relaxed version; - move the store to the end, and make sure we return `val` all the time. Reviewers: alekseyshl, eugenis, koriakin Reviewed By: alekseyshl Subscribers: kubamracek, delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D45725 llvm-svn: 330268
* [sanitizer] Remove low-hanging-fruit dead codeKostya Kortchinsky2018-04-175-48/+0
| | | | | | | | | | | | | | | | | Summary: Going through the dead code findings, the code removed in this CL appears to be pretty straightforward to remove, and seems to be some leftover from previous refactors. Reviewers: alekseyshl, eugenis Reviewed By: alekseyshl Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45704 llvm-svn: 330190
* [sanitizer] Fix OSX build failure post D45457Kostya Kortchinsky2018-04-161-0/+6
| | | | | | | | | | | | Summary: It looks like OSX's UBSan needs a "NoHooks" version of `RTSanitizerCommonSymbolizer` to work build properly. Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D45696 llvm-svn: 330146
* [sanitizer] Split Symbolizer/StackTraces from core RTSanitizerCommonKostya Kortchinsky2018-04-1612-333/+363
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Host symbolizer & stacktraces related code in their own RT: `RTSanitizerCommonSymbolizer`, which is "libcdep" by nature. Symbolizer & stacktraces specific code that used to live in common files is moved to a new file `sanitizer_symbolizer_report.cc` as is. The purpose of this is the enforce a separation between code that relies on symbolization and code that doesn't. This saves the inclusion of spurious code due to the interface functions with default visibility, and the extra data associated. The following sanitizers makefiles were modified & tested locally: - dfsan: doesn't require the new symbolizer RT - esan: requires it - hwasan: requires it - lsan: requires it - msan: requires it - safestack: doesn't require it - xray: doesn't require it - tsan: requires it - ubsan: requires it - ubsan_minimal: doesn't require it - scudo: requires it (but not for Fuchsia that has a minimal runtime) This was tested locally on Linux, Android, Fuchsia. Reviewers: alekseyshl, eugenis, dberris, kubamracek, vitalybuka, dvyukov, mcgrathr Reviewed By: alekseyshl, vitalybuka Subscribers: srhines, kubamracek, mgorny, krytarowski, delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D45457 llvm-svn: 330131
* [sanitizer] Allow for the allocator "names" to be set by the toolsKostya Kortchinsky2018-04-135-8/+16
| | | | | | | | | | | | | | | | | | | Summary: In the same spirit of SanitizerToolName, allow the Primary & Secondary allocators to have names that can be set by the tools via PrimaryAllocatorName and SecondaryAllocatorName. Additionally, set a non-default name for Scudo. Reviewers: alekseyshl, vitalybuka Reviewed By: alekseyshl, vitalybuka Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45600 llvm-svn: 330055
* [sanitizer] Fix __sanitizer::Vector::Resize vectorVitaly Buka2018-04-132-0/+13
| | | | | | | | | | | | | | | | Implemented downsizing Patch by Oleg Doronin Reviewers: kcc, vitalybuka Reviewed By: kcc, vitalybuka Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45605 llvm-svn: 330049
* [sanitizer] Replace cast with unsigned literals in testsVitaly Buka2018-04-131-4/+4
| | | | llvm-svn: 330048
* [asan] Reduce flakiness in stack-overflow detectionKuba Mracek2018-04-131-1/+3
| | | | | | | | IsStackOverflow only treats accesses within 512 bytes of SP as stack-overflow. This should really be the size of a page instead. The scariness_score_test.cc triggers stack overflow with frames that are even larger than a page, which can also trigger a fault that will not be recognized as stack-overflow. Let's just use smaller frames. llvm-svn: 329980
* [sanitizer] Correct name length computation for some Fuchsia vmosKostya Kortchinsky2018-04-111-1/+1
| | | | | | | | | | | | | | | | | Summary: This was missed during the review of D38595, but the vmo name size computation should use internal_strlen, not sizeof, otherwise we end up with 7 character names. Reviewers: mcgrathr, flowerhack Reviewed By: mcgrathr Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45525 llvm-svn: 329842
* [sanitizer] Allow BackgroundThread to not depend on StackDepot v2Kostya Kortchinsky2018-04-101-12/+18
| | | | | | | | | | | | | | | | | | | | Summary: This is a redo of D45296. It looks like the random stack-protector issues I was getting were coming from my Android emulator, and updating everything all around and relaunching stuff ended up making it go away. I guess I'll have to see how it behaves on the bots. Only additional change from the previous CL is some `const` were appropriate. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45461 llvm-svn: 329706
* [sanitizer] Enable threads for libc++ build used by the symbolizerPetr Hosek2018-04-102-2/+4
| | | | | | | | | Disabling threads makes <atomic> unusable, but this is needed by LLVM libraries that are dependencies of the symbolizer. Differential Revision: https://reviews.llvm.org/D45424 llvm-svn: 329672
* GetRandom / OpenBSD, using getentropy to get high quality randomnessVitaly Buka2018-04-091-1/+19
| | | | | | | | | | | | | | | | | | | Summary: - getentropy presence since late 2014, safe to use. - guarantees to delivers good random data up to 256 bytes. - fall back to /dev/urandom as long the buffer is correct. Patch by David CARLIER Reviewers: kubamracek, vitalybuka Reviewed By: vitalybuka Subscribers: cryptoad, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D44866 llvm-svn: 329633
* [sanitizer] Reverting rCRT329595Kostya Kortchinsky2018-04-091-14/+10
| | | | | | | | | | | | Summary: Even this version seems to mess with Android somehow. Reverting for now while I figure out what's up. Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45450 llvm-svn: 329606
* [sanitizer] Allow BackgroundThread to not depend on StackDepotKostya Kortchinsky2018-04-091-10/+14
| | | | | | | | | | | | | | | | | | | | Summary: Still pursuing the ultimate goal of splitting the Symbolizer code from RTSanitizerCommon core, allow `BackgroundThread` to work even when not linked with `sanitizer_stackdepot.cc`. There is no reason this function should pull in the whole `StackDepot` if symbolization is not supported. Currently this has no functional change as the depot is always linked anyway. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: kubamracek, delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D45296 llvm-svn: 329595
* [sanitizer] Split stacktrace/symbolizer: Windows unwindKostya Kortchinsky2018-04-043-52/+77
| | | | | | | | | | | | | | | | | | | Summary: The purpose of this set of changes is to separate stackframe/symbolizer support into their own RT within sanitizer_common. Sanitizers with no use for those could then be built without the extraneous dependencies pulled in by the default visibility interface functions. I am aiming to do small changes for specific platforms. In this one, we split the unwind functions from sanitizer_win.cc into their own sanitizer_unwind_win.cc. Reviewers: alekseyshl, rnk Reviewed By: alekseyshl, rnk Subscribers: delcypher, #sanitizers, kubamracek, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D44799 llvm-svn: 329204
* [sanitizer] Remove empty Symbolizer PrepareForSandboxingKostya Kortchinsky2018-04-039-30/+10
| | | | | | | | | | | | | | | | | | | | | | | Summary: `Symbolizer::PrepareForSandboxing` is empty for all platforms and apparently has been for a while (D10213). Remove it, and shuffle things around so that the platform specific code is now in `PlatformPrepareForSandboxing`. This allows to have one less symbolizer dependency in a common file, which helps for the upcoming split. Also remove `SymbolizerPrepareForSandboxing` in tsan_go which appears to not be used anywhere. Reviewers: alekseyshl, eugenis, dvyukov, mcgrathr Reviewed By: alekseyshl Subscribers: kubamracek, delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D44953 llvm-svn: 329094
* [ASan] Report proper ASan error on allocator failures instead of CHECK(0)-ingAlex Shlyapnikov2018-03-282-0/+13
| | | | | | | | | | | | | | | | | | Summary: Currently many allocator specific errors (OOM, for example) are reported as a text message and CHECK(0) termination, not stack, no details, not too helpful nor informative. To improve the situation, ASan detailed errors were defined and reported under the appropriate conditions. Issue: https://github.com/google/sanitizers/issues/887 Reviewers: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D44404 llvm-svn: 328722
* [sanitizer] Fix Darwin buildVitaly Buka2018-03-242-3/+7
| | | | llvm-svn: 328417
* Mmap interceptor providing mprotect supportVitaly Buka2018-03-246-31/+53
| | | | | | | | | | | | | | | | Summary: - Intercepting mprotect calls. - Fixing forgotten flag check. Patch by David CARLIER Reviewers: vitalybuka, vsk Subscribers: delcypher, srhines, kubamracek, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D44777 llvm-svn: 328415
* [sanitizer] Fix strlcpy and strlcat interceptors on DarwinVitaly Buka2018-03-241-3/+3
| | | | llvm-svn: 328414
* FreeBSD sanitizer common, intercept couple of more functionsVitaly Buka2018-03-231-10/+10
| | | | | | | | | | | | | | | Summary: Intercepts lstat, acct, access, faccessat and strlcpy/strlcat Patch by David CARLIER Reviewers: visa, vitalybuka Subscribers: krytarowski, fedor.sergeev, srhines, kubamracek, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D44432 llvm-svn: 328376
* Revert "Mmap interceptor providing mprotect support"Vitaly Buka2018-03-233-22/+6
| | | | | | | | Breaks Darwin. This reverts commit r328369. llvm-svn: 328375
* Mmap interceptor providing mprotect supportVitaly Buka2018-03-233-6/+22
| | | | | | | | | | | | | | | | | | Summary: - Intercepting mprotect calls. - Fixing forgotten flag check. Patch by David CARLIER Reviewers: vitalybuka, vsk Reviewed By: vitalybuka Subscribers: srhines, kubamracek, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D44777 llvm-svn: 328369
* [sanitizer] Fix PPC botVitaly Buka2018-03-231-3/+3
| | | | llvm-svn: 328279
* [sanitizer] zx_vmo_write on Fuchsia takes only 4 arguments nowPetr Hosek2018-03-221-10/+1
| | | | | | | | | The system call now fails when it cannot write the requested size. Update the sanitizer runtime Fuchsia implementation accordingly. Differential Revision: https://reviews.llvm.org/D44770 llvm-svn: 328273
* More OpenBSD fixesVitaly Buka2018-03-221-8/+26
| | | | | | | | | | | | | | | | | | Summary: - Use internal_syscall_ptr in internal_readlink - use sigcontext on OpenBSD Patch by David CARLIER Reviewers: krytarowski, vitalybuka Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D44713 llvm-svn: 328239
* [sanitizer] Split coverage into separate RT in sanitizer_commonKostya Kortchinsky2018-03-221-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: `sanitizer_common`'s coverage support is fairly well separated, and libcdep by default. Several sanitizers don't make use of coverage, and as far as I can tell do no benefit from the extra dependencies pulled in by the coverage public interface functions. The following sanitizers call `InitializeCoverage` explicitely: MSan, ASan, LSan, HWAsan, UBSan. On top of this, any sanitizer bundling RTUBSan should add the coverage RT as well: ASan, Scudo, UBSan, CFI (diag), TSan, MSan, HWAsan. So in the end the following have no need: DFSan, ESan, CFI, SafeStack (nolibc anyway), XRay, and the upcoming Scudo minimal runtime. I tested this with all the sanitizers check-* with gcc & clang, and in standalone on Linux & Android, and there was no issue. I couldn't test this on Mac, Fuchsia, BSDs, & Windows for lack of an environment, so adding a bunch of people for additional scrunity. I couldn't test HWAsan either. Reviewers: eugenis, vitalybuka, alekseyshl, flowerhack, kubamracek, dberris, rnk, krytarowski Reviewed By: vitalybuka, alekseyshl, flowerhack, dberris Subscribers: mgorny, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D44701 llvm-svn: 328204
* Mmap interceptor new option, Write Exec runtime detectorVitaly Buka2018-03-214-0/+35
| | | | | | | | | | | | | | | | | | Summary: Following-up the refactoring of mmap interceptors, adding a new common option to detect PROT_WRITE|PROT_EXEC pages request. Patch by David CARLIER Reviewers: vitalybuka, vsk Reviewed By: vitalybuka Subscribers: krytarowski, #sanitizers Differential Revision: https://reviews.llvm.org/D44194 llvm-svn: 328151
* tsan: support inlined frames in external symbolizationDmitry Vyukov2018-03-211-1/+1
| | | | | | | | | | | | New API passes a callback function to the external symbolizer, allowing it to add multiple frames to the traceback. Note that the old interface API will be still supported until the clients migrate to the new one. Author: asmundak (Alexander Smundak) Reviewed in: https://reviews.llvm.org/D44714 llvm-svn: 328079
* Fix declaration of environ after r327923Vitaly Buka2018-03-211-4/+2
| | | | llvm-svn: 328077
* Revert "[compiler-rt] Change std::sort to llvm::sort in response to r327219"Mandeep Singh Grang2018-03-202-3/+3
| | | | | | This reverts commit 2ee210e1963e03aacc0f71c50e4994bb5c66586e. llvm-svn: 327936
* [compiler-rt] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-03-202-3/+3
| | | | | | | | | | | | | | | | | | | Summary: r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. Reviewers: kcc, rsmith, RKSimon, eugenis Reviewed By: RKSimon Subscribers: efriedma, kubamracek, dberris, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D44360 llvm-svn: 327929
* OpenBSD UBsan support missing bitsVitaly Buka2018-03-192-67/+99
| | | | | | | | | | | | | | | | | Summary: Lost bits since the WIP ticket Patch by David CARLIER Reviewers: vitalybuka, vsk Reviewed By: vitalybuka Subscribers: srhines, kubamracek, krytarowski, fedor.sergeev, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D44599 llvm-svn: 327923
* Cleanup of "extern char **environ" declarationVitaly Buka2018-03-191-5/+5
| | | | llvm-svn: 327904
* Revert "Mmap interceptor new option, Write Exec runtime detector"Vitaly Buka2018-03-174-35/+0
| | | | | | | | Breaks Android bot. This reverts commit r327747. llvm-svn: 327762
* OpenBSD UBsan support final missing bitsVitaly Buka2018-03-162-5/+7
| | | | | | | | | | | | | | | Summary: One forgotten file change + reordering one header due to clang-format Patch by David CARLIER Reviewers: vitalybuka, vsk Subscribers: kubamracek, fedor.sergeev, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D44556 llvm-svn: 327758
* Mmap interceptor new option, Write Exec runtime detectorVitaly Buka2018-03-164-0/+35
| | | | | | | | | | | | | | | | Summary: Following-up the refactoring of mmap interceptors, adding a new common option to detect PROT_WRITE|PROT_EXEC pages request. Patch by David CARLIER Reviewers: vitalybuka, vsk Reviewed By: vitalybuka Subscribers: krytarowski, #sanitizers Differential Revision: https://reviews.llvm.org/D44194 llvm-svn: 327747
* Revert "Mmap interceptor new option, Write Exec runtime detector"Jonas Devlieghere2018-03-164-35/+0
| | | | | | | | | This reverts r327696 because it is failing on GreenDragon. http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/43605/ http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/10957/ llvm-svn: 327719
OpenPOWER on IntegriCloud