summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/asan_malloc_linux.cc
Commit message (Collapse)AuthorAgeFilesLines
* compiler-rt: Rename .cc file in lib/asan to .cppNico Weber2019-08-011-307/+0
| | | | | | Like r367463, but for asan. llvm-svn: 367558
* [sanitizer] Implement reallocarray.Evgeniy Stepanov2019-05-011-0/+8
| | | | | | | | | | | | | | | | Summary: It's a cross of calloc and realloc. Sanitizers implement calloc-like check for size overflow. Reviewers: vitalybuka, kcc Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61108 llvm-svn: 359708
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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
* [sanitizer] Fix mallopt interceptor.Evgeniy Stepanov2018-10-251-1/+1
| | | | | | On error, mallopt is supposed to return 0, not -1. llvm-svn: 345323
* [ASAN] fix typos and disable long-object-path test for win32Peter Wu2018-06-141-2/+2
| | | | | | | | Glob patterns seem unsupported for commands executed by the emulated shell (LIT_USE_INTERNAL_SHELL=1). Disable the test while that is being addressed (a workaround such as "cd a-*" also does not work). llvm-svn: 334719
* [ASAN] fix startup crash in dlsym for long paths since glibc 2.27Peter Wu2018-06-141-1/+18
| | | | | | | | | | | | | | | | | | | | Summary: Error messages for dlsym used to be stored on the stack, but since commit 2449ae7b ("ld.so: Introduce struct dl_exception") in glibc 2.27 these are now stored on the heap (and thus use the dlsym alloc pool). Messages look like "undefined symbol: __isoc99_printf\0/path/to/a.out". With many missing library functions and long object paths, the pool is quickly exhausted. Implement a simple mechanism to return freed memory to the pool (clear it in case it is used for calloc). Fixes https://github.com/google/sanitizers/issues/957 Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D47995 llvm-svn: 334703
* [asan, myriad] Use local pool for new/delete when ASan run-time is not upWalter Lee2018-06-081-4/+12
| | | | | | | | This can happen on Myriad RTEMS so needs to be handled. Differential Revision: https://reviews.llvm.org/D47916 llvm-svn: 334329
* [Sanitizers] Check alignment != 0 for aligned_alloc and posix_memalignAlex Shlyapnikov2018-06-081-1/+1
| | | | | | | | | | | | | | | Summary: Move the corresponding tests to the common folder (as all of the sanitizer allocators will support this feature soon) and add the checks specific to aligned_alloc to ASan and LSan allocators. Reviewers: vitalybuka Subscribers: srhines, kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D47924 llvm-svn: 334316
* [asan, myriad] Implement aligned local pool allocationWalter Lee2018-06-011-1/+25
| | | | | | | | Extend the local pool allocation support to posix_memalign. Differential Revision: https://reviews.llvm.org/D47642 llvm-svn: 333788
* [asan, myriad] Configure platform interceptorsWalter Lee2018-06-011-0/+2
| | | | | | | | | | | Myriad only uses the platform interceptors for memory allocation routines. Configure them properly. Also add a missing guard around aligned alloc interceptor. Differential Revision: https://reviews.llvm.org/D47641 llvm-svn: 333784
* [asan] Port asan_malloc_linux.cc to RTEMSWalter Lee2018-05-071-6/+16
| | | | | | | | | | | | We reuse the allocation interceptors as is. RTEMS doesn't support dlsyms. However, it needs to handle memory allocation requests before the ASan run-time has been initialized. We use the dlsym alloc pool for this purpose, and we increase its size to 4k to support this usage. Differential Revision: https://reviews.llvm.org/D46465 llvm-svn: 331649
* [Sanitizers] Basic sanitizer Solaris support (PR 33274)Kamil Rytarowski2017-12-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is the first mostly working version of the Sanitizer port to 32-bit Solaris/x86. It is currently based on Solaris 11.4 Beta. This part was initially developed inside libsanitizer in the GCC tree and should apply to both. Subsequent parts will address changes to clang, the compiler-rt build system and testsuite. I'm not yet sure what the right patch granularity is: if it's profitable to split the patch up, I'd like to get guidance on how to do so. Most of the changes are probably straightforward with a few exceptions: * The Solaris syscall interface isn't stable, undocumented and can change within an OS release. The stable interface is the libc interface, which I'm using here, if possible using the internal _-prefixed names. * While the patch primarily target 32-bit x86, I've left a few sparc changes in. They cannot currently be used with clang due to a backend limitation, but have worked fine inside the gcc tree. * Some functions (e.g. largefile versions of functions like open64) only exist in 32-bit Solaris, so I've introduced a separate SANITIZER_SOLARIS32 to check for that. The patch (with the subsequent ones to be submitted shortly) was tested on i386-pc-solaris2.11. Only a few failures remain, some of them analyzed, some still TBD: AddressSanitizer-i386-sunos :: TestCases/Posix/concurrent_overflow.cc AddressSanitizer-i386-sunos :: TestCases/init-order-atexit.cc AddressSanitizer-i386-sunos :: TestCases/log-path_test.cc AddressSanitizer-i386-sunos :: TestCases/malloc-no-intercept.c AddressSanitizer-i386-sunos-dynamic :: TestCases/Posix/concurrent_overflow.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/Posix/start-deactivated.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/default_options.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/init-order-atexit.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/log-path_test.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/malloc-no-intercept.c SanitizerCommon-Unit :: ./Sanitizer-i386-Test/MemoryMappingLayout.DumpListOfModules SanitizerCommon-Unit :: ./Sanitizer-i386-Test/SanitizerCommon.PthreadDestructorIterations Maybe this is good enough the get the ball rolling. Reviewers: kcc, alekseyshl Reviewed By: alekseyshl Subscribers: srhines, jyknight, kubamracek, krytarowski, fedor.sergeev, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40898 llvm-svn: 320740
* Try to appease compiler and break multiline comment.Kamil Rytarowski2017-08-081-2/+2
| | | | llvm-svn: 310428
* Add NetBSD support in asan_malloc_linux.ccKamil Rytarowski2017-08-081-2/+4
| | | | | | | | | | | | | | | | | | | Summary: Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, fjricci, vitalybuka, filcab Reviewed By: fjricci Subscribers: llvm-commits, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36376 llvm-svn: 310414
* [asan] Restore dead-code-elimination optimization for FuchsiaVitaly Buka2017-08-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: r310244 fixed a bug introduced by r309914 for non-Fuchsia builds. In doing so it also reversed the intended effect of the change for Fuchsia builds, which was to allow all the AllocateFromLocalPool code and its variables to be optimized away entirely. This change restores that optimization for Fuchsia builds, but doesn't have the original change's bug because the comparison arithmetic now takes into account the size of the elements. Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36430 llvm-svn: 310330
* [asan] Return sizeof missed by r309914Vitaly Buka2017-08-071-1/+1
| | | | llvm-svn: 310244
* [asan] Allocator support for FuchsiaVitaly Buka2017-08-031-21/+29
| | | | | | | | | | | | | | | | Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl, kcc Reviewed By: alekseyshl Subscribers: srhines, cryptoad, kubamracek, phosek, filcab, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36190 llvm-svn: 309914
* [asan] Fix ASan internal failure in AllocateFromLocalPoolMaxim Ostapenko2017-06-091-8/+14
| | | | | | | | | | | | | | This patch addresses PR 33206. There might be a situation when dynamic ASan runtime initializes later than shared library which has malloc in static constructor (rtld doesn't provide an order of shared libs initialization). In this case ASan hasn't yet initialized interceptors, but already intercepts malloc. If malloc is too big to be handled by static local pool, ASan will die with error: Sanitizer CHECK failed: lib/asan/asan_malloc_linux.cc:40 ((allocated_for_dlsym)) < ((kDlsymAllocPoolSize)) (1036, 1024) Patch by Denis Khalikov. Differential Revision: https://reviews.llvm.org/D33784 llvm-svn: 305058
* Recommit: Stop intercepting some malloc-related functions on FreeBSD andDimitry Andric2017-01-301-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | macOS Summary: In https://bugs.freebsd.org/215125 I was notified that some configure scripts attempt to test for the Linux-specific `mallinfo` and `mallopt` functions by compiling and linking small programs which references the functions, and observing whether that results in errors. FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so normally these tests would fail, but when sanitizers are enabled, they incorrectly succeed, because the sanitizers define interceptors for these functions. This also applies to some other malloc-related functions, such as `memalign`, `pvalloc` and `cfree`. Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`, `pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers. Also delete the non-functional `cfree` wrapper for Windows, to fix the test cases on that platform. Reviewers: emaste, kcc, rnk Subscribers: timurrrr, eugenis, hans, joerg, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D27654 llvm-svn: 293536
* Revert "Stop intercepting some malloc-related functions on FreeBSD and macOS"Evgeniy Stepanov2017-01-271-13/+5
| | | | | | | | This reverts r293337, which breaks tests on Windows: malloc-no-intercept-499eb7.o : error LNK2019: unresolved external symbol _mallinfo referenced in function _main llvm-svn: 293346
* Stop intercepting some malloc-related functions on FreeBSD and macOSDimitry Andric2017-01-271-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: In https://bugs.freebsd.org/215125 I was notified that some configure scripts attempt to test for the Linux-specific `mallinfo` and `mallopt` functions by compiling and linking small programs which references the functions, and observing whether that results in errors. FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so normally these tests would fail, but when sanitizers are enabled, they incorrectly succeed, because the sanitizers define interceptors for these functions. This also applies to some other malloc-related functions, such as `memalign`, `pvalloc` and `cfree`. Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`, `pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers. Reviewers: emaste, kcc Subscribers: hans, joerg, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D27654 llvm-svn: 293337
* [asan, msan] Fix reallocation logic when IsInDlsymAllocPool(ptr) is true.Maxim Ostapenko2016-09-261-3/+5
| | | | llvm-svn: 282389
* [msan] Prevent initialization failure with newer (2.23+) glibc in use.Maxim Ostapenko2016-09-231-1/+5
| | | | | | | | | | This patch is pretty the same as http://reviews.llvm.org/D20235 that we used for ASan. Using the same hack for MSan fixes its initialization with newer Glibc in use. Differential Revision: https://reviews.llvm.org/D24736 llvm-svn: 282232
* [asan] Fix asan initialization failure with newer (2.23+) glibc in use.Maxim Ostapenko2016-05-161-18/+24
| | | | | | | | | | This patch tries to fix https://llvm.org/bugs/show_bug.cgi?id=27310 by using the same hack for malloc as we use for calloc: allocate corresponding memory from internal buffer when ASan is not initialized. This way we could avoid nasty '==6987==AddressSanitizer CHECK failed: ../../../../libsanitizer/asan/asan_rtl.cc:556 "((!asan_init_is_running && "ASan init calls itself!")) != (0)" (0x0, 0x0)' errors in environments with glibc 2.23+ in use, where _dl_signal_error, called from dlsym for undefined symbols calls malloc in order to get a buffer for error message. Differential Revision: http://reviews.llvm.org/D20235 llvm-svn: 269633
* [Sanitizer] Pass proper values to DTLS_on_libc_memalign.Alexey Samsonov2016-01-141-1/+1
| | | | | | | Fix a surprising typo: the old code used to think that dynamic TLS segments were several times larger than they actually are. llvm-svn: 257722
* [asan] Correctly release memory allocated during early startup.Yury Gribov2015-12-011-2/+19
| | | | | | | | | | Calloc interceptor initially allocates memory from temp buffer (to serve dlsyms called during asan_init). There is a chance that some non-instrumented library (or executable) has allocated memory with calloc before asan_init and got pointer from the same temporary buffer which later caused problems with free. Inspired by https://github.com/google/sanitizers/issues/626 Differential Revision: http://reviews.llvm.org/D14979 llvm-svn: 254395
* [asan] Remove leftover debug printf.Evgeniy Stepanov2014-07-171-1/+0
| | | | llvm-svn: 213264
* [asan] Fix malloc interception on Android L Preview.Evgeniy Stepanov2014-07-171-39/+61
| | | | | | | | Format of __libc_malloc_dispatch has changed in Android L. While we are moving towards a solution that does not depend on bionic internals, here is something to support both K* and L releases. llvm-svn: 213263
* [sanitizer] support c11 aligned_alloc, Linux only for nowKostya Serebryany2014-07-041-0/+5
| | | | llvm-svn: 212322
* [asan] Add malloc_usable_size to android malloc dispatch.Evgeniy Stepanov2014-06-091-8/+10
| | | | llvm-svn: 210452
* [asan] Make ReplaceSystemMalloc optional on Android.Evgeniy Stepanov2014-06-061-5/+7
| | | | | | | Don't fail if __libc_malloc_dispatch is missing; continue running with normal linux interceptors instead. llvm-svn: 210322
* [asan] use some LIKELY/UNLIKELYKostya Serebryany2014-05-141-1/+1
| | | | llvm-svn: 208776
* A set of trivial changes to support sanitizers on FreeBSD.Alexey Samsonov2014-03-041-2/+2
| | | | | | Patch by Viktor Kutuzov! llvm-svn: 202801
* [asan] experimental intercetor for __tls_get_addr. So far it does nothing ↵Kostya Serebryany2014-01-291-2/+7
| | | | | | interesting, actual usage will come later. See https://groups.google.com/forum/#!topic/address-sanitizer/BfwYD8HMxTM for background llvm-svn: 200384
* [ASan] Do not rely on malloc context in allocator reports.Alexey Samsonov2013-11-131-2/+3
| | | | | | | | | | | Invoke a fatal stack trace unwinder when ASan prints allocator-relevant error reports (double-free, alloc-dealloc-mismatch, invalid-free). Thus we'll be able to print complete stack trace even if allocation/free stacks are not stored (malloc_context_size=0). Based on the patch by Yuri Gribov! llvm-svn: 194579
* [ASan] Kill the remainders of platform defines in favor of SANITIZER_ definesAlexey Samsonov2013-04-031-1/+1
| | | | llvm-svn: 178629
* [ASan] Switch ASan to generic ThreadRegistry from sanitizer_common. Delete ↵Alexey Samsonov2013-03-211-1/+0
| | | | | | ASan-specific AsanThreadRegistry. llvm-svn: 177634
* [sanitizer] Replace more platform checks with SANITIZER_ constants.Evgeniy Stepanov2013-03-191-1/+3
| | | | llvm-svn: 177400
* [sanitizer] Move ASan platform macros to sanitizer_common and rename them ↵Evgeniy Stepanov2013-03-191-1/+1
| | | | | | appropriately. llvm-svn: 177397
* [ASan] Split ASan interface header into private and public parts. Add a test ↵Alexey Samsonov2013-01-311-1/+0
| | | | | | that makes sure users can include interface header llvm-svn: 174058
* [asan] asan_allocator2: do not align the requested size to the redzone size ↵Kostya Serebryany2012-12-261-3/+2
| | | | | | (saves a bit more memory) llvm-svn: 171111
* [asan] add a flag alloc_dealloc_mismatch (off by default for now) which ↵Kostya Serebryany2012-12-211-3/+3
| | | | | | finds malloc/delete, new/free, new/delete[], etc mismatches llvm-svn: 170869
* [asan] add a flag poison_heap to allow better allocator benchmarking, ↵Kostya Serebryany2012-12-201-0/+7
| | | | | | implemenet malloc_stats() on Linux llvm-svn: 170685
* [asan] add two asan flags: fast_unwind_on_fatal and fast_unwind_on_malloc to ↵Kostya Serebryany2012-12-131-10/+10
| | | | | | allow using the slow CFI-based unwinder llvm-svn: 170117
* [ASan] fix interception macro for Android buildAlexey Samsonov2012-09-121-5/+5
| | | | llvm-svn: 163692
* A few tweaks for building ASanRT against Android NDK.Evgeniy Stepanov2012-08-271-1/+1
| | | | llvm-svn: 162666
* [ASan] fix names of malloc/free replacements on AndroidAlexey Samsonov2012-08-061-1/+7
| | | | llvm-svn: 161322
* [asan] get rid of '#include <malloc.h>' in the implementation of malloc ↵Kostya Serebryany2012-06-251-20/+26
| | | | | | interceptors llvm-svn: 159132
* Lots of trivial changes to remove extraneous semicolons throughout ASan.Chandler Carruth2012-06-251-1/+1
| | | | llvm-svn: 159128
* Remove file-type tags for .cc files in ASan run-time libraryAlexey Samsonov2012-06-041-1/+1
| | | | llvm-svn: 157927
OpenPOWER on IntegriCloud