summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
Commit message (Collapse)AuthorAgeFilesLines
...
* [compiler-rt] Rename FuzzedDataProvider.h to .hpp and other minor changes.Max Moroz2019-08-061-1/+1
| | | | | | | | | | | | | | | | | | Summary: .hpp makes more sense for this header as it's C++ only, plus it contains the actual implementation. Reviewers: Dor1s Reviewed By: Dor1s Subscribers: kubamracek, dberris, mgorny, delcypher, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D65812 llvm-svn: 368054
* [compiler-rt] Implement getrandom interceptionVitaly Buka2019-08-063-0/+30
| | | | | | | | | | | | | | | | | | | | | | | Summary: Straightforward implementation of `getrandom` syscall and libc hooks. Test Plan: Local MSAN failures caused by uninstrumented `getrandom` calls stop failing. Patch by Andrew Krieger. Reviewers: eugenis, vitalybuka Reviewed By: vitalybuka Subscribers: srhines, kubamracek, dberris, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D65551 llvm-svn: 367999
* [Sanitizer] Linux refactor shadow huge page mode handlingDavid Carlier2019-08-053-4/+6
| | | | | | | | | | | | Disabling Transparent huge page mode refactored in one function. Reviewers: vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D65771 llvm-svn: 367925
* [compiler-rt] Move FDP to include/fuzzer/FuzzedDataProvider.h for easier use.Max Moroz2019-08-051-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: FuzzedDataProvider is a helper class for writing fuzz targets that fuzz multple inputs simultaneously. The header is supposed to be used for fuzzing engine agnostic fuzz targets (i.e. the same target can be used with libFuzzer, AFL, honggfuzz, and other engines). The common thing though is that fuzz targets are typically compiled with clang, as it provides all sanitizers as well as different coverage instrumentation modes. Therefore, making this FDP class a part of the compiler-rt installation package would make it easier to develop and distribute fuzz targets across different projects, build systems, etc. Some context also available in https://github.com/google/oss-fuzz/pull/2547. This CL does not delete the header from `lib/fuzzer/utils` directory in order to provide the downstream users some time for a smooth migration to the new header location. Reviewers: kcc, morehouse Reviewed By: morehouse Subscribers: lebedev.ri, kubamracek, dberris, mgorny, delcypher, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D65661 llvm-svn: 367917
* compiler-rt: Rename cc files below test/asan to cppNico Weber2019-08-051-2/+2
| | | | | | See r367803 and similar other changes. llvm-svn: 367887
* compiler-rt: Rename .cc file in test/lsan to .cppFangrui Song2019-08-051-1/+1
| | | | | | Like r367463, but for test/lsan. llvm-svn: 367803
* [sanitizer_common][tests] Fix SanitizerCommon-Unit :: ↵Rainer Orth2019-08-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ./Sanitizer-*-Test/SanitizerCommon.PthreadDestructorIterations on Solaris SanitizerCommon.PthreadDestructorIterations currently FAILs on Solaris: [ RUN ] SanitizerCommon.PthreadDestructorIterations /vol/llvm/src/compiler-rt/local/lib/sanitizer_common/tests/sanitizer_posix_test.cc:58: Failure Value of: destructor_executed Actual: true Expected: false [ FAILED ] SanitizerCommon.PthreadDestructorIterations (1 ms) It turns out that destructor is called 4 times after the first call to SpawnThread, but 5 times after the second. While PTHREAD_DESTRUCTOR_ITERATIONS is 4 in <limits.h>, the Solaris pthread_key_create(3C) man page documents If, after all the destructors have been called for all keys with non- null values, there are still some keys with non-null values, the process will be repeated. POSIX requires that this process be executed at least PTHREAD_DESTRUCTOR_ITERATIONS times. Solaris calls the destructors repeatedly until all values with associated destructors are NULL. Destructors that set new values can cause an infinite loop. The patch adjusts the test case to allow for this. Tested on x86_64-pc-solaris2.11. Differential Revision: https://reviews.llvm.org/D65055 llvm-svn: 367705
* compiler-rt: Rename .cc file in test/tsan to .cppFangrui Song2019-08-021-1/+1
| | | | | | Like r367463, but for test/tsan. llvm-svn: 367656
* Remove a few straggler ".cc"s in compiler-rt/libNico Weber2019-08-013-3/+3
| | | | llvm-svn: 367589
* compiler-rt: Rename .cc file in lib/tsan/tests/{rtl,unit} to .cppNico Weber2019-08-011-2/+2
| | | | | | Like r367463, but for tsan/tests/{rtl,unit}. llvm-svn: 367566
* compiler-rt: Rename .cc file in lib/tsan/rtl to .cppNico Weber2019-08-011-1/+1
| | | | | | Like r367463, but for tsan/rtl. llvm-svn: 367564
* compiler-rt: Rename .cc file in lib/msan to .cppNico Weber2019-08-011-1/+1
| | | | | | Like r367463, but for msan. llvm-svn: 367562
* compiler-rt: Rename .cc file in lib/lsan to .cppNico Weber2019-08-011-1/+1
| | | | | | Like r367463, but for lsan. llvm-svn: 367561
* compiler-rt: Rename .cc file in lib/asan/tests to .cppNico Weber2019-08-011-1/+1
| | | | | | Like r367463, but for asan/tests llvm-svn: 367559
* compiler-rt: Rename .cc file in lib/asan to .cppNico Weber2019-08-011-1/+1
| | | | | | Like r367463, but for asan. llvm-svn: 367558
* Try to heal bots after r367551Nico Weber2019-08-011-1/+1
| | | | llvm-svn: 367552
* compiler-rt: Try to appease lint script.Nico Weber2019-07-312-9/+7
| | | | | | | | | | | | | A bot complains: /b/sanitizer-x86_64-linux-autoconf/build/llvm/projects/compiler-rt/lib/sanitizer_common/tests/malloc_stress_transfer_test.cpp:2: Streams are highly discouraged. [readability/streams] [3] /b/sanitizer-x86_64-linux-autoconf/build/llvm/projects/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cpp:11: Streams are highly discouraged. [readability/streams] [3] lib/CMakeFiles/SanitizerLintCheck.dir/build.make:57: recipe for target 'lib/CMakeFiles/SanitizerLintCheck' failed I do not know why this apparently wasn't a problem when the files had extension .cc. llvm-svn: 367493
* Attempt to heal bots after r367467Nico Weber2019-07-311-1/+1
| | | | llvm-svn: 367473
* compiler-rt: Rename .cc file in lib/sanitizer_common/symbolizer to .cppNico Weber2019-07-313-3/+3
| | | | llvm-svn: 367471
* compiler-rt: Rename .cc file in lib/sanitizer_common/tests to .cppNico Weber2019-07-3135-68/+71
| | | | | | | | | | | See https://reviews.llvm.org/D58620 for discussion, and for the commands I ran. In addition I also ran for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $(basename $f) . ; done and manually updated references to renamed files found by that. llvm-svn: 367467
* compiler-rt: Rename .cc file in lib/sanitizer_common to .cppNico Weber2019-07-3180-160/+163
| | | | | | | | | | | See https://reviews.llvm.org/D58620 for discussion, and for the commands I ran. In addition I also ran for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $f . ; done and manually updated (many) references to renamed files found by that. llvm-svn: 367463
* Attempt to heal bots after r367456Nico Weber2019-07-311-1/+1
| | | | llvm-svn: 367462
* [Sanitizer][ASAN][MSAN] Fix infinite recursion on FreeBSDAlexander Richardson2019-07-311-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Don't initialize interceptor_metadata_map unless SI_POSIX is setEugene Leviant2019-07-281-1/+3
| | | | | | Differential revision: https://reviews.llvm.org/D64794 llvm-svn: 367188
* [sanitizer_common] Allow customization of StartSymbolizerSubprocessJulian Lettner2019-07-252-7/+13
| | | | | | | | | | | | | | Summary: Make SymbolizerProcess::StartSymbolizerSubprocess virtual and protected to allow subclasses to customize it via "override and call". Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D65252 llvm-svn: 366967
* [ASan] Support `{f}puts(NULL)` on Darwin, part 2Julian Lettner2019-07-181-2/+4
| | | | | | | Add braces around macro `{ MACRO(); }` to guard against macros that expand to multiple statements. llvm-svn: 366488
* [ASan] Support `{f}puts(NULL)` on DarwinJulian Lettner2019-07-171-2/+4
| | | | | | | | | | | | | On Darwin, the man page states that "both fputs() and puts() print `(null)' if str is NULL." rdar://48227136 Reviewed By: Lekensteyn Differential Revision: https://reviews.llvm.org/D64773 llvm-svn: 366342
* [Sanitizers] Fix SanitizerCommon-Unit :: ↵Rainer Orth2019-07-121-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | ./Sanitizer-*-Test/MemoryMappingLayout.DumpListOfModules on Solaris The MemoryMappingLayout.DumpListOfModules currently FAILs on Solaris: [ RUN ] MemoryMappingLayout.DumpListOfModules /vol/llvm/src/compiler-rt/local/lib/sanitizer_common/tests/sanitizer_procmaps_test.cc:52: Failure Value of: found Actual: false Expected: true [ FAILED ] MemoryMappingLayout.DumpListOfModules (22 ms) The problem is that the test expects the executable name from modules[i].full_name(), however the pr_mapname field of struct prmap is just the entry in /proc/<pid>/object, which is "a.out" instead of "Sanitizer-i386-Test". Fortunately, the real name can be determined by looking in proc/<pid>/path where "a.out" is a symlink to the real path. Tested on x86_64-pc-solaris2.11. Differential Revision: https://reviews.llvm.org/D64559 llvm-svn: 365879
* Add NetBSD LSan supportKamil Rytarowski2019-07-115-9/+377
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Combine few relatively small changes into one: - implement internal_ptrace() and internal_clone() for NetBSD - add support for stoptheworld based on the ptrace(2) API - define COMPILER_RT_HAS_LSAN for NetBSD - enable tests for NetBSD/amd64 Inspired by the original implementation by Christos Zoulas in netbsd/src for GCC. The implementation is in theory CPU independent through well defined macros across all NetBSD ports, however only the x86_64 version was tested. Reviewers: mgorny, dvyukov, vitalybuka, joerg, jfb Reviewed By: vitalybuka Subscribers: dexonsmith, jfb, srhines, kubamracek, llvm-commits, christos Tags: #llvm Differential Revision: https://reviews.llvm.org/D64057 llvm-svn: 365735
* [Sanitizers] Remove clang_rt.sancov_{begin,end} on SolarisRainer Orth2019-07-083-42/+0
| | | | | | | | | | | | | | | | There's no point to manually create the __start___sancov_guards and __stop___sancov_guards sections and labels on Solaris any longer. They were originally introduced in https://reviews.llvm.org/D40899 and https://reviews.llvm.org/D40903. - The Solaris 11.4 ld supports creating them out of the box. - We already unconditionally use Solaris 11.4 features like the ld -z gnu-version-script-compat option and fully working .preinit_array support in compiler-rt. - The current files don't assemble on SPARC because the assembler syntax may be different between /bin/as and GNU as. Tested on amd64-pc-solaris2.11. Differential Revision: https://reviews.llvm.org/D63601 llvm-svn: 365399
* [Sanitizers] Remove obsolete OpenFile from sanitizer_solaris.ccRainer Orth2019-07-021-5/+0
| | | | | | | | | | | I noticed that the instance of OpenFile in sanitizer_solaris.cc is no longer needed. Removed as follows, tested on x86_64-pc-solaris2.11. Differential Revision: https://reviews.llvm.org/D63764 llvm-svn: 364892
* hwasan: Teach the runtime to identify the local variable being accessed in ↵Peter Collingbourne2019-06-275-12/+119
| | | | | | | | | | | | | | UAR reports. Each function's PC is recorded in the ring buffer. From there we can access the function's local variables and reconstruct the tag of each one with the help of the information printed by llvm-symbolizer's new FRAME command. We can then find the variable that was likely being accessed by matching the pointer's tag against the reconstructed tag. Differential Revision: https://reviews.llvm.org/D63469 llvm-svn: 364607
* [sanitizer_common] Switch from zx_clock_get_new to zx_clock_getPetr Hosek2019-06-271-1/+1
| | | | | | | | | This is part of the soft-transition to the new system call name. These two system calls are the same so this change is no-op. Differential Revision: https://reviews.llvm.org/D63895 llvm-svn: 364593
* [ASan] Use dynamic shadow on 32-bit iOS and simulatorsJulian Lettner2019-06-211-17/+21
| | | | | | | | | | | | | | | | | | | | The VM layout on iOS is not stable between releases. On 64-bit iOS and its derivatives we use a dynamic shadow offset that enables ASan to search for a valid location for the shadow heap on process launch rather than hardcode it. This commit extends that approach for 32-bit iOS plus derivatives and their simulators. rdar://50645192 rdar://51200372 rdar://51767702 Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D63586 llvm-svn: 364105
* [asan] Avoid two compiler-synthesized calls to memset & memcpyReid Kleckner2019-06-211-0/+3
| | | | | | | | | | Otherwise the tests hang on Windows attempting to report nested errors. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D63627 llvm-svn: 364070
* [Sanitizers] Fix sanitizer_posix_libcdep.cc compilation on Solaris 11.5Rainer Orth2019-06-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A recent build of Solaris 11.5 Beta (st_047) gained madvise(MADV_DONTDUMP) support for Linux compatibility. This broke the compiler-rt build: /vol/llvm/src/llvm/dist/projects/compiler-rt/lib/sanitizer_comm/sanitizer_posix_libcdep.cc: In function ‘bool __sanitizer::DontDumpShadowMemory(__sanitizer::uptr, __sanitizer::uptr)’: /vol/llvm/src/llvm/dist/projects/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc:81:18: error: invalid conversion from ‘void*’ to ‘caddr_t’ {aka ‘char*’} [-fpermissive] 81 | return madvise((void *)addr, length, MADV_DONTDUMP) == 0; | ^~~~~~~~~~~~ | | | void* In file included from /vol/llvm/src/llvm/dist/projects/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc:32: /usr/include/sys/mman.h:231:20: note: initializing argument 1 of ‘int madvise(caddr_t, std::size_t, int)’ 231 | extern int madvise(caddr_t, size_t, int); | ^~~~~~~ The obvious fix is to use the same solution that has already been used a couple of lines earlier: // In the default Solaris compilation environment, madvise() is declared // to take a caddr_t arg; casting it to void * results in an invalid // conversion error, so use char * instead. This allowed the compiler-rt build to finish and was tested successfully on i386-pc-solaris2.11 and x86_64-pc-linux-gnu. Differential Revision: https://reviews.llvm.org/D62892 llvm-svn: 363778
* Don't crash if PR_SET_VMA_ANON_NAME fails.Evgeniy Stepanov2019-06-181-2/+1
| | | | | | | | This prctl is not implemented on very old devices. It is not necessary for the core functionality of the tool. Simply ignore the failure. llvm-svn: 363755
* [compiler-rt] Respect CMAKE_NMShoaib Meenai2019-06-151-3/+4
| | | | | | | | | | | The default nm executable may not be able to handle the architecture we're building the sanitizers for. Respect CMAKE_NM if it's set to ensure we're using the correct nm tool. Preserve the existing NM environment variable override to not break its users. Differential Revision: https://reviews.llvm.org/D63368 llvm-svn: 363483
* Improve error message when '=' is missing in {ASAN,...}_OPTIONS.Vitaly Buka2019-06-153-12/+26
| | | | | | | | | | | | | | | | | | 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
* [Sanitizers] Add case MACOS_VERSION_CATALINAJulian Lettner2019-06-112-2/+3
| | | | | | | | Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D63096 llvm-svn: 363104
* Add unused symbol to thunk files to force wholearchive inclusionReid Kleckner2019-06-102-0/+12
| | | | | | | | | | | | | | These "dynamic_runtime_thunk" object files exist to create a weak alias from 'foo' to 'foo_dll' for all weak sanitizer runtime symbols. The weak aliases are implemented as /alternatename linker options in the .drective section, so they are not actually in the symbol table. In order to force the Visual C++ linker to load the object, even with -wholearchive:, we have to provide at least one external symbol. Once we do that, it will read the .drective sections and see the weak aliases. Fixes PR42074 llvm-svn: 362970
* [Sanitizer] Add interceptor for wcsdupPavel Labath2019-05-222-0/+19
| | | | | | | | | | | | | | Summary: The wide-string equivalent of strdup. Implementation trivial. Reviewers: vitalybuka, eugenis Subscribers: kubamracek, delcypher, llvm-commits, #sanitizers Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D62189 llvm-svn: 361357
* [sanitizer] Update symbolizer/scripts/global_symbols.txtVitaly Buka2019-05-171-0/+1
| | | | llvm-svn: 361077
* [compiler-rt] Migrate to _zx_clock_get_new/_zx_clock_get_monotonicPetr Hosek2019-05-091-2/+7
| | | | | | | | This is part of the soft-transition to the new _zx_clock_get signature. Differential Revision: https://reviews.llvm.org/D61768 llvm-svn: 360394
* Fix build on NetBSD 8.99.38Kamil Rytarowski2019-05-081-0/+2
| | | | | | | | With recent changes the dev/nvmm/nvmm_ioctl.h header is no longer a standalone NVMM header. Disable it until the NVMM operations will stabilize and be included in the ioctl(2) interceptors. llvm-svn: 360212
* [compiler-rt] Set the ZX_VMO_RESIZABLE option for zx_vmo_createPetr Hosek2019-05-021-1/+1
| | | | | | | | | | | | | Currently VMO in Zircon create using the zx_vmo_create is resizable by default, but we'll be changing this in the future, requiring an explicit flag to make the VMO resizable. Prepare for this change by passing ZX_VMO_RESIZABLE option to all zx_vmo_create calls that need resizable VMO. Differential Revision: https://reviews.llvm.org/D61450 llvm-svn: 359803
* [compiler-rt][tests] Propagate COMPILER_RT_UNITTEST_LINK_FLAGSHubert Tong2019-05-011-0/+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][NFC] Remove unneeded SizeClassAllocatorLocalCacheVitaly Buka2019-05-013-29/+17
| | | | llvm-svn: 359729
* [sanitizer][NFC] Add const/static into a couple of methodsVitaly Buka2019-05-012-4/+4
| | | | llvm-svn: 359728
* [sanitizer][NFC] Set LargeMmapAllocator type from PrimaryAllocatorVitaly Buka2019-05-014-23/+16
| | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud