summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
Commit message (Collapse)AuthorAgeFilesLines
...
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-19208-826/+624
| | | | | | | | | | | | | | | | | to reflect the new license. 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: 351636
* [hwasan] Madvise away unused shadow.Evgeniy Stepanov2019-01-191-0/+11
| | | | | | | | | | | | | | | | | | Summary: Whenever a large shadow region is tagged to zero, madvise(DONT_NEED) as much of it as possible. This reduces shadow RSS on Android by 45% or so, and total memory use by 2-4%, probably even more on long running multithreaded programs. CPU time seems to be in the noise. Reviewers: kcc, pcc Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D56757 llvm-svn: 351620
* Make compiler-rt CMakeLists.txt formatting a bit more like LLVM's usual ↵Nico Weber2019-01-161-5/+10
| | | | | | formatting llvm-svn: 351363
* [Sanitizer] Intercept sl_add api on FreeBSD/NetBSDDavid Carlier2019-01-156-5/+65
| | | | | | | | | | Reviewers: krytarowski, vitalybuka Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D56670 llvm-svn: 351189
* [test] Disable sunrpc tests when rpc/xdr.h is missingMichal Gorny2019-01-141-4/+2
| | | | | | | | | | | | | | | | | Disable tests requiring sunrpc when the relevant headers are missing. In order to accommodate that, move the header check from sanitizer_common to base-config-ix, and define the check result as a global variable there. Use it afterwards both for definition needed by sanitizer_common, and to control 'sunrpc' test feature. While at it, remove the append_have_file_definition macro that was used only once, and no longer fits the split check-definition. Bug report: https://github.com/google/sanitizers/issues/974 Differential Revision: https://reviews.llvm.org/D47819 llvm-svn: 351109
* [sanitizer] Move android's GetPageSize to a header (NFC)Evgeniy Stepanov2019-01-122-4/+13
| | | | | | | No need to pay function call overhead for a function that returns a constant. llvm-svn: 350983
* sanitizer_common: Change gen_dynamic_list.py to take a -o argument instead ↵Peter Collingbourne2019-01-111-10/+13
| | | | | | | | | | | of writing to stdout. This makes the script a little more gn friendly; gn does not support redirecting the output of a script. Differential Revision: https://reviews.llvm.org/D56579 llvm-svn: 350980
* [Sanitizer] Disable getusershell interception for AndroidDavid Carlier2019-01-111-1/+1
| | | | | | | | | | Reviewers: vitalybuka, pcc, eugenis Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D56583 llvm-svn: 350965
* Provide storage for `true_type::value` and `false_type::value`.Dan Liew2019-01-112-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes linker errors that occurs when the `sanitizer_type_traits_test.cc` is built without optimizations. The error occurs because the test tries to take a reference. A possible workaround is to give the GTest macros take boolean rvalues by doing something like: ``` ASSERT_TRUE(bool(is_same<uptr, uptr>::value)); ``` However this only hides the problem. Unfortunately Using `constexpr` won't fix the problem unless we are using C++17. Reviewers: vitalybuka, kubamracek, george.karpenkov, yln Subscribers: mgorny, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D56035 llvm-svn: 350940
* [Sanitizer] Intercept getusershellDavid Carlier2019-01-112-0/+17
| | | | | | | | | | | | - If entries are properly copied (there were a bug in FreeBSD implementation in earlier version), or list properly reset. Reviewers: vitalybuka, krytarowski Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D56562 llvm-svn: 350919
* [sanitizer_common] Define __sanitizer_FILE on NetBSDMichal Gorny2019-01-103-2/+59
| | | | | | Differential Revision: https://reviews.llvm.org/D56109 llvm-svn: 350882
* [sanitizer_common] Remove support for tirpc/rpc/xdr.hMichal Gorny2019-01-104-11/+2
| | | | | | | | | | | | | Remove the partial support for rpc/xdr.h from libtirpc. Since it is an entirely external library, we ought to build it sanitized separately and not attempt to intercept like the libc implementation. Besides, the existing code for tirpc support was neither complete nor working. Noted by @krytarowski. Differential Revision: https://reviews.llvm.org/D47817 llvm-svn: 350881
* i[Sanitizer] Enable pututxline interceptionDavid Carlier2019-01-101-1/+13
| | | | | | | | | | Reviewers: krytarowski Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D56495 llvm-svn: 350796
* [Sanitizer] Intercept fdevname on FreeBSDDavid Carlier2019-01-082-0/+36
| | | | | | | | | | | | | - Is a file descriptor flavor FreeBSD's specific. - reentrant version included. Reviewers: vitalybuka, krytarowski, emaste Reviewed By: emaste Differential Revision: https://reviews.llvm.org/D56268 llvm-svn: 350658
* Fix Mac compilation.Evgeniy Stepanov2019-01-081-0/+4
| | | | | | Provide an implementation of MemoryMappingLayout::Error() for Mac. llvm-svn: 350601
* [asan] Support running without /procEvgeniy Stepanov2019-01-0811-4/+39
| | | | | | | | | | | | | | | | | | Summary: This patch lets ASan run when /proc is not accessible (ex. not mounted yet). It includes a special test-only flag that emulates this condition in an unpriviledged process. This only matters on Linux, where /proc is necessary to enumerate virtual memory mappings. Reviewers: vitalybuka, pcc, krytarowski Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D56141 llvm-svn: 350590
* [compiler-rt][Fuchsia] Replace _zx_vmar_allocate_old callPetr Hosek2019-01-061-4/+4
| | | | | | | | | This is the deprecated legacy interface, replace it with the current _zx_vmar_allocate one. Differential Revision: https://reviews.llvm.org/D56360 llvm-svn: 350488
* Revert "Revert "Switch Android from TLS_SLOT_TSAN(8) to TLS_SLOT_SANITIZER(6)""Evgeniy Stepanov2019-01-051-5/+5
| | | | | | This reapplies commit r348984. llvm-svn: 350449
* [sanitizer] Reduce stack depot size on Android.Evgeniy Stepanov2019-01-042-2/+2
| | | | | | | | | | | | | | | | Summary: The default setting kTabSizeLog=20 results in an 8Mb global hash table, almost all of it in private pages. That is not a sane setting in a mobile, system-wide use case: with ~150 concurrent processes stack depot will account for more than 1Gb of RAM. Reviewers: kcc, pcc Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D56333 llvm-svn: 350443
* [hwasan] Switch to 64 allocator with a dense size class map.Evgeniy Stepanov2019-01-032-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Replace the 32-bit allocator with a 64-bit one with a non-constant base address, and reduce both the number of size classes and the maximum size of per-thread caches. As measured on [1], this reduces average weighted memory overhead (MaxRSS) from 26% to 12% over stock android allocator. These numbers include overhead from code instrumentation and hwasan shadow (i.e. not a pure allocator benchmark). This switch also enables release-to-OS functionality, which is not implemented in the 32-bit allocator. I have not seen any effect from that on the benchmark. [1] https://android.googlesource.com/platform/system/extras/+/master/memory_replay/ Reviewers: vitalybuka, kcc Subscribers: kubamracek, cryptoad, llvm-commits Differential Revision: https://reviews.llvm.org/D56239 llvm-svn: 350370
* [Sanitizer] Enable funopen on FreeBSDDavid Carlier2019-01-021-1/+1
| | | | | | | | | | Reviewers: krytarowski Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D56209 llvm-svn: 350248
* [sanitizer] Android does not provide <fstab.h>Evgeniy Stepanov2019-01-022-4/+3
| | | | llvm-svn: 350246
* [sanitizer_common] Implement funopen*() interceptors for NetBSDMichal Gorny2019-01-022-0/+164
| | | | | | Differential Revision: https://reviews.llvm.org/D56158 llvm-svn: 350233
* [sanitizer_common] Implement popen, popenve, pclose interceptorsMichal Gorny2019-01-022-0/+78
| | | | | | | | | | | | | | | Implement the interceptors for popen(), pclose() and popenve() functions. The first two are POSIX, the third one is specific to NetBSD. popen() spawns a process and creates a FILE object piping data from/to that process. pclose() closes the pipe and waits for the process to terminate appropriately. For the purpose of popen(), the COMMON_INTERCEPTOR_FILE_OPEN macro is modified to allow null path parameter. Differential Revision: https://reviews.llvm.org/D56157 llvm-svn: 350232
* [sanitizer_common] Fix devname_r() return type on !NetBSDMichal Gorny2019-01-021-4/+11
| | | | | | | | | | Update the interceptor for devname_r() to account for correct return types on different platforms. This function returns int on NetBSD but char* on FreeBSD/OSX. Noticed by @krytarowski. Differential Revision: https://reviews.llvm.org/D56150 llvm-svn: 350228
* Add support for background thread on NetBSD in ASanKamil Rytarowski2018-12-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Change the point of calling MaybeStartBackgroudThread() from AsanInitInternal() that is too early on NetBSD to a constructor (with aid of C++11 lambda construct). Enable the code for background thread as is for NetBSD. Rename test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc to test/sanitizer_common/TestCases/hard_rss_limit_mb_test.cc and allow runs on NetBSD. This tests passes correctly. Reviewers: vitalybuka, joerg, eugenis Reviewed By: eugenis Subscribers: eugenis, kubamracek, fedor.sergeev, llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D55887 llvm-svn: 350139
* [Sanitizer] Enable getfsent api for DarwinDavid Carlier2018-12-293-1/+4
| | | | | | | | | | Reviewers: vitalybuka, kubamracek Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D56138 llvm-svn: 350138
* Introduce `LocalAddressSpaceView::LoadWritable(...)` and make the ↵Dan Liew2018-12-282-13/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Load(...)` method return a const pointer. Summary: This is a follow-up to r346956 (https://reviews.llvm.org/D53975). The purpose of this change to allow implementers of the `AddressSpaceView` to be able to distinguish between when a caller wants read-only memory and when a caller wants writable memory. Being able distinguish these cases allows implementations to optimize for the different cases and also provides a way to workaround possible platform restrictions (e.g. the low level platform interface for reading out-of-process memory may place memory in read-only pages). For allocator enumeration in almost all cases read-only is sufficient so we make `Load(...)` take on this new requirement and introduce the `LoadWritable(...)` variants for cases where memory needs to be writable. The behaviour of `LoadWritable(...)` documented in comments are deliberately very restrictive so that it will be possible in the future to implement a simple write-cache (i.e. just a map from target address to a writable region of memory). These restrictions can be loosened in the future if necessary by implementing a more sophisticated write-cache. rdar://problem/45284065 Reviewers: kcc, cryptoad, eugenis, kubamracek, george.karpenkov Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D54879 llvm-svn: 350136
* [Sanitizer] Intercept arc4random_buf / arc4random_addrandom on FreeBSD/NetBSDDavid Carlier2018-12-282-0/+27
| | | | | | | | | | | | | | | - Disabled on purpose on Android and Darwin platform (for now). - Darwin supports it, would need interception in its specific code before enabling it. - Linux does not support it but only via third party library. - Android supports it via bionic however it is known to have issue with older versions of the implementations. Can be enabled by an Android committer later on if necessary once there is more 'certainity'/been more tested. Reviewers: krytarowski, vitalybuka Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D56125 llvm-svn: 350123
* Revert "[asan] Support running without /proc.", +1Evgeniy Stepanov2018-12-2811-42/+0
| | | | | | | | | Revert r350104 "[asan] Fix build on windows." Revert r350101 "[asan] Support running without /proc." These changes break Mac build, too. llvm-svn: 350112
* Fix a mistake in previousKamil Rytarowski2018-12-281-2/+2
| | | | | | Assign correct ioctl(2) operation number. llvm-svn: 350110
* Update NetBSD ioctl(2) entries with 8.99.28Kamil Rytarowski2018-12-273-1/+54
| | | | | | | | | Add SIOCSETHERCAP. Add commented out NVMM (NetBSD Virtual Machine Monitor) operations as this interface is still WIP and a subject to change. llvm-svn: 350107
* Enable posix regex interceptors on linux.Evgeniy Stepanov2018-12-273-1/+6
| | | | | | | | | | | | Summary: They happen to work out of the box. Reviewers: rtrieu, vitalybuka Subscribers: kubamracek, fedor.sergeev, krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D56088 llvm-svn: 350103
* [asan] Support running without /proc.Evgeniy Stepanov2018-12-2711-0/+42
| | | | | | | | | | | | | | | | | | Summary: This patch lets ASan run when /proc is not accessible (ex. not mounted yet). It includes a special test-only flag that emulates this condition in an unpriviledged process. This only matters on Linux, where /proc is necessary to enumerate virtual memory mappings. Reviewers: pcc, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D55874 llvm-svn: 350101
* [Sanitizer] Add fstab api to FreeBSD/LinuxDavid Carlier2018-12-276-0/+49
| | | | | | | | | | | | Interception of /etc/fstab function parsers. Reviewers: krytarowski, vitalybuka Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D56099 llvm-svn: 350099
* [sanitizer] Avoid memset call in tsanJordan Rupprecht2018-12-271-1/+2
| | | | | | | | | | | | Summary: Assigning an array of bools to {false, false, false} can, in certain build configurations, lead to a memset call. Use internal_memset to avoid this. Reviewers: eugenis Subscribers: kubamracek, delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D56107 llvm-svn: 350098
* [Sanitizer] Enable FTS api on FreeBSDDavid Carlier2018-12-273-1/+6
| | | | | | | | | | Reviewers: krytarowski, vitalybuka Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D56097 llvm-svn: 350090
* [xray] Detect MPROTECT and error out when it's enabled (on NetBSD)Michal Gorny2018-12-236-0/+35
| | | | | | | | | | Add a CheckMPROTECT() routine to detect when pax MPROTECT is enabled on NetBSD, and error xray out when it is. The solution is adapted from existing CheckASLR(). Differential Revision: https://reviews.llvm.org/D56049 llvm-svn: 350030
* [Sanitizer] Enable POSIX regex api on FreeBSD.David Carlier2018-12-224-7/+21
| | | | | | | | | | | | | | | | | Reviewers: krytarowski Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D56009 M lib/sanitizer_common/sanitizer_common_interceptors.inc M lib/sanitizer_common/sanitizer_platform_interceptors.h M lib/sanitizer_common/sanitizer_platform_limits_freebsd.cc M lib/sanitizer_common/sanitizer_platform_limits_freebsd.h D test/sanitizer_common/TestCases/NetBSD/regex.cc A + test/sanitizer_common/TestCases/Posix/regex.cc llvm-svn: 350002
* Fix comment typo.Dan Liew2018-12-211-1/+1
| | | | llvm-svn: 349961
* Fix `static_assert()` scope in `CombinedAllocator`.Dan Liew2018-12-211-6/+7
| | | | | | | | | | | | | It should be at the class scope and not inside the `Init(...)` function because we want to error out as soon as the wrong type is constructed. At the function scope the `static_assert` is only checked if the function might be called. This is a follow up to r349957. rdar://problem/45284065 llvm-svn: 349960
* Fix `static_assert()` scope in `SizeClassAllocator32`.Dan Liew2018-12-211-3/+4
| | | | | | | | | | | | | It should be at the class scope and not inside the `Init(...)` function because we want to error out as soon as the wrong type is constructed. At the function scope the `static_assert` is only checked if the function might be called. This is a follow up to r349138. rdar://problem/45284065 llvm-svn: 349959
* Introduce `AddressSpaceView` template parameter to `CombinedAllocator`.Dan Liew2018-12-212-3/+11
| | | | | | | | | | | | | | | | | | | | | | Summary: This is a follow up to https://reviews.llvm.org/D55764 . For the ASan and LSan allocatorsthe type declarations have been modified so that it's possible to create a combined allocator type that consistently uses a different type of `AddressSpaceView`. We intend to use this in future patches. For the other sanitizers they just use `LocalAddressSpaceView` by default because we have no plans to use these allocators in an out-of-process manner. rdar://problem/45284065 Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov, yln Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D55766 llvm-svn: 349957
* Introduce `AddressSpaceView` template parameter to `SizeClassAllocator64`.Dan Liew2018-12-212-8/+43
| | | | | | | | | | | | | | | | | | | | | | Summary: This is a follow up patch to r349138. This patch makes a `AddressSpaceView` a type declaration in the allocator parameters used by `SizeClassAllocator64`. For ASan, LSan, and the unit tests the AP64 declarations have been made templated so that `AddressSpaceView` can be changed at compile time. For the other sanitizers we just hard-code `LocalAddressSpaceView` because we have no plans to use these allocators in an out-of-process manner. rdar://problem/45284065 Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D55764 llvm-svn: 349954
* [Sanitizer] Enable strtonum in FreeBSDDavid Carlier2018-12-211-1/+1
| | | | | | | | | | Reviewers: krytarowski, vitalybuka Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D55993 llvm-svn: 349916
* [sanitizer] Support running without fd 0,1,2.Evgeniy Stepanov2018-12-206-9/+36
| | | | | | | | | | | | | | | | | | | Summary: Support running with no open file descriptors (as may happen to "init" process on linux). * Remove a check that writing to stderr succeeds. * When opening a file (ex. for log_path option), dup the new fd out of [0, 2] range to avoid confusing the program. (2nd attempt, this time without the sanitizer_rtems change) Reviewers: pcc, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D55801 llvm-svn: 349817
* [Sanitizer] Enable vis api on FreeBSDDavid Carlier2018-12-203-1/+6
| | | | | | | | | | Reviewers: krytarowski Reviewed By: krytarowski Differential Revision: https://reviews.llvm.org/D55923 llvm-svn: 349762
* Revert "[sanitizer] Support running without fd 0,1,2."Ilya Biryukov2018-12-207-37/+10
| | | | | | | | This reverts commit r349699. Reason: the commit breaks compilation of sanitizer_rtems.cc when building for RTEMS. llvm-svn: 349745
* [sanitizer] Support running without fd 0,1,2.Evgeniy Stepanov2018-12-197-10/+37
| | | | | | | | | | | | | | | | | Summary: Support running with no open file descriptors (as may happen to "init" process on linux). * Remove a check that writing to stderr succeeds. * When opening a file (ex. for log_path option), dup the new fd out of [0, 2] range to avoid confusing the program. Reviewers: pcc, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D55801 llvm-svn: 349699
* [sanitizer] Remove spurious semi-colonKostya Kortchinsky2018-12-191-1/+1
| | | | | | | | | | | | | | | | | | | Summary: An extra ';' at the end of a namespace triggers a pedantic warning: ``` .../sanitizer_common/sanitizer_type_traits.h:42:2: warning: extra ‘;’ [-Wpedantic] }; // namespace __sanitizer ``` Reviewers: eugenis, delcypher Reviewed By: eugenis Subscribers: kubamracek, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D55849 llvm-svn: 349666
OpenPOWER on IntegriCloud