summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
Commit message (Collapse)AuthorAgeFilesLines
...
* [ASan] Do not misrepresent high value address dereferences as null dereferencesJulian Lettner2019-10-105-5/+38
| | | | | | | | | | | | | | | | | | | | | | Dereferences with addresses above the 48-bit hardware addressable range produce "invalid instruction" (instead of "invalid access") hardware exceptions (there is no hardware address decoding logic for those bits), and the address provided by this exception is the address of the instruction (not the faulting address). The kernel maps the "invalid instruction" to SEGV, but fails to provide the real fault address. Because of this ASan lies and says that those cases are null dereferences. This downgrades the severity of a found bug in terms of security. In the ASan signal handler, we can not provide the real faulting address, but at least we can try not to lie. rdar://50366151 Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D68676 llvm-svn: 374265
* [sanitizer_common] Remove OnPrint from Go build.Matt Morehouse2019-10-091-6/+0
| | | | | | | | | | | | | | | | Summary: Go now uses __sanitizer_on_print instead. Reviewers: vitalybuka, dvyukov Reviewed By: vitalybuka Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68621 llvm-svn: 374258
* [msan] Add interceptors: crypt, crypt_r.Evgeniy Stepanov2019-10-084-0/+42
| | | | | | | | | | | | Reviewers: vitalybuka Subscribers: srhines, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68431 llvm-svn: 373993
* [tsan, go] fix Go windows buildVitaly Buka2019-10-071-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Don't use weak exports when building tsan into a shared library for Go. gcc can't handle the pragmas used to make the weak references. Include files that have been added since the last update to build.bat. (We should really find a better way to list all the files needed.) Add windows version defines (WINVER and _WIN32_WINNT) to get AcquireSRWLockExclusive and ReleaseSRWLockExclusive defined. Define GetProcessMemoryInfo to use the kernel32 version. This is kind of a hack, the windows header files should do this translation for us. I think we're not in the right family partition (we're using Desktop, but that translation only happens for App and System partitions???), but hacking the family partition seems equally gross and I have no idea what the consequences of that might be. Patch by Keith Randall. Reviewers: dvyukov, vitalybuka Reviewed By: vitalybuka Subscribers: jfb, delcypher, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D68599 llvm-svn: 373984
* [sanitizer] Print SIGTRAP for corresponding signalVitaly Buka2019-10-071-0/+2
| | | | | | | | | | | | Reviewers: eugenis, jfb Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68603 llvm-svn: 373979
* compiler-rt: use __GLIBC_PREREQ for SANITIZER_INTERCEPT_GETRANDOMVitaly Buka2019-10-041-2/+2
| | | | | | | | | | | | | | Summary: Fixes https://github.com/google/oss-fuzz/issues/2836 Reviewers: eugenis Subscribers: dberris, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68178 llvm-svn: 373681
* compiler-rt: move all __GLIBC_PREREQ into own header fileVitaly Buka2019-10-035-19/+38
| | | | | | | | | | | | Reviewers: eugenis Subscribers: dberris, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68177 llvm-svn: 373632
* Move SanitizerInitializeUnwinder outside anonymous namespace.Matt Morehouse2019-10-021-32/+32
| | | | | | Fixes the Android build breakage introduced in r373528. llvm-svn: 373539
* [sanitizer_common] Declare __sanitizer_on_print in Windows interception.Matt Morehouse2019-10-021-0/+1
| | | | | | Speculative fix for Windows bot. llvm-svn: 373532
* [sanitizer_common] Add __sanitizer_on_print to interface list.Matt Morehouse2019-10-021-0/+1
| | | | | | Should fix the current Windows buildbot failure. llvm-svn: 373530
* NFC: add namespace {}Vitaly Buka2019-10-021-0/+4
| | | | llvm-svn: 373528
* [sanitizer_common] Rename OnPrint to __sanitizer_on_print.Matt Morehouse2019-10-021-1/+7
| | | | | | | | | | | | | | | | | | Summary: https://reviews.llvm.org/D28596 exposed OnPrint in the global namespace, which can cause collisions with user-defined OnPrint() functions. Reviewers: vitalybuka, dvyukov Reviewed By: vitalybuka, dvyukov Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67987 llvm-svn: 373518
* Revert "compiler-rt: use __GLIBC_PREREQ for SANITIZER_INTERCEPT_GETRANDOM"Vitaly Buka2019-10-016-37/+21
| | | | | | | | | | | Revert "compiler-rt: move all __GLIBC_PREREQ into own header file" "move all __GLIBC_PREREQ" breaks build on some bots This reverts commit 2d75ee937397c209dbd95aefc88da6301fed07da. This reverts commit 7a6461fcc2ed8e28c43993c561721af0bbe97f3a. llvm-svn: 373367
* compiler-rt: use __GLIBC_PREREQ for SANITIZER_INTERCEPT_GETRANDOMVitaly Buka2019-10-011-2/+2
| | | | | | | | | | | | | | Summary: Fixes https://github.com/google/oss-fuzz/issues/2836 Reviewers: eugenis Subscribers: dberris, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68178 llvm-svn: 373284
* compiler-rt: move all __GLIBC_PREREQ into own header fileVitaly Buka2019-10-015-19/+35
| | | | | | | | | | | | Reviewers: eugenis Subscribers: dberris, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68177 llvm-svn: 373283
* sanitizer_common: fix freebsd build errorDmitry Vyukov2019-09-241-1/+0
| | | | | | | | Variable flags is not used. Remove it. Suggested-by: randall77 (Keith Randall) Review: https://reviews.llvm.org/D67928 llvm-svn: 372698
* Add __lsan::ScopedInterceptorDisabler for strerror(3)Kamil Rytarowski2019-09-211-0/+6
| | | | | | | | | | | | | | | | | | | | Summary: strerror(3) on NetBSD uses internally TSD with a destructor that is never fired for exit(3). It's correctly called for pthread_exit(3) scenarios. This is a case when a leak on exit(3) is expected, unavoidable and harmless. Reviewers: joerg, vitalybuka, dvyukov, mgorny Reviewed By: vitalybuka Subscribers: dmgreen, kristof.beyls, jfb, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D67337 llvm-svn: 372461
* Stop tracking atexit/__cxa_atexit/pthread_atfork allocations in LSan/NetBSDKamil Rytarowski2019-09-211-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The atexit(3) and __cxa_atexit() calls allocate internally memory and free on exit, after executing all callback. This causes false positives as DoLeakCheck() is called from the atexit handler. In the LSan/ASan tests there are strict checks triggering false positives here. Intercept all atexit(3) and __cxa_atexit() calls and disable LSan when calling the real functions. Stop tracing allocations in pthread_atfork(3) funtions, as there are performed internal allocations that are not freed for the time of running StopTheWorld() code. This avoids false-positives. The same changes have to be replicated in the ASan and LSan runtime. Non-NetBSD OSs are not tested and this code is restricted to NetBSD only. Reviewers: dvyukov, joerg, mgorny, vitalybuka, eugenis Reviewed By: vitalybuka Subscribers: jfb, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D67331 llvm-svn: 372459
* Add getauxval() compat for NetBSDKamil Rytarowski2019-09-122-3/+21
| | | | | | | | | | | | | | | | | | | | | | | Summary: getauxval() is not available on NetBSD and there is no a direct equivalent. Add a function that implements the same semantics with NetBSD internals. Reorder the GetPageSize() functions to prefer the sysctl approach for NetBSD. It no longer makes a difference which approach is better. Avoid changing conditional code path. Reviewers: vitalybuka, dvyukov, mgorny, joerg Reviewed By: vitalybuka Subscribers: llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D67329 llvm-svn: 371758
* [compiler-rt] cpplint of inc files in backgroundVitaly Buka2019-09-121-0/+2
| | | | llvm-svn: 371705
* [compiler-rt] Remove some cpplint filtersVitaly Buka2019-09-1210-38/+45
| | | | llvm-svn: 371704
* [compiler-rt] Better lint output for .inc filesVitaly Buka2019-09-121-12/+4
| | | | llvm-svn: 371702
* Remove NOLINTs from compiler-rtVitaly Buka2019-09-1130-179/+183
| | | | llvm-svn: 371687
* Fix mac buildVitaly Buka2019-09-111-4/+4
| | | | llvm-svn: 371680
* Update compiler-rt cpplint.pyVitaly Buka2019-09-1110-2685/+4913
| | | | | | https://github.com/cpplint/cpplint/commit/adb3500107f409ac5491188ae652ac3f4d03d9d3 llvm-svn: 371675
* Do not intercept malloc_usable_size on NetBSDKamil Rytarowski2019-09-081-1/+2
| | | | llvm-svn: 371334
* compiler-rt: use 64-bit time_t for all FreeBSD archs except i386Ed Maste2019-09-031-1/+1
| | | | | | | | | At present only i386 has 32-bit time_t on FreeBSD. Reviewed by: dim Differential Revision: https://reviews.llvm.org/D66758 llvm-svn: 370756
* compiler-rt: use more __sanitizer_time_t on FreeBSDEd Maste2019-09-031-11/+11
| | | | | | | | | A few structs were using long for time_t members. NFC. Reviewed by: devnexen Differential Revision: https://reviews.llvm.org/D66756 llvm-svn: 370755
* [sanitizer] Support monorepo layout in symbolizer build scriptVitaly Buka2019-08-291-6/+21
| | | | llvm-svn: 370288
* [sanitizer] Simplify COMPILER_RT setup in lint scriptVitaly Buka2019-08-281-8/+2
| | | | llvm-svn: 370277
* [sanitizer_common] Close superfluous file descriptors in spawned processJulian Lettner2019-08-271-5/+23
| | | | | | | | | | | | | | Use attribute flag `POSIX_SPAWN_CLOEXEC_DEFAULT` in the call to `posix_spawn`. If this flag is set, then only file descriptors explicitly described by the file_actions argument are available in the spawned process; all of the other file descriptors are automatically closed in the spawned process. POSIX_SPAWN_CLOEXEC_DEFAULT is an Apple-specific extension. llvm-svn: 370121
* NFC: clang-format r370008 to suppress lint errorsVitaly Buka2019-08-272-7/+6
| | | | llvm-svn: 370023
* Fix buildbotDavid Carlier2019-08-272-4/+7
| | | | llvm-svn: 370011
* [Sanitizer] Using huge page on FreeBSD for shadow mappingDavid Carlier2019-08-273-2/+28
| | | | | | | | | | | | | - Unless explicit configuration, using FreeBSD super pages feature for shadow mapping. - asan only for now. Reviewers: dim, emaste, vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D65851 llvm-svn: 370008
* [sanitizer] Resubmit D66620 from monorepoTaewook Oh2019-08-222-1/+3
| | | | | | | | | | | | | | | | Summary: https://reviews.llvm.org/D66620 is accepted but was based on the multi-repo setup, so I was not able to `arc patch` it. Resubmit the diff under monorepo Committed on behalf of @sugak (Igor Sugak) Reviewers: sugak Subscribers: #sanitizers, llvm-commits, vitalybuka Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66624 llvm-svn: 369716
* Fixing buildbot due to style.David Carlier2019-08-221-2/+4
| | | | llvm-svn: 369711
* [Sanitizer] checks ASLR on FreeBSDDavid Carlier2019-08-221-0/+27
| | | | | | | | | | | | - Especially MemorySanitizer fails if those sysctl configs are enabled. Reviewers: vitalybuka, emaste, dim Reviewed By: dim Differential Revision: https://reviews.llvm.org/D66582 llvm-svn: 369708
* Revert r369472 and r369441Vitaly Buka2019-08-216-234/+0
| | | | | | check-sanitizer does not work on Linux llvm-svn: 369495
* [AArch64] Speed-up leak and address sanitizers on AArch64 for 48-bit VMASebastian Pop2019-08-206-0/+234
| | | | | | | | | | | | | | | | | | This patch fixes https://github.com/google/sanitizers/issues/703 On a Graviton-A1 aarch64 machine with 48-bit VMA, the time spent in LSan and ASan reduced from 2.5s to 0.01s when running clang -fsanitize=leak compiler-rt/test/lsan/TestCases/sanity_check_pure_c.c && time ./a.out clang -fsanitize=address compiler-rt/test/lsan/TestCases/sanity_check_pure_c.c && time ./a.out With this patch, LSan and ASan create both the 32 and 64 allocators and select at run time between the two allocators following a global variable that is initialized at init time to whether the allocator64 can be used in the virtual address space. Differential Revision: https://reviews.llvm.org/D60243 llvm-svn: 369441
* Build symbolizer runtime with C++14.Peter Collingbourne2019-08-191-1/+1
| | | | | | Should hopefully fix sanitizer-x86_64-linux bot. llvm-svn: 369290
* [Sanitizer] arc4random interception on MacDavid Carlier2019-08-192-2/+3
| | | | | | | | | | Reviewers: yln,vitalybuka Reviewed By: yln Differential Revision: https://reviews.llvm.org/D66391 llvm-svn: 369285
* [sanitizer_common] Always use posix_spawn on DarwinJulian Lettner2019-08-151-1/+2
| | | | | | | | | | | | | On Darwin we have two external symbolizers: atos and llvm-symbolizer. atos was changed to use posix_spawn (instead of fork+execv) in a previous commit [1]. Let's use posix_spawn for llvm-symbolizer as well. Our hope is that eventually we can transition to posix_spawn on other platforms too. [1] 399408a92f1dbbefeb708f718b0d8eb62dfa9f09 llvm-svn: 369021
* [sanitizer_common] Replace forkpty with posix_spawn on DarwinJulian Lettner2019-08-156-92/+99
| | | | | | | | | | | | | | | | | | | | | | | | | On Darwin, we currently use forkpty to communicate with the "atos" symbolizer. There are several problems that fork[pty] has, e.g. that after fork, interceptors are still active and this sometimes causes crashes or hangs. This is especially problematic for TSan, which uses interceptors for OS-provided locks and mutexes, and even Libc functions use those. This patch replaces forkpty with posix_spawn on Darwin. Since posix_spawn doesn't fork (at least on Darwin), the interceptors are not a problem. Another benefit is that we'll handle post-fork failures (e.g. sandbox disallows "exec") gracefully now. Related revisions and previous attempts that were blocked by or had to be revered due to test failures: https://reviews.llvm.org/D48451 https://reviews.llvm.org/D40032 Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D65253 llvm-svn: 368947
* [Sanitizer] Reenable getusershell interceptionDavid Carlier2019-08-101-1/+1
| | | | | | | | | | | | and disabling it forAndroid. Reviewers: krytarowski, vitalybuka Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D66027 llvm-svn: 368504
* [Sanitizer][Darwin] Add interceptor for malloc_zone_from_ptrJulian Lettner2019-08-091-1/+10
| | | | | | | | | | | | | | | | | Ensure that malloc_default_zone and malloc_zone_from_ptr return the sanitizer-installed malloc zone even when MallocStackLogging (MSL) is requested. This prevents crashes in certain situations. Note that the sanitizers and MSL cannot be used together. If both are enabled, MSL functionality is essentially deactivated since it only hooks the default allocator which is replaced by a custom sanitizer allocator. rdar://53686175 Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D65990 llvm-svn: 368492
* [sanitizer] Update symbolizer/scripts/global_symbols.txtBenjamin Kramer2019-08-091-0/+5
| | | | llvm-svn: 368440
* [compiler-rt] Add ConsumeProbability and ConsumeFloatingPoint methods to FDP.Max Moroz2019-08-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Also slightly cleaned up the comments and changed the header's extension back to `.h` as per comments on https://reviews.llvm.org/D65812. New methods added: * `ConsumeProbability` returns [0.0, 1.0] by consuming an unsigned integer value from the input data and dividing that value by the integer's max value. * `ConsumeFloatingPointInRange` returns a floating point value in the given range. Relies on `ConsumeProbability` method. This method does not have the limitation of `std::uniform_real_distribution` that requires the given range to be <= the floating point type's max. If the range is too large, this implementation will additionally call `ConsumeBool` to decide whether the result will be in the first or the second half of the range. * `ConsumeFloatingPoint` returns a floating point value in the range `[std::numeric_limits<T>::lowest(), std::numeric_limits<T>::min()]`. Tested on Linux, Mac, Windows. Reviewers: morehouse Reviewed By: morehouse Subscribers: kubamracek, mgorny, dberris, delcypher, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D65905 llvm-svn: 368331
* Sync ioctl(2) list with NetBSD 9.99.3Kamil Rytarowski2019-08-083-7/+127
| | | | | | | | Register 36 new ioctl(2) calls. Enable NVMM for amd64 as the API has been stabilized. llvm-svn: 368247
* [Sanitizer] little typoDavid Carlier2019-08-061-1/+1
| | | | llvm-svn: 368093
* [Sanitizer] Linux explicitally migrate shadow mapping to Transparent Huge PageDavid Carlier2019-08-063-8/+6
| | | | | | | | | | | | in madvise mode, the shadow pages will be migrated only via madvise explicit calls. Reviewers: vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D65775 llvm-svn: 368090
OpenPOWER on IntegriCloud