summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/hwasan
Commit message (Collapse)AuthorAgeFilesLines
...
* [hwasan] Export memory stats through /proc/$PID/maps.Evgeniy Stepanov2018-09-084-7/+46
| | | | | | | Adds a line to /proc/$PID/maps with more or less up-to-date memory stats of the process. llvm-svn: 341735
* [hwasan] Fix malloc overflow detection.Evgeniy Stepanov2018-09-071-7/+9
| | | | | | | | | Check size limit before rounding up, otherwise malloc((size_t)-1) would happily allocate 0 bytes. Steal a nice test case from scudo. llvm-svn: 341612
* [hwasan] change the thread list so that main_thread can also be removedKostya Serebryany2018-09-072-8/+12
| | | | llvm-svn: 341610
* [hwasan] Remove allocator interceptors.Evgeniy Stepanov2018-09-062-93/+92
| | | | | | | | | | | | | | | | | | Summary: When building without COMPILER_RT_HWASAN_WITH_INTERCEPTORS, skip interceptors for malloc/free/etc and only export their versions with __sanitizer_ prefix. Also remove a hack in mallinfo() interceptor that does not apply to hwasan. Reviewers: kcc Subscribers: kubamracek, krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D51711 llvm-svn: 341598
* [hwasan] fix pthread_exitKostya Serebryany2018-09-061-1/+1
| | | | llvm-svn: 341594
* [hwasan] introduce __hwasan_print_memory_usageKostya Serebryany2018-09-066-3/+55
| | | | llvm-svn: 341592
* [hwasan] when verbose_threads==1, print the memory usage per threadKostya Serebryany2018-09-052-1/+8
| | | | llvm-svn: 341507
* [hwasan] simplify the code, NFCKostya Serebryany2018-09-054-21/+8
| | | | llvm-svn: 341501
* [hwasan] Don't handle signals on Android.Evgeniy Stepanov2018-09-051-0/+11
| | | | | | | | | | Sigtrap is used for error reporting, but all other signals are better left for the platform. In particular, sanitizer signal handlers do not dump registers or memory which makes debugging harder for no good reason. llvm-svn: 341500
* [hwasan] revert r341435 as it breaks the bot on aarch64Kostya Serebryany2018-09-051-11/+7
| | | | llvm-svn: 341441
* [hwasan] fix colored outputKostya Serebryany2018-09-051-0/+1
| | | | llvm-svn: 341440
* [hwasan] print thread IDs when reporting a bug (also had to fix ↵Kostya Serebryany2018-09-054-23/+36
| | | | | | pthread_create on Linux) llvm-svn: 341438
* [hwasan] use real TLS on linux to store the current thread -- this way we ↵Kostya Serebryany2018-09-051-7/+11
| | | | | | can call t->Destroy in __hwasan_thread_exit, same as on Android llvm-svn: 341435
* [hwasan] simplify the code, NFCKostya Serebryany2018-09-054-16/+8
| | | | llvm-svn: 341432
* [hwasan] remove stale Thread:: data members. While doing so noticed that ↵Kostya Serebryany2018-09-045-14/+14
| | | | | | GetThreadStackAndTls was always called with 'at_initialization=true', fixed that. llvm-svn: 341431
* [hwasan] add a unique id to a thread and add debug prints for thread ↵Kostya Serebryany2018-09-043-0/+16
| | | | | | creation/destruction llvm-svn: 341428
* [hwasan] Fix new[] with zero size.Evgeniy Stepanov2018-08-311-9/+10
| | | | | | | Fixes "allocator is out of memory trying to allocate 0x0 bytes" by always allocating at least one byte. llvm-svn: 341229
* [hwasan] move code around to remove an opaque class definition ↵Kostya Serebryany2018-08-312-51/+47
| | | | | | (HwasanThreadLocalMallocStorage) that had incorrect size and used 10x more than needed RAM (500K instead of 50K per thread) llvm-svn: 341170
* [hwasan] simplify the code, NFCKostya Serebryany2018-08-312-17/+6
| | | | llvm-svn: 341166
* [hwasan] report heap-buffer-overflow location, once, not once per each live ↵Kostya Serebryany2018-08-311-41/+41
| | | | | | thread llvm-svn: 341160
* [hwasan] properly report heap-buffer-overflowKostya Serebryany2018-08-312-6/+51
| | | | llvm-svn: 341159
* [hwasan] fix the build on Linux Ubuntu 14.04. We don't need __hwasan_shadow ↵Kostya Serebryany2018-08-311-0/+11
| | | | | | on Linux at all llvm-svn: 341158
* [hwasan] make malloc(0) return nullptr, add basic address description for ↵Kostya Serebryany2018-08-312-0/+7
| | | | | | stack addresses llvm-svn: 341156
* [hwasan] fix the linux-only pthread_create interceptor and reinstate the two ↵Kostya Serebryany2018-08-302-12/+14
| | | | | | threaded tests llvm-svn: 341143
* [hwasan] use thread-local ring buffers to properly report heap-use-after-freeKostya Serebryany2018-08-305-63/+51
| | | | llvm-svn: 341133
* [hwasan] simplify the thread hangling: instead of the ThreadRegistry (too ↵Kostya Serebryany2018-08-306-84/+53
| | | | | | heavy) simply maintain a linked list of Threads llvm-svn: 341111
* [hwasan] add a simple threaded UAF test, make it work on x86 (need to ↵Kostya Serebryany2018-08-304-4/+21
| | | | | | disable tagging in malloc with inside pthread_create) llvm-svn: 341007
* [hwasan] add basic ThreadRegistry plumbing, also rename HwasanThread to ThreadKostya Serebryany2018-08-307-40/+107
| | | | llvm-svn: 341005
* [hwasan] remove even more stale codeKostya Serebryany2018-08-292-33/+6
| | | | llvm-svn: 340989
* [hwasan] remove more stale codeKostya Serebryany2018-08-293-57/+27
| | | | llvm-svn: 340985
* [hwasan] get rid of some macros, remove the fixed shadow mappingKostya Serebryany2018-08-298-60/+40
| | | | llvm-svn: 340983
* [hwasan] formatting change, NFCKostya Serebryany2018-08-299-10/+13
| | | | llvm-svn: 340980
* [hwasan] rename some variables and functions for better readability, NFCKostya Serebryany2018-08-294-51/+54
| | | | llvm-svn: 340979
* [hwasan] simplify the realloc implementation: always allocate/deallocate on ↵Kostya Serebryany2018-08-292-28/+7
| | | | | | realloc. This may slowdown some realloc-heavy code, but at least at this point a want simpler code. Also added a test llvm-svn: 340973
* Add a thread-local ring buffer of heap allocationsKostya Serebryany2018-08-296-4/+60
| | | | | | | | | | | | | | | | | | Summary: We need this in order to properly report heap-use-after-free, since we don't have a quarantine. This is a first part of the code, more like a proof of concept. But I'd like to commit at as is and proceed with refactoring, adding a ThreadRegistry, and extending the functionality. Reviewers: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D51394 llvm-svn: 340971
* [sanitizer] Revert D50940Kostya Kortchinsky2018-08-291-1/+1
| | | | | | | | | | | | | | | | | Summary: The previous version of the patch makes some code unable to distinguish failure to map address 0 and error. Revert to turn the bots back to green while figuring out a new approach. Reviewers: eugenis Reviewed By: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D51451 llvm-svn: 340957
* [hwasan] implement detection of realloc-after-freeKostya Serebryany2018-08-241-1/+5
| | | | llvm-svn: 340593
* [hwasan] implement detection of double-free (invalid-free)Kostya Serebryany2018-08-243-21/+64
| | | | llvm-svn: 340591
* [sanitizer] Change Mmap*NoAccess to return nullptr on errorKostya Kortchinsky2018-08-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: `MmapNoAccess` & `MmapFixedNoAccess` return directly the result of `internal_mmap`, as opposed to other Mmap functions that return nullptr. This inconsistency leads to some confusion for the callers, as some check for `~(uptr)0` (`MAP_FAILED`) for failure (while it can fail with `-ENOMEM` for example). Two potential solutions: change the callers, or make the functions return `nullptr` on failure to follow the precedent set by the other functions. The second option looked more appropriate to me. Correct the callers that were wrongly checking for `~(uptr)0` or `MAP_FAILED`. TODO for follow up CLs: - There are a couple of `internal_mmap` calls in XRay that check for MMAP_FAILED as a result as well (cc: @dberris); they should use `internal_iserror`; Reviewers: eugenis, alekseyshl, dberris, kubamracek Reviewed By: alekseyshl Subscribers: kristina, kubamracek, delcypher, #sanitizers, dberris, llvm-commits Differential Revision: https://reviews.llvm.org/D50940 llvm-svn: 340576
* [hwasan] make error reporting look more like in asan, print the memory tag ↵Kostya Serebryany2018-08-221-6/+32
| | | | | | around the buggy access, simplify one test llvm-svn: 340470
* [hwasan] remove stale data fieldKostya Serebryany2018-08-221-1/+0
| | | | llvm-svn: 340442
* [hwasan] Add a (almost) no-interceptor mode.Evgeniy Stepanov2018-08-208-183/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The idea behind this change is to allow sanitization of libc. We are prototyping on Bionic, but the tool interface will be general enough (or at least generalizable) to support any other libc. When libc depends on libclang_rt.hwasan, the latter can not interpose libc functions. In fact, majority of interceptors become unnecessary when libc code is instrumented. This change gets rid of most hwasan interceptors and provides interface for libc to notify hwasan about thread creation and destruction events. Some interceptors (pthread_create) are kept under #ifdef to enable testing with uninstrumented libc. They are expressed in terms of the new libc interface. The new cmake switch, COMPILER_RT_HWASAN_WITH_INTERCEPTORS, ON by default, builds testing version of the library with the aforementioned pthread_create interceptor. With the OFF setting, the library becomes more of a libc plugin. Reviewers: vitalybuka, kcc, jfb Subscribers: srhines, kubamracek, mgorny, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D50922 llvm-svn: 340216
* Revert "Revert "[hwasan] Add __hwasan_handle_longjmp.""Evgeniy Stepanov2018-08-163-7/+41
| | | | | | | | | | | This reapplies commit r339935 with the following changes: * make longjmp test C, not C++, to avoid dependency on libc++/libstdc++ * untag pointer in memset interceptor x86_64 does not have TBI, so hwasan barely works there. Tests must be carefully written in a way that does not leak tagged pointer to system libraries. llvm-svn: 339963
* Revert "[hwasan] Add __hwasan_handle_longjmp."Evgeniy Stepanov2018-08-162-21/+0
| | | | | | This reverts commit 339935 which breaks hwasan tests on x86_64. llvm-svn: 339957
* [hwasan] Enable Android logging.Evgeniy Stepanov2018-08-161-0/+3
| | | | | | | | | | | | Summary: Enable syslog as soon as the shadow is mapped. Reviewers: vitalybuka, kcc Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D50865 llvm-svn: 339950
* [hwasan] Add __hwasan_handle_longjmp.Evgeniy Stepanov2018-08-162-0/+21
| | | | | | | | | | | | | | | | | Summary: A callback to annotate longjmp-like code. Unlike __asan_handle_no_return, in hwasan we can not conservatively "unpoison" the entire thread stack, because there is no such thing as unpoisoned memory. Pointer and memory tags must always match. Reviewers: vitalybuka, kcc Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D50752 llvm-svn: 339935
* [hwasan] Add malloc_fill_byte and free_fill_byte flags.Evgeniy Stepanov2018-08-162-1/+22
| | | | | | | | | | Reviewers: vitalybuka, kcc Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D50753 llvm-svn: 339932
* [hwasan] Add a basic API.Evgeniy Stepanov2018-08-152-3/+15
| | | | | | | | | | | | | | | | Summary: Add user tag manipulation functions: __hwasan_tag_memory __hwasan_tag_pointer __hwasan_print_shadow (very simple and ugly, for now) Reviewers: vitalybuka, kcc Subscribers: kubamracek, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D50746 llvm-svn: 339746
* [hwasan] Provide __sanitizer_* aliases to allocator functions.Evgeniy Stepanov2018-08-131-2/+21
| | | | | | | | | | | | | | | | Summary: Export __sanitizer_malloc, etc as aliases to malloc, etc. This way users can wrap sanitizer malloc, even in fully static binaries. Both jemalloc and tcmalloc provide similar aliases (je_* and tc_*). Reviewers: vitalybuka, kcc Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D50570 llvm-svn: 339614
* [hwasan] Handle missing /proc/self/maps.Evgeniy Stepanov2018-08-131-7/+20
| | | | | | | | | | | | | | Summary: Don't crash when /proc/self/maps is inaccessible from main thread. It's not a big deal, really. Reviewers: vitalybuka, kcc Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D50574 llvm-svn: 339607
OpenPOWER on IntegriCloud