summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
Commit message (Collapse)AuthorAgeFilesLines
...
* Introduce a way to allow the ASan dylib on Darwin platforms to be loaded via ↵Dan Liew2018-12-011-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `dlopen()`. Summary: The purpose of this option is provide a way for the ASan dylib to be loaded via `dlopen()` without triggering most initialization steps (e.g. shadow memory set up) that normally occur when the ASan dylib is loaded. This new functionality is exposed by - A `SANITIZER_SUPPORTS_INIT_FOR_DLOPEN` macro which indicates if the feature is supported. This only true for Darwin currently. - A `HandleDlopenInit()` function which should return true if the library is being loaded via `dlopen()` and `SANITIZER_SUPPORTS_INIT_FOR_DLOPEN` is supported. Platforms that support this may perform any initialization they wish inside this function. Although disabling initialization is something that could potentially apply to other sanitizers it appears to be unnecessary for other sanitizers so this patch only makes the change for ASan. rdar://problem/45284065 Reviewers: kubamracek, george.karpenkov, kcc, eugenis, krytarowski Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D54469 llvm-svn: 348078
* Add a new interceptor for getvfsstat(2) from NetBSDKamil Rytarowski2018-11-302-0/+16
| | | | | | | | | | | | | | | | | | | Summary: getvfsstat - gets list of all mounted file systems. Add a dedicated test. Reviewers: vitalybuka, joerg Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D55014 llvm-svn: 348027
* Fix filtering of sanitizer_common unittest architectures on Darwin.Kuba Mracek2018-11-271-1/+1
| | | | llvm-svn: 347622
* Unbreak FreeBSD build.David Carlier2018-11-221-0/+1
| | | | | | M lib/sanitizer_common/sanitizer_platform_limits_posix.cc llvm-svn: 347451
* [XRay] Support for FuchsiaPetr Hosek2018-11-222-1/+5
| | | | | | | | This extends XRay to support Fuchsia. Differential Revision: https://reviews.llvm.org/D52162 llvm-svn: 347443
* [Sanitizer] Adding setvbuf in supported platforms and other stream buffer ↵David Carlier2018-11-216-2/+46
| | | | | | | | | | | | | | | functions - Enabling setvbuf interceptions for non NetBSD platforms. - setbuf, setbuffer, setlinebuf as well. Reviewers: vitalybuka, krytarowski Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D54779 llvm-svn: 347426
* tsan: add pthread_tryjoin_np and pthread_timedjoin_np interceptorsDmitry Vyukov2018-11-212-0/+12
| | | | | | | | | | Add pthread_tryjoin_np() and pthread_timedjoin_np() interceptors on Linux, so that ThreadSanitizer can handle programs using these functions. Author: Yuri Per (yuri) Reviewed in: https://reviews.llvm.org/D54521 llvm-svn: 347383
* Revert "[Sanitizer] intercept setvbuf on other platforms where it is supported"David Carlier2018-11-202-4/+1
| | | | llvm-svn: 347358
* [Sanitizer] intercept setvbuf on other platforms where it is supportedDavid Carlier2018-11-202-1/+4
| | | | | | | | | | | | Unit tests enabled only in platform tested. Reviewers: krytarowski, vitalybuka Reviewed By: krytarowski, vitalybuka Differential Revision: https://reviews.llvm.org/D54739 llvm-svn: 347355
* [compiler-rt] Use zx_futex_wait_deprecated for Fuchsia sanitizer runtimePetr Hosek2018-11-201-2/+2
| | | | | | | | | This change is part of the soft-transition to the new synchronization primitives which implement priority inheritance. Differential Revision: https://reviews.llvm.org/D54727 llvm-svn: 347279
* Add interceptor for the setvbuf(3) from NetBSDKamil Rytarowski2018-11-192-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | Summary: setvbuf(3) is a routine to setup stream buffering. Enable the interceptor for NetBSD. Add dedicated tests for setvbuf(3) and functions on top of this interface: setbuf, setbuffer, setlinebuf. Based on original work by Yang Zheng. Reviewers: joerg, vitalybuka Reviewed By: vitalybuka Subscribers: devnexen, tomsun.0.7, kubamracek, llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54548 llvm-svn: 347270
* [sanitizer] Update global_symbols.txtVitaly Buka2018-11-161-0/+3
| | | | llvm-svn: 347099
* Add new interceptor for mi_vector_hash(3)Kamil Rytarowski2018-11-162-0/+18
| | | | | | | | | | | | | | | | | | | | | | | Summary: mi_vector_hash(3) provides fast 32bit hash functions. Add a test for this interface. Enable the API for NetBSD. Based on original work by Yang Zheng. Reviewers: joerg, vitalybuka Reviewed By: vitalybuka Subscribers: tomsun.0.7, kubamracek, llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54530 llvm-svn: 347088
* Add new interceptor for getmntinfo(3) from NetBSDKamil Rytarowski2018-11-162-0/+20
| | | | | | | | | | | | | | | | | | | | | Summary: getmntinfo gets information about mounted file systems. Add a dedicated test for new interceptor. Based on original work by Yang Zheng. Reviewers: joerg, vitalybuka Reviewed By: vitalybuka Subscribers: tomsun.0.7, kubamracek, llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54611 llvm-svn: 347083
* Start adding the supporting code to perform out-of-process allocatorDan Liew2018-11-154-9/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | enumeration. Summary: This patch introduces the local portion (`LocalAddressSpaceView`) of the `AddressSpaceView` abstraction and modifies the secondary allocator so that the `ForEachChunk()` method (and its callees) would work in the out-of-process case when `AddressSpaceView` is `RemoteAddressSpaceView`. The `AddressSpaceView` abstraction simply maps pointers from a target process to a pointer in the local process (via its `Load()` method). For the local (in-process) case this is a no-op. For the remote (out-of-process) case this is not a no-op. The implementation of the out-of-process `RemoteAddressSpaceView` is not included in this patch and will be introduced later. This patch is considerably simpler than the `ObjectView` abstraction used in previous patches but lacks the type safety and stricter memory management of the `ObjectView` abstraction. This patch does not introduce any tests because with `LocalAddressSpaceView` it should be a non functional change and unit tests already cover the secondary allocator. When `RemoteAddressSpaceView` is landed tests will be added to ensure that it functions as expected. rdar://problem/45284065 Reviewers: kcc, kubamracek, dvyukov, vitalybuka, cryptoad, george.karpenkov, morehouse Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D53975 llvm-svn: 346956
* Introduce `sanitizer_malloc_introspect_t` for Darwin which is a sub-class of ↵Dan Liew2018-11-081-1/+23
| | | | | | | | | | | | | | | | | | | | | | Darwin's `malloc_introspection_t` and use it when setting up the malloc zone. Summary: Currently `sanitizer_malloc_introspection_t` just adds a version field which is used to version the allocator ABI. The current allocator ABI version is returned by the new `GetMallocZoneAllocatorEnumerationVersion()` function. The motivation behind this change is to allow external processes to determine the allocator ABI of a sanitized process. rdar://problem/45284065 Reviewers: kubamracek, george.karpenkov, vitalybuka Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D54045 llvm-svn: 346420
* Split lgammal() from INIT_LGAMMALKamil Rytarowski2018-11-072-4/+12
| | | | | | | | | | | | | | | | | | | | | | Summary: Introduce SANITIZER_INTERCEPT_LGAMMAL dedicated for lgammal(). Disable it for NetBSD as this routine is not implemented in this OS. Installation of supernumerary interceptors causes leaking of errors to dlsym(3)-like operations. Reviewers: joerg, vitalybuka Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54054 llvm-svn: 346352
* Split remquol() from INIT_REMQUOKamil Rytarowski2018-11-072-4/+12
| | | | | | | | | | | | | | | | | | | | | | Summary: Introduce SANITIZER_INTERCEPT_REMQUOL dedicated for remquol(). Disable for for NetBSD as this routine is not implemented in this OS. Installation of supernumerary interceptors causes leaking of errors to dlsym(3)-like operations. Reviewers: joerg, vitalybuka Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54051 llvm-svn: 346351
* [sanitizer] Only set soft coredump limit.Evgeniy Stepanov2018-11-071-3/+5
| | | | | | | | | | | | Summary: If user wants to raise it back, let them. Reviewers: kcc, vitalybuka Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D54190 llvm-svn: 346284
* [sanitizer] Return headed to fix build after r346258Vitaly Buka2018-11-061-0/+1
| | | | llvm-svn: 346270
* [sanitizer] Use "fast mmap" kernel flag for shadow memory on macOS 10.13.4+Kuba Mracek2018-11-066-1/+33
| | | | | | | | This speeds up process startup and teardown and also reduces lock contention when running multiple ASanified/TSanified processes simultaneously. Should greatly improve lit testing time. Differential Revision: https://reviews.llvm.org/D48445 llvm-svn: 346262
* [sanitizer] Fix nolibc unittests broken by r346215Vitaly Buka2018-11-062-30/+36
| | | | | | | | Subscribers: kubamracek, krytarowski, fedor.sergeev, llvm-commits Differential Revision: https://reviews.llvm.org/D54163 llvm-svn: 346258
* [sanitizer] Add char **GetEnviron() on all other platformsVitaly Buka2018-11-066-3/+21
| | | | | | | | Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D54165 llvm-svn: 346257
* [sanitizer] Use AT_EXECFN in ReExec() if availableBenjamin Kramer2018-11-061-0/+4
| | | | | | | | | | execve("/proc/self/exe") will not work if the binary relies on $EXEC_ORIGIN in an rpath. Query AT_EXECFN instead, which will give the same string that the current binary was exec'd with. Differential Revision: https://reviews.llvm.org/D54113 llvm-svn: 346215
* [Sanitizers] Disable SANITIZER_CAN_FAST_UNWIND on all SPARC targetsRainer Orth2018-11-052-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | While testing my to-be-submitted Solaris sanitizer support on gcc mainline, I ran into an issue on Solaris/SPARC (sparc-sun-solaris2.11). Initially libasan.so failed to link: Undefined first referenced symbol in file __sanitizer::BufferedStackTrace::FastUnwindStack(unsigned long, unsigned long, unsigned long, unsigned long, unsigned int) /var/gcc/gcc-9.0.0-20181024/11.5-gcc-gas/sparc-sun-solaris2.11/./libsanitizer/asan/.libs/libasan.so This happens because SANITIZER_CAN_FAST_UNWIND is enabled on non-Linux SPARC targets (cf. sanitizer_stacktrace.h), but the guard around the SPARCv8-only definition in sanitizer_stacktrace_sparc.cc only works with clang: clang predefines __sparcv8__ on non-Solaris, and __sparcv8 only on Solaris gcc predefines __sparcv8 on Solaris, but __sparc_v8__ on non-Solaris The attached patch allows for all three variants. However, disabling SANITIZER_CAN_FAST_UNWIND on all SPARC targets fixes a couple of testsuite failures in the Solaris asan testsuite, so for now it's better to keep it disabled everywhere. This allowed the libsanitizer build to complete and gave reasonable (though slightly worse than on Solaris/x86) testsuite results. Differential Revision: https://reviews.llvm.org/D54099 llvm-svn: 346155
* [Sanitizers] Solaris largefile fixesRainer Orth2018-11-054-19/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While testing the Solaris libsanitizer port on GCC mainline, I found that I'd messed up the largefile checks in various ways, some of which showed as compile failures (wrong structure sizes and member offsets), others at runtime, some of those only on sparc as a big-endian target. This patch fixes all of them: - OFF_T is now correctly defined for 32-bit largefile and traditional environments, and 64-bit. - The definition of __sanitizer_dirent now checks the correct conditionals. - sanitizer_procmaps_solaris.cc undefines _FILE_OFFSET_BITS: before Solaris 11.4 <procfs.h> doesn't even compile with largefile support enabled, but the use at hand doesn't need it anyway while g++ 9 will define _FILE_OFFSET_BITS=64 out of the box. - With full largefile support enabled, one needs to use e.g. mmap64 instead of mmap; this is hidden behind macros. With this patch I could bootstrap gcc mainline on both sparc-sun-solaris2.11 and i386-pc-solaris2.11. In addition, I've successfully built llvm on i386-pc-solaris2.11. Differential Revision: https://reviews.llvm.org/D54101 llvm-svn: 346153
* Fix build on sparc64-linux-gnu.Martin Liska2018-11-051-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D54030 llvm-svn: 346129
* Try to unbreak the build of sanitizers on !NetBSDKamil Rytarowski2018-11-021-1/+4
| | | | | | | | Include the build of unpoison_passwd() and unpoison_group() for SANITIZER_INTERCEPT_FGETPWENT_R and SANITIZER_INTERCEPT_FGETGRENT_R. static void unpoison_passwd( llvm-svn: 346042
* Split getpwent and fgetgrent functions in interceptorsKamil Rytarowski2018-11-022-15/+33
| | | | | | | | | | | | | | | | | | | | | | | | Summary: NetBSD does not ship with fgetpwent_r() and fgetgrent_r(). Split their interceptors from getpwent_r() and getgrent_r() and disable for this OS. Installation of supernumerary interceptors causes leaking of errors to dlsym(3)-like operations. No functional change for other OSes. Reviewers: vitalybuka, joerg Reviewed By: vitalybuka Subscribers: srhines, kubamracek, fedor.sergeev, llvm-commits, #sanitizers, mgorny Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54041 llvm-svn: 346038
* [PowerPC]Disable randomized address space on Linux ppc64leLei Huang2018-11-021-0/+11
| | | | | | | | | | | Recent versions of Ubuntu (17.04 and 18.04) on PowerPC have introduced changes to Address Space Layout Randomization (ASLR) that is causing 500+ sanitizer failures. This patch disables ASLR when running the sanitizers on PowerPC 64bit LE. Differential Revision: https://reviews.llvm.org/D52900 llvm-svn: 346030
* [NFC] Refactor initialisation of Darwin malloc zone fields into separate ↵Dan Liew2018-11-021-1/+5
| | | | | | | | | | | | | | | | | | function called `InitMallocZoneFields()` which is now called from `ReplaceSystemMalloc()`. Summary: The motivation here is to be able support initialisation of the malloc zone on other code paths. rdar://problem/45284065 Reviewers: kubamracek, george.karpenkov Subscribers: llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D54037 llvm-svn: 345983
* Update ioctl(2) operations for NetBSD 8.99.25Kamil Rytarowski2018-10-313-42/+66
| | | | | | | | | | | | Eliminate dropped operations, add new operations. Update included headers for newer need. Add a fallback definition of nvlist_ref_t, becaue this type is internal to libnpf and the kernel, not exported into public headers. llvm-svn: 345726
* [asan] Remove stale -fno-exceptions flag in sanitizer_common as wellReid Kleckner2018-10-311-5/+0
| | | | llvm-svn: 345685
* Cast the return value of _Unwind_GetIP() to uptrKamil Rytarowski2018-10-301-1/+1
| | | | | | | This is needed for NetBSD to match the expected type in Unwind_GetIP(). llvm-svn: 345620
* Cleanup includes in sanitizer_platform_limits_netbsd.ccKamil Rytarowski2018-10-301-105/+119
| | | | | | | | Sort the headers more correctly according to NetBSD style. Prevent in this code part clang-format, as shuffling the order will cause build failures. llvm-svn: 345586
* Regenerate syscall hooks for NetBSD 8.99.25Kamil Rytarowski2018-10-301-21/+17
| | | | | | | | | | Register new syscall getsockopt2. Drop removed syscalls pmc_get_info and pmc_control. While there address compiler warnings about potentially unused variables. llvm-svn: 345582
* Handle pthread_sigmask in DemangleFunctionName()Kamil Rytarowski2018-10-301-0/+2
| | | | | | Translate __libc_thr_sigsetmask to pthread_sigmask on NetBSD. llvm-svn: 345574
* [sanitizer] Move interceptor initialization check into real_clock_gettimeVitaly Buka2018-10-302-5/+4
| | | | | | | | | | Reviewers: cryptoad, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53777 llvm-svn: 345556
* [sanitizer] Improve macOS version detectionKuba Mracek2018-10-262-21/+30
| | | | | | Part of <https://reviews.llvm.org/D48445>. llvm-svn: 345406
* [sanitizer] Avoid calling a nullptr in MonotonicNanoTime if interceptors are ↵Kuba Mracek2018-10-241-2/+5
| | | | | | | | | | not yet initialized There's a TSan startup crash on Linux when used in Swift programs, where MonotonicNanoTime will try to call real_clock_gettime and then jump to NULL because interceptors are not yet initialized. This is on Ubuntu 18.04. Looks like TSan's main Initialize() function is called at a point where __progname is already set, but interceptors aren't yet set up. Let's fix this by checking whether interceptors are initialized in MonotonicNanoTime. Differential Revision: https://reviews.llvm.org/D53528 llvm-svn: 345174
* [Sanitizer] openbsd does not have sysctlbyname callDavid Carlier2018-10-212-5/+9
| | | | | | | | | | | | Enabling only for FreeBSD. Reviewers: krytarowski, vitalybuka Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D53413 llvm-svn: 344876
* [sanitizer] Avoid extra newlines in syslog.Evgeniy Stepanov2018-10-121-7/+10
| | | | | | | Fix line splitting logic to avoid sending empty lines to syslog, as that adds extra newlines. llvm-svn: 344426
* [sanitizers] [windows] Use a linker directive pragma for psapiMartin Storsjo2018-10-101-0/+4
| | | | | | | | | | | | | This allows users of static libraries (such as ubsan) to link without knowing about this transitive dependency, if using the psapi functions that require linking to a separate psapi library. Since Windows 7, these functions (EnumProcessModules, GetModuleInformation, GetProcessMemoryInfo) are remapped to K32- prefixed ones, available in kernel32.dll. Differential Revision: https://reviews.llvm.org/D53012 llvm-svn: 344126
* Remove remnant code of using indirect syscall on NetBSDKamil Rytarowski2018-10-085-66/+31
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The NetBSD version of internal routines no longer call the indirect syscall interfaces, as these functions were switched to lib calls. Remove the remnant code complication that is no longer needed after this change. Remove the variations of internal_syscall, as they were NetBSD specific. No functional change intended. Reviewers: vitalybuka, joerg, javed.absar Reviewed By: vitalybuka Subscribers: kubamracek, fedor.sergeev, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D52955 llvm-svn: 343988
* [Sanitizer] fix internal_sysctlbyname build for FreeBSD.David Carlier2018-10-081-1/+1
| | | | llvm-svn: 343964
* Unwind local macro DEFINE_INTERNAL()Kamil Rytarowski2018-10-051-47/+43
| | | | | | | | No functional change intended. This is a follow up of a suggestion from D52793. llvm-svn: 343870
* Introduce internal_sysctlbyname in place of sysctlbynameKamil Rytarowski2018-10-054-1/+27
| | | | | | | | | | | | | | | | | | Summary: This change will allow to install sysctlbyname() interceptors more easily in sanitizers. Reviewers: vitalybuka, joerg Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D52793 llvm-svn: 343840
* [Esan] Port cache frag to FreeBSDDavid Carlier2018-10-042-2/+14
| | | | | | | | | | | | Data involving struct accesses accounting work (plan to support only efficiency-cache-frag flag in the frontend side). Reviewers: krytarowski, vitalybuka, jfb Reviewed By : vitalybuka Differential Revision: https://reviews.llvm.org/D52608 llvm-svn: 343812
* [sanitizer] Include inlined frames into __sanitizer_symbolize_pc outputVitaly Buka2018-10-021-5/+19
| | | | | | | | | | | | | | | | Summary: Behavior for existing used is not changing as the first line is going to be the same, and it was invalid to try to read more lines. New clients can read until they get empty string. Reviewers: eugenis, morehouse Subscribers: kubamracek, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D52743 llvm-svn: 343605
* Revert "[sanitizer] Include inlined frames into __sanitizer_symbolize_pc output"Jessica Paquette2018-10-021-19/+5
| | | | | | | | | This reverts r343554. It was breaking some bots: http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/49997/ llvm-svn: 343600
OpenPOWER on IntegriCloud