summaryrefslogtreecommitdiff
path: root/lib/asan/asan_mapping.h
AgeCommit message (Collapse)Author
2017-12-07[PowerPC][asan] Update asan to handle changed memory layouts in newer kernelsBill Seurer
In more recent Linux kernels with 47 bit VMAs the layout of virtual memory for powerpc64 changed causing the address sanitizer to not work properly. This patch adds support for 47 bit VMA kernels for powerpc64 and fixes up test cases. https://reviews.llvm.org/D40908 There is an associated patch for trunk. Tested on several 4.x and 3.x kernel releases. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320110 91177308-0d34-0410-b5e6-96231b3b80d8
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] Fix small X86_64 ShadowOffset for non-default shadow scaleWalter Lee
The requirement is that shadow memory must be aligned to page boundaries (4k in this case). Use a closed form equation that always satisfies this requirement. Differential Revision: https://reviews.llvm.org/D39471 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318421 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-13[asan] Add CMake hook to override shadow scale in compiler_rtWalter Lee
Allow user to override shadow scale in compiler_rt by passing -DCOMPILER_RT_ASAN_SHADOW_SCALE=n to CMake. Propagate the override shadow scale value via a compiler define to compiler-rt and asan tests. Tests will use the define to partially disable unsupported tests. Set "-mllvm -asan-mapping-scale=<n>" for compiler_rt tests. Differential Revision: https://reviews.llvm.org/D39469 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318038 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-08-28Add NetBSD ASAN shadow mapping for x86-64Kamil Rytarowski
Summary: The maximal virtual address on NetBSD/amd64 is 0x7f7ffffff000. Define shadow offset 0x400000000000 (1ULL << 46). Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, filcab, fjricci, kcc, eugenis, pcc Reviewed By: kcc Subscribers: llvm-commits, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36587 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@311937 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-09[asan] Complete the Fuchsia portVitaly Buka
Submitted on behalf of Roland McGrath. Reviewers: kcc, eugenis, alekseyshl, vitalybuka Reviewed By: vitalybuka Subscribers: filcab, vitalybuka, srhines, kubamracek, mgorny, phosek, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35865 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310431 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10[Asan] Eliminate SHADOW_TO_MEM() macroIvan A. Kosarev
Differential Revision: https://reviews.llvm.org/D31592 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299867 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-05[asan] Reapply: Switch to using dynamic shadow offset on iOSAnna Zaks
The VM layout is not stable between iOS version releases, so switch to dynamic shadow offset. Differential Revision: https://reviews.llvm.org/D25218 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@283375 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-05Revert "[asan] Switch to using dynamic shadow offset on iOS"Anna Zaks
This reverts commit b2af965b7924ad793b313996a96633bb72daf629. Revert as these changes broke a Chromium buildbot. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@283349 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-04[asan] When protect_shadow_gap=0, set up the shadow for the shadow gap. This ↵Kostya Serebryany
is needed to support NVIDIA CUDA drivers. Unfortunately, I don't know how to test it properly with CUDA on a public build bot, so adding a test that emulates the CUDA behavior. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@283270 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-04[asan] Switch to using dynamic shadow offset on iOSAnna Zaks
The VM layout is not stable between iOS version releases, so switch to dynamic shadow offset. Differential Revision: https://reviews.llvm.org/D25218 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@283240 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-30[compiler-rt] Add support for the dynamic shadow allocationEtienne Bergeron
Summary: This patch is adding support for dynamic shadow allocation. This is a merge and re-commit of the following patches. ``` [compiler-rt] Fix Asan build on Android https://reviews.llvm.org/D24768 [compiler-rt] Add support for the dynamic shadow allocation https://reviews.llvm.org/D23363 ``` This patch needed to re-land at the same time: ``` [asan] Support dynamic shadow address instrumentation https://reviews.llvm.org/D23354 ``` Reviewers: rnk, zaks.anna Subscribers: tberghammer, danalbert, kubabrecka, dberris, chrisha, llvm-commits Differential Revision: https://reviews.llvm.org/D25104 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282882 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-21revert 282085, 281909, they broke 32-bit dynamic ASan and the ↵Nico Weber
sanitizer-windows bot git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282096 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-21[compiler-rt] Fix Asan build on AndroidEtienne Bergeron
Summary: The dynamic shadow code is not detected correctly on Android. The android shadow seems to start at address zero. The bug is introduced here: https://reviews.llvm.org/D23363 Started here: https://build.chromium.org/p/chromium.fyi/builders/ClangToTAndroidASan/builds/4029 Likely due to an asan runtime change, filed https://llvm.org/bugs/show_bug.cgi?id=30462 From asan_mapping.h: ``` #if SANITIZER_WORDSIZE == 32 # if SANITIZER_ANDROID # define SHADOW_OFFSET (0) <<---- HERE # elif defined(__mips__) ``` Shadow address on android is 0. From asan_rtl.c: ``` if (shadow_start == 0) { [...] shadow_start = FindAvailableMemoryRange(space_size, alignment, granularity); } ``` We assumed that 0 is dynamic address. On windows, the address was determined with: ``` # elif SANITIZER_WINDOWS64 # define SHADOW_OFFSET __asan_shadow_memory_dynamic_address # else ``` and __asan_shadow_memory_dynamic_address is initially zero. Reviewers: rnk, eugenis, vitalybuka Subscribers: kcc, tberghammer, danalbert, kubabrecka, dberris, llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D24768 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282085 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19[compiler-rt] Add support for the dynamic shadow allocationEtienne Bergeron
Summary: This patch is adding the needed code to compiler-rt to support dynamic shadow. This is to support this patch: https://reviews.llvm.org/D23354 It's adding support for using a shadow placed at a dynamic address determined at runtime. The dynamic shadow is required to work on windows 64-bits. Reviewers: rnk, kcc, vitalybuka Subscribers: kubabrecka, dberris, llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D23363 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281909 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21Change the shadow memory address for win64.Etienne Bergeron
This is part of the effort for asan to support Windows 64 bit. Patch by Wei Wang Differential Revision: http://reviews.llvm.org/D21525 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@273270 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-30[ASan] Add shadow offset for SystemZ.Marcin Koscielnicki
This is the compiler-rt counterpart to D19650. Differential Revision: http://reviews.llvm.org/D19652 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268162 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-02[asan] Remove redundant elifAnna Zaks
This is a fixup to r259451. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259588 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-02[asan] Add iOS support.Anna Zaks
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259451 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-04[ASan] Fix the links to bugs and wikipages.Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254735 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-09[compiler-rt] [asan] Use same shadow offset for aarch64Adhemerval Zanella
This patch makes ASAN for aarch64 use the same shadow offset for all currently supported VMAs (39 and 42 bits). The shadow offset is the same for 39-bit (36). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252497 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-20[asan] Enable ASan for AArch64/42-bit VMAAdhemerval Zanella
This patch adds support for asan on aarch64-linux with 42-bit VMA (current default config for 64K pagesize kernels). The support is enabled by defining the SANITIZER_AARCH64_VMA to 42 at build time for both clang/llvm and compiler-rt. The default VMA is 39 bits. For 42-bit VMA aarch64 uses SANITIZIER_CAN_USER_ALLOCATOR64. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245596 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-07[asan] Try different values of the shadow gap start.Evgeniy Stepanov
The number of unaccessible pages at the beginning of the address space can differ between processes on the same machine. Try different values at runtime to protect as much memory as possible. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244364 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-07[asan] Reduce shadow gap start on 32-bit Android.Evgeniy Stepanov
This fixes an internal assertion failure when running out of the address space in the large allocator. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244359 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-05[asan] Enable asan for aarch64Adhemerval Zanella
This patch enables asan for aarch64/linux. It marks it as 'unstable-release', since some tests are failing due either kernel missing support of non-executable pages in mmap or environment instability (infinite loop in juno reference boards). It sets decorate_proc_maps test to require stable-release, since the test expects the shadow memory to not be executable and the support for aarch64 is only added recently by Linux (da141706aea52c1a9 - 4.0). It also XFAIL static_tls test for aarch64 linker may omit the __tls_get_addr call as a TLS optimization. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244054 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-29[asan] Remove special case mapping on Android/AArch64.Evgeniy Stepanov
ASan shadow on Android starts at address 0 for both historic and performance reasons. This is possible because the platform mandates -pie, which makes lower memory region always available. This is not such a good idea on 64-bit platforms because of MAP_32BIT incompatibility. This patch changes Android/AArch64 mapping to be the same as that of Linux/AAarch64. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243548 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-23Working on reconciling out-of-tree patches to compiler-rt for building for iOS.Chris Bieneman
Summary: This is one of many changes needed for compiler-rt to get it building on iOS. This change ifdefs out headers and functionality that aren't available on iOS, and adds support for iOS and the iOS simulator to as an. Note: this change does not enable building for iOS, as there are more changes to come. Reviewers: glider, kubabrecka, bogner, samsonov Reviewed By: samsonov Subscribers: samsonov, zaks.anna, llvm-commits Differential Revision: http://reviews.llvm.org/D10515 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240469 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-31[asan][mips] Fix MIPS64 Asan mappingKumar Sukhani
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@227683 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22[ASan/Win] Move the shadow to 0x30000000Timur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226809 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12[ASan] Move the shadow on Windows 32-bit from 0x20000000 to 0x40000000Timur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225641 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12[asan] [mips] added support of asan for mips64/mips64el, patch by Kumar SukhaniKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221800 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-06Use GET_CURRENT_FRAME() to calculate the memory layout for power. This worksWill Schmidt
for both PPC64 Big and Little endian modes, so also eliminates the need for the BIG_ENDIAN/LITTLE_ENDIAN #ifdeffery. By trial and error, it also looks like the kPPC64_ShadowOffset64 value is valid using (1ULL << 41) for both BE and LE, so that #if/#elif/#endif block has also been simplified. Differential Revision: http://reviews.llvm.org/D6044 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221457 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-04[asan] [mips] changed ShadowOffset32 for systems having 16kb PageSize; patch ↵Kostya Serebryany
by Kumar Sukhani git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@221288 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-15[compiler-rt] Enable ASAN for powerpc64le-linuxWill Schmidt
Whitespace update for lint check by myself (Will). Otherwise code and comments by Peter Bergner, as previously seen on llvm-commits. The following patch gets ASAN somewhat working on powerpc64le-linux. It currently assumes the LE kernel uses 46-bit addressing, which is true, but it doesn't solve the case for BE where it may be 44 or 46 bits. That can be fixed with a follow on patch. There are some test suite fails even with this patch that I haven't had time to solve yet, but this is better than the state it is in now. The limited debugging of those test suite fails seems to show that the address map for 46-bit addressing has changed and so we'll need to modify the shadow memory location slightly. Again, that can be fixed with a follow on patch. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@219827 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-05-12Add FreeBSD support to address sanitizer process mapping facilitiesViktor Kutuzov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208537 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23[ASan] Move the shadow range on 32-bit iOS (and iOS Simulator)Alexander Potapenko
to 0x40000000-0x60000000 to avoid address space clash with system libraries. The solution has been proposed by tahabekireren@gmail.com in https://code.google.com/p/address-sanitizer/issues/detail?id=210 This is also known to fix some Chromium iOS tests. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@207002 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-27[asan] Do not sanitize kernel area on 32-bit targets, patch by Yuri GribovKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204897 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-01-16[asan] Nuke ASAN_FLEXIBLE_MAPPING_AND_OFFSET.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199370 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-12-04[ASan] Use 'extern "C"' rather than 'extern' for global variables exposed in ↵Timur Iskhodzhanov
the interface git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196379 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-17[ASan] Don't add SANITIZER_INTERFACE_ATTRIBUTE for internal ASan functionsAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190860 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-16[ASan] Check that getSymbolizer() is defined. Turn magic mapping constants ↵Alexey Samsonov
into named variables git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190787 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-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-02-28[asan] bump kMidMemEnd to 0x4fffffffffULL since in rare cases prelink uses ↵Kostya Serebryany
addresses higher than 0x3fffffffff git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@176250 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-21[asan] speedup by more than 2x handling of the small memset/memcpy/etc callsKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@175728 91177308-0d34-0410-b5e6-96231b3b80d8