Commit Graph

2334 Commits

Author SHA1 Message Date
Evgeniy Stepanov 366ea7115d [asan] Remove malloc_context_size=0 from asan_device_setup.
This line was added in
  r243679 - [asan] Support arm64 devices in asan_device_setup
without any good reason.

llvm-svn: 329962
2018-04-12 22:06:18 +00:00
Alex Shlyapnikov 40c90bfba8 [ASan] NFC: make use of a new ErrorBase ctor
Summary:
Minor style changes to complement D44404:
- make use of a new ErrorBase ctor
- de-duplicate a comment about VS2013 support

Reviewers: eugenis

Subscribers: kubamracek, delcypher, llvm-commits, #sanitizers

Differential Revision: https://reviews.llvm.org/D45390

llvm-svn: 329586
2018-04-09 16:00:10 +00:00
Alex Shlyapnikov 10f50a44c1 [ASan] Report proper ASan error on allocator failures instead of CHECK(0)-ing
Summary:
Currently many allocator specific errors (OOM, for example) are reported as
a text message and CHECK(0) termination, not stack, no details, not too
helpful nor informative. To improve the situation, ASan detailed errors were
defined and reported under the appropriate conditions.

Issue: https://github.com/google/sanitizers/issues/887

Reviewers: eugenis

Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits

Differential Revision: https://reviews.llvm.org/D44404

llvm-svn: 328722
2018-03-28 18:22:40 +00:00
Evgeniy Stepanov 29e6fd6785 [asan] Add vfork to the list of reasons for stack errors.
Until we figure out what to do with it, vfork can cause stack-based
false positives.

llvm-svn: 328681
2018-03-28 00:45:20 +00:00
Evgeniy Stepanov 7989d8da20 Revert "[asan] Replace vfork with fork."
Replacing vfork with fork results in significant slowdown of certain
apps (in particular, memcached).

This reverts r327752.

llvm-svn: 328600
2018-03-27 00:31:16 +00:00
Kostya Kortchinsky 988fab3f66 [sanitizer] Split coverage into separate RT in sanitizer_common
Summary:
`sanitizer_common`'s coverage support is fairly well separated, and libcdep by
default. Several sanitizers don't make use of coverage, and as far as I can
tell do no benefit from the extra dependencies pulled in by the coverage public
interface functions.

The following sanitizers call `InitializeCoverage` explicitely: MSan, ASan,
LSan, HWAsan, UBSan. On top of this, any sanitizer bundling RTUBSan should
add the coverage RT as well: ASan, Scudo, UBSan, CFI (diag), TSan, MSan, HWAsan.

So in the end the following have no need: DFSan, ESan, CFI, SafeStack (nolibc
anyway), XRay, and the upcoming Scudo minimal runtime.

I tested this with all the sanitizers check-* with gcc & clang, and in
standalone on Linux & Android, and there was no issue. I couldn't test this on
Mac, Fuchsia, BSDs, & Windows for lack of an environment, so adding a bunch of
people for additional scrunity. I couldn't test HWAsan either.

Reviewers: eugenis, vitalybuka, alekseyshl, flowerhack, kubamracek, dberris, rnk, krytarowski

Reviewed By: vitalybuka, alekseyshl, flowerhack, dberris

Subscribers: mgorny, delcypher, #sanitizers, llvm-commits

Differential Revision: https://reviews.llvm.org/D44701

llvm-svn: 328204
2018-03-22 15:04:31 +00:00
Mandeep Singh Grang a9e74a9165 Revert "[compiler-rt] Change std::sort to llvm::sort in response to r327219"
This reverts commit 2ee210e1963e03aacc0f71c50e4994bb5c66586e.

llvm-svn: 327936
2018-03-20 01:17:18 +00:00
Mandeep Singh Grang dc09ebf71b [compiler-rt] Change std::sort to llvm::sort in response to r327219
Summary:
r327219 added wrappers to std::sort which randomly shuffle the container before sorting.
This will help in uncovering non-determinism caused due to undefined sorting
order of objects having the same key.

To make use of that infrastructure we need to invoke llvm::sort instead of std::sort.

Reviewers: kcc, rsmith, RKSimon, eugenis

Reviewed By: RKSimon

Subscribers: efriedma, kubamracek, dberris, #sanitizers, llvm-commits

Differential Revision: https://reviews.llvm.org/D44360

llvm-svn: 327929
2018-03-20 00:44:59 +00:00
Evgeniy Stepanov a4561123de [asan] Replace vfork with fork.
Summary:
vfork is not ASan-friendly because it modifies stack shadow in the
parent process address space. While it is possible to compensate for that with, for example,
__asan_handle_no_return before each call to _exit or execve and friends, simply replacing
vfork with fork looks like by far the easiest solution.

Posix compliant programs can not detect the difference between vfork and fork.

Fixes https://github.com/google/sanitizers/issues/925

Reviewers: kcc, vitalybuka

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D44587

llvm-svn: 327752
2018-03-16 22:15:05 +00:00
Evgeniy Stepanov 9034c02270 [asan] Remove empty fork interceptor.
After a partial revert, ASan somehow ended up with an empty interceptor for fork().

llvm-svn: 327748
2018-03-16 21:31:49 +00:00
Alex Shlyapnikov 79a7c4fe73 [Sanitizers] Add more standard compliant posix_memalign implementation for LSan.
Summary:
Add more standard compliant posix_memalign implementation for LSan and
use corresponding sanitizer's posix_memalign implenetations in allocation
wrappers on Mac.

Reviewers: eugenis, fjricci

Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits

Differential Revision: https://reviews.llvm.org/D44335

llvm-svn: 327338
2018-03-12 21:59:06 +00:00
Evgeniy Stepanov c2e54761c9 [asan] poison_heap=0 should not disable __asan_handle_no_return.
Reviewers: kcc, alekseyshl, vitalybuka

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D44339

llvm-svn: 327337
2018-03-12 21:46:55 +00:00
Dan Liew 0faaa99e4d [asan] Fix bug where suppression of overlapping accesses was ignored on
`strcpy()`, `strncpy()`, `strcat()`, and `strncat()`.

rdar://problem/35576899

Differential Revision: https://reviews.llvm.org/D43702

llvm-svn: 327068
2018-03-08 21:50:22 +00:00
Kamil Rytarowski ad4632e07a Disable ASan exceptions on NetBSD
This is a workarond for the fallout from D42644:
[asan] Intercept std::rethrow_exception indirectly.

Reported problem on NetBSD/amd64:

$ sh ./projects/compiler-rt/test/sanitizer_common/asan-i386-NetBSD/NetBSD/Output/ttyent.cc.script
/usr/lib/i386/libgcc.a(unwind-dw2.o): In function `_Unwind_RaiseException':
unwind-dw2.c:(.text+0x1b41): multiple definition of `_Unwind_RaiseException'
/public/llvm-build/lib/clang/7.0.0/lib/netbsd/libclang_rt.asan-i386.a(asan_interceptors.cc.o):/public/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:337: first defined here
clang-7.0: error: linker command failed with exit code 1 (use -v to see invocation)

llvm-svn: 326216
2018-02-27 18:05:49 +00:00
Vitaly Buka e9d957de8d [asan] Enable ASAN_INTERCEPT___CXA_THROW for x86 Android
llvm-svn: 326160
2018-02-27 02:14:06 +00:00
Kuba Mracek d2af423bbe Fix build for iOS/ARM ("__Unwind_RaiseException" is not available for armv7).
llvm-svn: 326150
2018-02-26 23:39:04 +00:00
Vitaly Buka 78577341c4 [asan] Fix build for Android
llvm-svn: 326149
2018-02-26 23:23:07 +00:00
Vitaly Buka 781ef03e10 [asan] Intercept std::rethrow_exception indirectly
Summary:
Fixes Bug 32434
See https://bugs.llvm.org/show_bug.cgi?id=32434

Short summary:
std::rethrow_exception does not use __cxa_throw to rethrow the exception, so if
it is called from uninstrumented code, it will leave the stack poisoned. This
can lead to false positives.

Long description:

For functions which don't return normally (e.g. via exceptions), asan needs to
unpoison the entire stack. It is not known before a call to such a function
where execution will continue, some function which don't contain cleanup code
like destructors might be skipped. After stack unwinding, execution might
continue in uninstrumented code.

If the stack has been poisoned before such a function is called, but the stack
is unwound during the unconventional return, then zombie redzones (entries) for
no longer existing stack variables can remain in the shadow memory. Normally,
this is avoided by asan generating a call to asan_handle_no_return before all
functions marked as [[noreturn]]. This asan_handle_no_return unpoisons the
entire stack. Since these [[noreturn]] functions can be called from
uninstrumented code, asan also introduces interceptor functions which call
asan_handle_no_return before running the original [[noreturn]] function;
for example, cxa_throw is intercepted.

If a [[noreturn]] function is called from uninstrumented code (so the stack is
left poisoned) and additionally, execution continues in uninstrumented code, new
stack variables might be introduced and overlap with the stack variables
which have been removed during stack unwinding. Since the redzones are not
cleared nor overwritten by uninstrumented code, they remain but now contain
invalid data.

Now, if the redzones are checked against the new stack variables, false
positive reports can occur. This can happen for example by the uninstrumented
code calling an intercepted function such as memcpy, or an instrumented
function.

Intercepting std::rethrow_exception directly is not easily possible since it
depends on the C++ standard library implementation (e.g. libcxx vs libstdc++)
and the mangled name it produces for this function. As a rather simple
workaround, we're intercepting _Unwind_RaiseException for libstdc++. For
libcxxabi, we can intercept the ABI function __cxa_rethrow_primary_exception.

Patch by Robert Schneider.

Reviewers: kcc, eugenis, alekseyshl, vitalybuka

Reviewed By: vitalybuka

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D42644

llvm-svn: 326132
2018-02-26 21:40:19 +00:00
Kuba Mracek 473f3fbaf8 Fix-up for r326106: FindAvailableMemoryRange needs a nullptr as its 5th argument.
llvm-svn: 326111
2018-02-26 18:44:43 +00:00
Kuba Mracek 061f3589cc [asan] Be more careful and verbose when allocating dynamic shadow memory
FindAvailableMemoryRange can currently overwrite existing memory (by restricting the VM below addresses that are already used). This patch adds a check to make sure we don't restrict the VM space too much. We are also now more explicit about why the lookup failed and print out verbose values.

Differential Revision: https://reviews.llvm.org/D43318

llvm-svn: 326106
2018-02-26 18:33:21 +00:00
Kamil Rytarowski 39628a7ab0 Add NetBSD syscall hooks skeleton in sanitizers
Summary:
Implement the skeleton of NetBSD syscall hooks for use with sanitizers.

Add a script that generates the rules to handle syscalls
on NetBSD: generate_netbsd_syscalls.awk. It has been written
in NetBSD awk(1) (patched nawk) and is compatible with gawk.

Generate lib/sanitizer_common/sanitizer_platform_limits_netbsd.h
that is a public header for applications, and included as:
<sanitizer_common/sanitizer_platform_limits_netbsd.h>.

Generate sanitizer_syscalls_netbsd.inc that defines all the
syscall rules for NetBSD. This file is modeled after the Linux
specific file: sanitizer_common_syscalls.inc.

Start recognizing NetBSD syscalls with existing sanitizers:
ASan, ESan, HWASan, TSan, MSan.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, kcc, dvyukov, eugenis

Reviewed By: vitalybuka

Subscribers: hintonda, kubamracek, mgorny, llvm-commits, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D42048

llvm-svn: 325206
2018-02-15 02:43:02 +00:00
Kostya Kortchinsky 2833383cd4 [scudo] Allow options to be defined at compile time
Summary:
Allow for options to be defined at compile time, like is already the case for
other sanitizers, via `SCUDO_DEFAULT_OPTIONS`.

Reviewers: alekseyshl, dberris

Reviewed By: alekseyshl, dberris

Subscribers: kubamracek, delcypher, llvm-commits, #sanitizers

Differential Revision: https://reviews.llvm.org/D42980

llvm-svn: 324620
2018-02-08 16:29:48 +00:00
Yvan Roux cae4970b34 [asan] Fix filename size on linux platforms.
This is a a fix for:
https://bugs.llvm.org/show_bug.cgi?id=35996

Use filename limits from system headers to be synchronized with what
LD_PRELOAD can handle.

Differential Revision: https://reviews.llvm.org/D42900

llvm-svn: 324496
2018-02-07 18:27:25 +00:00
Alex Shlyapnikov 3c80f4d941 Make detect_invalid_pointer_pairs option to be tristate.
Summary:
With the change, one can choose not to report comparison (or subtraction)
of a pointer with nullptr pointer.

Reviewers: kcc, jakubjelinek, alekseyshl

Reviewed By: alekseyshl

Subscribers: kubamracek

Differential Revision: https://reviews.llvm.org/D41479

llvm-svn: 323995
2018-02-01 19:52:56 +00:00
Alex Shlyapnikov fd2833992a [Sanitizers] Make common allocator agnostic to failure handling modes.
Summary:
Make common allocator agnostic to failure handling modes and move the
decision up to the particular sanitizer's allocator, where the context
is available (call stack, parameters, return nullptr/crash mode etc.)

It simplifies the common allocator and allows the particular sanitizer's
allocator to generate more specific and detailed error reports (which
will be implemented later).

The behavior is largely the same, except one case, the violation of the
common allocator's check for "size + alignment" overflow is now reportied
as OOM instead of "bad request". It feels like a worthy tradeoff and
"size + alignment" is huge in this case anyway (thus, can be interpreted
as not enough memory to satisfy the request). There's also a Report()
statement added there.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits, #sanitizers

Differential Revision: https://reviews.llvm.org/D42198

llvm-svn: 322784
2018-01-17 23:20:36 +00:00
Kamil Rytarowski 3efd1c516c [Sanitizers, test] Fix sanitizer tests on Solaris (PR 33274)
Summary:
This patch (on top of the previous two (https://reviews.llvm.org/D40898 and
https://reviews.llvm.org/D40899) complete the compiler-rt side of the the Solaris
sanitizer port.

It contains the following sets of changes:

* For the time being, the port is for 32-bit x86 only, so reject the various tests on
  x86_64.

* When compiling as C++, <setjmp.h> resp. <iso/setjmp_iso.h> only declares
  _setjmp and _longjmp inside namespace std.

* MAP_FILE is a Windows feature.  While e.g. Linux <sys/mman.h> provides a
  no-op compat define, Solaris does not.

* test/asan/TestCases/Posix/coverage.cc was initially failing like this:

/vol/gcc/src/llvm/llvm/local/projects/compiler-rt/lib/sanitizer_common/scripts/sancov.py: 4 files merged; 2 PCs total
rm: cannot remove '/var/gcc/llvm/local/projects/compiler-rt/test/asan/I386SunOSConfig/TestCases/Posix/Output/coverage': Invalid argument

  Further digging revealed that the rm was trying to remove the running test's working
  directory which failed as observed.  cd'ing out of the dir before let the test pass.

* Two tests needed a declaration of alloca. I've now copied the existing code from
  test/asan/TestCases/alloca_constant_size.cc, but it may be more profitable and
  maintainable to have a common testsuite header where such code is collected.

* Similarly, Solaris' printf %p format doesn't include the leading 0x.

* In test/asan/TestCases/malloc-no-intercept.c, I had to undef __EXTENSIONS__
  (predefined by clang for no apparent reason) to avoid conflicting declarations
  for memalign.

* test/ubsan/TestCases/Float/cast-overflow.cpp has different platform dependent
  ways to define BYTE_ORDER and friends.  Why not just use __BYTE_ORDER__ and
  friends as predefined by clang and gcc?

Patch by Rainer Orth.

Reviewers: kcc, alekseyshl

Reviewed By: alekseyshl

Subscribers: srhines, kubamracek, mgorny, krytarowski, fedor.sergeev, JDevlieghere, llvm-commits, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D40900

llvm-svn: 322635
2018-01-17 12:26:04 +00:00
Evgeniy Stepanov 2db14a5715 [asan] Restore asan_device_setup compatibility with older libraries.
Summary:
This way new asan_device_setup, which knows about the quirks of
recent releases of Android, can be used with older ASan runtime
library (say, from an NDK release). The library is version locked to
the compiler, and is often hard or impossible to update.

Reviewers: vitalybuka

Subscribers: srhines, kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D41679

llvm-svn: 321677
2018-01-02 21:35:23 +00:00
Alex Shlyapnikov f547c96d9f [Sanitizers, CMake] Basic sanitizer Solaris support (PR 33274)
Summary:
This patch, on top of https://reviews.llvm.org/D40898, contains the build system
changes necessary to enable the Solaris/x86 sanitizer port.

The only issue of note is the libclang_rt.sancov_{begin, end} libraries: clang relies on the
linker automatically defining __start_SECNAME and __stop_SECNAME labels for
sections whose names are valid C identifiers.  This is a GNU ld extension not present
in the ELF gABI, also implemented by gold and lld, but not by Solaris ld.  To work around
this, I automatically link the sancov_{begin,end} libraries into every executable for now.
There seems to be now way to build individual startup objects like crtbegin.o/crtend.o,
so I've followed the lead of libclang_rt.asan-preinit which also contains just a single
object.

Reviewers: kcc, alekseyshl

Reviewed By: alekseyshl

Subscribers: srhines, kubamracek, mgorny, fedor.sergeev, llvm-commits, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D40899

llvm-svn: 321373
2017-12-22 18:04:20 +00:00
Kamil Rytarowski 271018d216 [Sanitizers] Basic sanitizer Solaris support (PR 33274)
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
2017-12-14 20:14:29 +00:00
Kuba Mracek 2c1fa4feb1 [asan] Use linker initialization for the allocator
This saves ~2 MB of dirty memory footprint. Can be a big deal on mobile devices especially when running multiple processes with ASan.

Differential Revision: https://reviews.llvm.org/D40627

llvm-svn: 320660
2017-12-14 00:07:15 +00:00
Bill Seurer c776a9f5a8 [PowerPC][asan] Update asan to handle changed memory layouts in newer kernels
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.

llvm-svn: 320110
2017-12-07 22:53:49 +00:00
Alex Shlyapnikov c73d1e28f1 [ASan] Enhance libsanitizer support for invalid-pointer-pair.
Following patch adds support of all memory origins in
CheckForInvalidPointerPair function. For small difference of pointers,
it's directly done in shadow memory (the limit was set to 2048B).
Then we search for origin of first pointer and verify that the second
one has the same origin. If so, we verify that it points either to a same
variable (in case of stack memory or a global variable), or to a same
heap segment.

Committing on behanf of marxin and jakubjelinek.

Reviewers: alekseyshl, kcc

Subscribers: llvm-commits

Differential revision: https://reviews.llvm.org/D40600

llvm-svn: 319668
2017-12-04 18:00:24 +00:00
Walter Lee 6c529f7e96 [sanitizers] Add init function to set alignment of low level allocator
ASan requires that the min alignment be at least the shadow
granularity, so add an init function to do that.

Differential Revision: https://reviews.llvm.org/D39473

llvm-svn: 318717
2017-11-21 01:01:32 +00:00
Evgeniy Stepanov 8e7018d92f [asan] Use dynamic shadow on 32-bit Android, try 2.
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

llvm-svn: 318666
2017-11-20 17:41:57 +00:00
Evgeniy Stepanov 9d564cdcb0 Revert "[asan] Use dynamic shadow on 32-bit Android" and 3 more.
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.

llvm-svn: 318575
2017-11-18 00:22:34 +00:00
Evgeniy Stepanov 0b44f44bcf [asan] Fix asan_device_setup on KitKat.
"ln" from toybox does not understand -f (force) flag.

llvm-svn: 318573
2017-11-17 23:52:34 +00:00
Walter Lee 513fc069f0 [asan] Properly mark or disable tests that only work with shadow scale of 3
Differential Revision: https://reviews.llvm.org/D39774

llvm-svn: 318471
2017-11-16 23:29:19 +00:00
Walter Lee ed8b52c8bc [asan] Avoid assert failure for non-default shadow scale
Rather than assertion failing, we can fall back to the
non-optimized version which works for any shadow scale.

Differential Revision: https://reviews.llvm.org/D39474

llvm-svn: 318460
2017-11-16 22:02:58 +00:00
Walter Lee 13a3cf3b6a [asan] Ensure that the minimum redzone is at least SHADOW_GRANULARITY
This is required by the Asan run-time.

Differential Revision: https://reviews.llvm.org/D39472

llvm-svn: 318422
2017-11-16 17:03:25 +00:00
Walter Lee 8f1545c629 [asan] Fix small X86_64 ShadowOffset for non-default shadow scale
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

llvm-svn: 318421
2017-11-16 17:03:00 +00:00
Evgeniy Stepanov 396ed67950 [asan] Fallback to non-ifunc dynamic shadow on android<22.
Summary: Android < 22 does not support ifunc.

Reviewers: pcc

Subscribers: srhines, kubamracek, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D40116

llvm-svn: 318369
2017-11-16 02:52:19 +00:00
Tom de Vries a91707224d [asan] Remove semicolon after do {} while (0)
Remove semicolon after "do {} while (0)" in in CHECK_SMALL_REGION

llvm-svn: 318084
2017-11-13 20:59:20 +00:00
Walter Lee 52b2bd7845 [asan] Add CMake hook to override shadow scale in compiler_rt
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

llvm-svn: 318038
2017-11-13 14:02:27 +00:00
Evgeniy Stepanov 989299c42b [asan] Use dynamic shadow on 32-bit Android.
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

llvm-svn: 317943
2017-11-10 22:27:48 +00:00
Vitaly Buka 529e321e49 [sanitizer] Remove unused <signal.h> which conflicts with asan declarations
llvm-svn: 317871
2017-11-10 04:12:35 +00:00
Vitaly Buka a10d7a9fcc [sanitizer] Remove unneeded forward declaration of real_sigaction
llvm-svn: 317869
2017-11-10 04:00:58 +00:00
Vitaly Buka 084d365c90 [sanitizer] Remove unneeded forward declarations
llvm-svn: 317868
2017-11-10 03:35:26 +00:00
Vitaly Buka bad0b3ea7e [sanitizer] Remove unused <signal.h> which conflicts with asan declarations
llvm-svn: 317867
2017-11-10 03:18:53 +00:00
Vitaly Buka 43c3e6ae1c [sanitizer] Allow sanitizers to redefine implementation of signal interceptors
Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

Differential Revision: https://reviews.llvm.org/D39870

llvm-svn: 317843
2017-11-09 22:48:54 +00:00
Vitaly Buka 66f32fc431 [sanitizers] Rename GetStackTraceWithPcBpAndContext
Name does not need to enumerate arguments.

llvm-svn: 317774
2017-11-09 07:53:06 +00:00