summaryrefslogtreecommitdiff
path: root/lib/asan/asan_linux.cc
AgeCommit message (Collapse)Author
2017-11-20[asan] Use dynamic shadow on 32-bit Android, try 2.Evgeniy Stepanov
Summary: This change reverts r318575 and changes FindDynamicShadowStart() to keep the memory range it found mapped PROT_NONE to make sure it is not reused. We also skip MemoryRangeIsAvailable() check, because it is (a) unnecessary, and (b) would fail anyway. Reviewers: pcc, vitalybuka, kcc Subscribers: srhines, kubamracek, mgorny, llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D40203 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318666 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-18Revert "[asan] Use dynamic shadow on 32-bit Android" and 3 more.Evgeniy Stepanov
Revert the following commits: r318369 [asan] Fallback to non-ifunc dynamic shadow on android<22. r318235 [asan] Prevent rematerialization of &__asan_shadow. r317948 [sanitizer] Remove unnecessary attribute hidden. r317943 [asan] Use dynamic shadow on 32-bit Android. MemoryRangeIsAvailable() reads /proc/$PID/maps into an mmap-ed buffer that may overlap with the address range that we plan to use for the dynamic shadow mapping. This is causing random startup crashes. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318575 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-16[asan] Fallback to non-ifunc dynamic shadow on android<22.Evgeniy Stepanov
Summary: Android < 22 does not support ifunc. Reviewers: pcc Subscribers: srhines, kubamracek, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D40116 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318369 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-10[asan] Use dynamic shadow on 32-bit Android.Evgeniy Stepanov
Summary: The following kernel change has moved ET_DYN base to 0x4000000 on arm32: https://marc.info/?l=linux-kernel&m=149825162606848&w=2 Switch to dynamic shadow base to avoid such conflicts in the future. Reserve shadow memory in an ifunc resolver, but don't use it in the instrumentation until PR35221 is fixed. This will eventually let use save one load per function. Reviewers: kcc Subscribers: aemerson, srhines, kubamracek, kristof.beyls, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D39393 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317943 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-24On FreeBSD, skip the first entry in the dl_iterate_phdr list.Dimitry Andric
Summary: Similar to NetBSD, in FreeBSD, the first returned entry when callbacks are done via dl_iterate_phdr will return the main program. Ignore that entry when checking that the dynamic ASan lib is loaded first. Reviewers: eugenis, krytarowski, emaste, joerg Reviewed By: eugenis, krytarowski Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D39253 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316487 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-10Add NetBSD support in asan_linux.ccKamil Rytarowski
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: fjricci, vitalybuka, joerg, kcc, filcab Reviewed By: vitalybuka Subscribers: llvm-commits, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36488 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310647 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-12[asan] For iOS/AArch64, if the dynamic shadow doesn't fit, restrict the VM spaceKuba Mracek
On iOS/AArch64, the address space is very limited and has a dynamic maximum address based on the configuration of the device. We're already using a dynamic shadow, and we find a large-enough "gap" in the VM where we place the shadow memory. In some cases and some device configuration, we might not be able to find a large-enough gap: E.g. if the main executable is linked against a large number of libraries that are not part of the system, these libraries can fragment the address space, and this happens before ASan starts initializing. This patch has a solution, where we have a "backup plan" when we cannot find a large-enough gap: We will restrict the address space (via MmapFixedNoAccess) to a limit, for which the shadow limit will fit. Differential Revision: https://reviews.llvm.org/D35098 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307865 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-11Refactor MemoryMappingLayout::Next to use a single struct instead of output ↵Francis Ricci
parameters. NFC. Summary: This is the first in a series of patches to refactor sanitizer_procmaps to allow MachO section information to be exposed on darwin. In addition, grouping all segment information in a single struct is cleaner than passing it through a large set of output parameters, and avoids the need for annotations of NULL parameters for unneeded information. The filename string is optional and must be managed and supplied by the calling function. This is to allow the MemoryMappedSegment struct to be stored on the stack without causing overly large stack sizes. Reviewers: alekseyshl, kubamracek, glider Subscribers: emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D35135 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@307688 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-31[asan] Move AsanCheckDynamicRTPrereqs check under flagMaxim Ostapenko
The patch addresses https://github.com/google/sanitizers/issues/786. Currently AsanCheckDynamicRTPrereqs prevents dynamic ASan runtime from running in some important environments e.g. cowbuilder and fakeroot that may also work with interposition. Let's allow users to switch off the check given that they know what they do. Differential Revision: https://reviews.llvm.org/D31420 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299188 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-21[compiler-rt][asan] Add support for desallocation of unhandled pointersEtienne Bergeron
Summary: On windows 10, the ucrt DLL is performing allocations before the function hooking and there are multiple allocations not handled by Asan. When a free occur at the end of the process, asan is reporting desallocations not malloc-ed. Reviewers: rnk, kcc Reviewed By: rnk, kcc Subscribers: kcc, llvm-commits, kubamracek, chrisha, dberris Differential Revision: https://reviews.llvm.org/D25946 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295730 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11[asan] Add exception handler to map memory on demand on Win64.Etienne Bergeron
Memory will be committed on demand when exception happens while accessing shadow memeory region. Patch by: Wei Wang Differential Revision: http://reviews.llvm.org/D21942 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275107 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-28[asan] Add runtime support for __asan_(un)register_image_globalsRyan Govostes
This change introduces routines that register and unregister all instrumented globals in a loaded executable image. These routines are only implemented on Darwin, where globals metadata is expected to be placed in the __DATA,__asan_globals section. Review: http://reviews.llvm.org/D16841 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264644 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-03[tsan] Use re-exec method to enable interceptors on older versions of OS XKuba Brecka
In AddressSanitizer, we have the MaybeReexec method to detect when we're running without DYLD_INSERT_LIBRARIES (in which case interceptors don't work) and re-execute with the environment variable set. On OS X 10.11+, this is no longer necessary, but to have ThreadSanitizer supported on older versions of OS X, let's use the same method as well. This patch moves the implementation from `asan/` into `sanitizer_common/`. Differential Revision: http://reviews.llvm.org/D15123 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254600 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01[compiler-rt] Apply modernize-use-nullptr fixes in sanitizersVedant Kumar
- Trim spaces. - Use nullptr in place of 0 for pointer variables. - Use '!p' in place of 'p == 0' for null pointer checks. - Add blank lines to separate function definitions. - Add 'extern "C"' or 'namespace foo' comments after the appropriate closing brackets This is a continuation of work from 409b7b82. The focus here is on the various sanitizers (not sanitizer_common, as before). Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13225 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248966 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21[asan] Remove AsanPlatformThreadInitReid Kleckner
Since the CoreFoundation allocator replacement was moved in r173134, all implementations of this function have been empty. Reviewers: samsonov Differential Revision: http://reviews.llvm.org/D11375 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242811 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-04[ASan] Move ASan runtime library self-checks to a more appropriate place.Yury Gribov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@239018 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16[ASan] NFC: Factor out platform-specific interceptorsTimur Iskhodzhanov
Reviewed at http://reviews.llvm.org/D8321 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@232377 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-02asan: fix signal handling during stoptheworldDmitry Vyukov
The problem is that without SA_RESTORER flag, kernel ignores the handler. So tracer actually did not setup any handler. Add SA_RESTORER flag when setting up handlers. Add a test that causes SIGSEGV in stoptheworld callback. Move SignalContext from asan to sanitizer_common to print better diagnostics about signal in the tracer thread. http://reviews.llvm.org/D8005 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230978 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-10Fix ASan's Noinst unit testsKuba Brecka
We currently skip all "Noinst" unit tests on OS X, which was probably caused when we removed the "allow_reexec" flag. The MaybeReexec function fails to re-execute when the runtime is linked statically, because there is no dylib to use. This patch adds an explicit DisableReexec function that is used from asan_noinst_test.cc and the runtime then doesn't try to re-execute. Reviewed at http://reviews.llvm.org/D7493 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228740 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09Remove AsanInterceptsSignal in favor of (equivalent) IsDeadlySignal.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225556 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-15Fix getting IP, BP and SP for address sanitizer's needs on FreeBSD in 32-bit ↵Viktor Kutuzov
mode git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210988 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-06[asan] Make ReplaceSystemMalloc optional on Android.Evgeniy Stepanov
Don't fail if __libc_malloc_dispatch is missing; continue running with normal linux interceptors instead. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210322 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-02[asan] Improve vDSO check in AsanCheckDynamicRTPrereqs; patch by Yuri GribovKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210012 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-30[asan] Enable ASan on PowerPC.Evgeniy Stepanov
Patch by Peter Bergner. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209879 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-09Declare _DYNAMIC and dl_phdr_info in asan_linux.cc on FreeBSDViktor Kutuzov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205852 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-02[ASan] Fix incompatible runtimes check: don't iterate /proc/self/maps on ↵Alexey Samsonov
every call to __asan_init git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205418 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-02[ASan] One more attempt to fix Android buildAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205411 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-01[ASan] Fix Android buildAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205311 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-01[ASan] Optional support for dynamic ASan runtime on Linux.Alexey Samsonov
Based on http://llvm-reviews.chandlerc.com/D3042 by Yuri Gribov! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205308 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-12Add FreeBSD 9.2 support to asan_linux.ccViktor Kutuzov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@203658 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06[FreeBSD] Provide FreeBSD-specific things for ASan.Alexey Samsonov
Patch by Viktor Kutuzov! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@203100 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-04[ASan] Speed up stack trace unwinding for stacks of size 2.Alexey Samsonov
Summary: We don't need to do any work in this case - just take the current PC and caller PC. Reviewers: eugenis, ygribov Reviewed By: eugenis CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2936 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202845 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-13[sanitizer] AArch64 sanitizer support; patch by Christophe Lyon and Yvan RouxKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201303 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-10Add a copy of missing <ucontext.h> for Android and enable ASan SEGV handler.Evgeniy Stepanov
This change adds a copy of <ucontext.h> for Android found in google-breakpad that is missing from the official NDK. ASan SEGV handler is still disabled by default and can be enabled with ASAN_OPTIONS=handle_segv. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201084 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-28[ASan] Move the signal handling-related flags to sanitizer_common.Alexander Potapenko
This change is a part of refactoring intended to have common signal handling behavior in all tools. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200295 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-09Revert three patches which were committed without explicit contributionChandler Carruth
by their authors. This may break builds where others added code relying on these patches, but please *do not* revert this commit. Instead, we will prepare patches which fix the failures. Reverts the following commits: r168306: "[asan] support x32 mode in the fast stack unwinder. Patch by H.J. Lu" r168356: "[asan] more support for powerpc, patch by Peter Bergner" r196489: "[sanitizer] fix the ppc32 build (patch by Jakub Jelinek)" git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196802 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-18[asan] support __hppa__ (by John David Anglin)Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194995 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-03[asan] ASan Linux MIPS32 support (compiler-rt part), patch by Jyun-Yan YKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@183105 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-08[sanitizer] Move GetStackTrace from ASan to sanitizer_common.Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@181424 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03[ASan] Kill the remainders of platform defines in favor of SANITIZER_ definesAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178629 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-21[ASan] Switch ASan to generic ThreadRegistry from sanitizer_common. Delete ↵Alexey Samsonov
ASan-specific AsanThreadRegistry. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177634 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-20[ASan] Move GetCurrentThread/SetCurrentThread from AsanThreadRegistry class ↵Alexey Samsonov
into plain functions: they don't actually use registry git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177501 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-19[sanitizer] Replace more platform checks with SANITIZER_ constants.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177400 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-19[sanitizer] Move ASan platform macros to sanitizer_common and rename them ↵Evgeniy Stepanov
appropriately. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177397 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18[ASan] fixes for Android buildAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172800 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-17[ASan] minor changes to swapcontext handling: don't clear shadow memory if ↵Alexey Samsonov
context stack is too large git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172727 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-14asan/tsan: move blocking mutex from asan to sanitizer_commonDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172380 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-13[asan] pop the internal stack frames in SlowUnwindStack, extend the test to ↵Kostya Serebryany
check this git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170124 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-13[asan] add two asan flags: fast_unwind_on_fatal and fast_unwind_on_malloc to ↵Kostya Serebryany
allow using the slow CFI-based unwinder git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170117 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-03[asan] two more bits for __sparc__Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169141 91177308-0d34-0410-b5e6-96231b3b80d8