Commit Graph

4788 Commits

Author SHA1 Message Date
Dmitry Vyukov b89a69dac6 tsan: merge function definition and declaration
llvm-svn: 240633
2015-06-25 11:45:45 +00:00
Jay Foad 8677baf024 Enable memory sanitizer for PPC64
Summary:
This patch adds basic memory sanitizer support for PPC64. PR23219.

I have further patches ready to enable it in LLVM and Clang, and to fix
most of the many failing tests in check-msan.

Reviewers: kcc, willschm, samsonov, wschmidt, eugenis

Reviewed By: eugenis

Subscribers: wschmidt, llvm-commits

Differential Revision: http://reviews.llvm.org/D10648

llvm-svn: 240623
2015-06-25 06:22:31 +00:00
Alexey Samsonov 3fa03e3e9d [CMake] Fix PR23539: Don't reference C++ ABI symbols prior to Mac OS 10.9.
Summary:
This patch implements step 1 from
https://llvm.org/bugs/show_bug.cgi?id=23539#c10

I'd appreciate if you could test it on Mac OS and verify that parts of UBSan
runtime that reference C++ ABI symbols are properly excluded, and fix ASan/UBSan
builds.

Test Plan: regression test suite

Reviewers: thakis, hans

Subscribers: llvm-commits, zaks.anna, kubabrecka

Differential Revision: http://reviews.llvm.org/D10621

llvm-svn: 240617
2015-06-25 00:57:42 +00:00
Chris Bieneman a9e77abc68 One more change required to build the sanitizers for iOS.
Summary: _Unwind_Backtrace is not available on iOS, so we should ifdef out the posix implementations of BufferedStackTrace::SlowUnwindStack and BufferedStackTrace::SlowUnwindStackWithContext on iOS.

Reviewers: samsonov

Reviewed By: samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10696

llvm-svn: 240586
2015-06-24 20:13:44 +00:00
Dmitry Vyukov d58df749c1 tsan: fix false positive between dlopen and dl_iterate_phdr
We see false reports between dlopen and dl_iterate_phdr.
This happens because tsan does not see dynamic linker
internal synchronization. Unpoison module names
in dl_iterate_phdr callback.

llvm-svn: 240576
2015-06-24 19:49:32 +00:00
Peter Collingbourne 19e86199f1 SafeStack: Add another missing header to try to fix FreeBSD build.
llvm-svn: 240564
2015-06-24 18:16:05 +00:00
Peter Collingbourne 8454044b1f SafeStack: Add #include of <stdint.h>.
Should fix the FreeBSD build.

llvm-svn: 240555
2015-06-24 17:23:13 +00:00
Dmitry Vyukov b086a70206 asan: fix 32-bit build
llvm-svn: 240541
2015-06-24 13:27:56 +00:00
Dmitry Vyukov c871c03550 tsan: don't print external PCs in reports
They are meaningless.

llvm-svn: 240539
2015-06-24 13:04:12 +00:00
Dmitry Vyukov 89e0d57157 tsan: fix unbounded memory consumption for large mallocs
This happens only in corner cases, but we observed this on a real app.
See the test for description of the exact scenario that lead to unbounded memory consumption.

llvm-svn: 240535
2015-06-24 11:51:41 +00:00
Peter Collingbourne adbde27d2d Update SafeStack TODO in the safestack.cc
This patch clarifies the TODO note at the top of safestack.cc and brings
it more in sync with what we (the CPI team) actually plan to work on in
the future.

Patch by Volodymyr Kuznetsov!

Differential Revision: http://reviews.llvm.org/D10600

llvm-svn: 240473
2015-06-23 22:26:48 +00:00
Chris Bieneman f1ba141041 Working on reconciling out-of-tree patches to compiler-rt for building for iOS.
Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.

Darwin doesn't have _Unwind_VRS_Get, instead use _Unwind_GetIP directly.

Note: this change does not enable building for iOS, as there are more changes to come.

Reviewers: kubabrecka, bogner, samsonov

Reviewed By: samsonov

Subscribers: samsonov, llvm-commits

Differential Revision: http://reviews.llvm.org/D10516

llvm-svn: 240470
2015-06-23 21:39:57 +00:00
Chris Bieneman d1a1444c1a Working on reconciling out-of-tree patches to compiler-rt for building for iOS.
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

llvm-svn: 240469
2015-06-23 21:39:54 +00:00
Chris Bieneman 04f0643a76 Working on reconciling out-of-tree patches to compiler-rt for building for iOS.
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.

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, llvm-commits

Differential Revision: http://reviews.llvm.org/D10514

llvm-svn: 240468
2015-06-23 21:39:52 +00:00
Chris Bieneman e13272a008 Working on reconciling out-of-tree patches to compiler-rt for building for iOS.
Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.

This change does the following:
- Don't include crt_externs on iOS (it isn't available)
- Support ARM thread state objects

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, aemerson, llvm-commits

Differential Revision: http://reviews.llvm.org/D10510

llvm-svn: 240467
2015-06-23 21:39:49 +00:00
Pirama Arumuga Nainar 4a39e80809 Fix incorrect truncation at the overflow boundary
Summary:
This patch fixes incorrect truncation when the input wider value is
exactly 2^dstBits.  For that value, the overflow to infinity is not
correctly handled.  The fix is to replace a strict '>' with '>='.

Currently,
__truncdfsf2(340282366900000000000000000000000000000.0) returns infinity
__truncdfsf2(340282366920938463463374607431768211456.0) returns 0
__truncdfsf2(400000000000000000000000000000000000000.0) returns infinity

Likewise, __truncdfhf2 and __truncsfhf2 (and consequently gnu_f2h_ieee)
are discontinuous at 65536.0.

This patch adds tests for all three cases, along with adding a missing
header include to fp_test.h.

Reviewers: joerg, ab, srhines

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10594

llvm-svn: 240450
2015-06-23 20:24:53 +00:00
Frederic Riss 66c868ce27 [Sanitizers] Pass the correct arch to the symbolizer for x86_64h
I have no idea how to directly test that as it depends on a particular
(micro-)architecure of the host processor.
Combined with llvm's r240339 this should fix issues people might have
be seeing intermitently on Darwin haswell machines (the symbolizer
would use the wrong slice of the binary, thus potentially resolving
to the wrong symbol).

llvm-svn: 240379
2015-06-23 05:35:19 +00:00
Filipe Cabecinhas 7af0a1cb84 CMake: Stop using LLVM's custom parse_arguments. NFC
Summary:
Use CMake's cmake_parse_arguments() instead.
It's called in a slightly different way, but supports all our use cases.
It's in CMake 2.8.8, which is our minimum supported version.

CMake 3.0 doc (roughly the same. No direct link to 2.8.8 doc):
http://www.cmake.org/cmake/help/v3.0/module/CMakeParseArguments.html?highlight=cmake_parse_arguments

Since I was already changing these calls, I changed ARCH and LIB into
ARCHS and LIBS to make it more clear that they're lists of arguments.

Reviewers: eugenis, samsonov, beanz

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10529

llvm-svn: 240120
2015-06-19 03:39:24 +00:00
Peter Collingbourne 175d633271 Add control flow integrity diagnosis function to UBSan runtime library.
Also includes execution tests for the feature.

Differential Revision: http://reviews.llvm.org/D10269

llvm-svn: 240111
2015-06-19 01:52:55 +00:00
Alexey Samsonov 2a567835d1 Revert "Revert "[CMake] LSan is not actually available on Darwin.""
Re-land fixed version of r239955.

llvm-svn: 240108
2015-06-19 01:34:06 +00:00
Evgeniy Stepanov 9a10674079 [msan] Intercept fopencookie.
https://code.google.com/p/memory-sanitizer/issues/detail?id=86

llvm-svn: 240107
2015-06-19 01:28:41 +00:00
Dmitry Vyukov 70dd0e2087 tsan: mark meta shadow as NOHUGEPAGE
Meta shadow is compressing and we don't flush it,
so it makes sense to mark it as NOHUGEPAGE to not over-allocate memory.
On one program it reduces memory consumption from 5GB to 2.5GB.

llvm-svn: 240028
2015-06-18 16:57:37 +00:00
Justin Bogner 66afb72e2a Revert "[CMake] LSan is not actually available on Darwin."
This change makes cmake fail to even run on Darwin with errors
evaluating "$<TARGET_OBJECTS:RTInterception.x86_64>".

This reverts r239955

llvm-svn: 239985
2015-06-18 03:39:51 +00:00
Alexey Samsonov b412c47934 [CMake] Remove redundant checks in TSan CMakeLists.txt
llvm-svn: 239956
2015-06-17 22:24:49 +00:00
Alexey Samsonov 5cce9e1e59 [CMake] LSan is not actually available on Darwin.
llvm-svn: 239955
2015-06-17 22:24:44 +00:00
Peter Collingbourne b64d0b1e6d Protection against stack-based memory corruption errors using SafeStack: compiler-rt runtime support library
This patch adds runtime support for the Safe Stack protection to compiler-rt
(see http://reviews.llvm.org/D6094 for the detailed description of the
Safe Stack).

This patch is our implementation of the safe stack on top of compiler-rt. The
patch adds basic runtime support for the safe stack to compiler-rt that
manages unsafe stack allocation/deallocation for each thread.

Original patch by Volodymyr Kuznetsov and others at the Dependable Systems
Lab at EPFL; updates and upstreaming by myself.

Differential Revision: http://reviews.llvm.org/D6096

llvm-svn: 239763
2015-06-15 21:08:47 +00:00
Chris Bieneman 6bd006f31a [CMake] Cleanup add_compiler_rt_object_library to be platform-agnostic
Summary:
This change takes darwin-specific goop that was scattered around CMakeLists files and spread between add_compiler_rt_object_library and add_compiler_rt_darwin_object_library and moves it all under add_compiler_rt_object_library.

The goal of this is to try to push platform handling as low in the utility functions as possible.

Reviewers: rnk, samsonov

Reviewed By: rnk, samsonov

Subscribers: rnk, rsmith, llvm-commits

Differential Revision: http://reviews.llvm.org/D10250

llvm-svn: 239498
2015-06-10 23:55:07 +00:00
Evgeniy Stepanov e33f64f682 [asan] Fix Android build for API >= 21.
/code/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:971:8: error: address of function 'dl_iterate_phdr' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
  if (!dl_iterate_phdr)
      ~^~~~~~~~~~~~~~~
/code/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:971:8: note: prefix with the address-of operator to silence this warning
  if (!dl_iterate_phdr)
       ^
       &

llvm-svn: 239321
2015-06-08 18:15:52 +00:00
Evgeniy Stepanov 572cd900b2 [asan] Fix build of AsanNoinstTest on Android.
Some of the asan-ubsan build changes were not replicated in the android branch in CMakeLists.

llvm-svn: 239320
2015-06-08 18:03:33 +00:00
Alexey Samsonov 9f97bf0943 [ASan] Bump maximum allowed malloc() size in ASan allocator to 1Tb.
1Tb of RAM ought to be enough for anybody.

llvm-svn: 239187
2015-06-05 20:50:02 +00:00
Yury Gribov 2d45554b82 [ASan] Add process basename to log name and error message to
simplify analysis of sanitized systems logs.
    
Differential Revision: http://reviews.llvm.org/D7333

llvm-svn: 239134
2015-06-05 06:08:23 +00:00
Yury Gribov e244b49f2c [ASan] Fix Darwin and Windows builds.
llvm-svn: 239027
2015-06-04 07:56:19 +00:00
Yury Gribov c019a57099 [ASan] Make binary name reader cross-platform.
Differential Revision: http://reviews.llvm.org/D10213

llvm-svn: 239020
2015-06-04 07:29:43 +00:00
Yury Gribov c5243f0c6a [ASan] Move ASan runtime library self-checks to a more appropriate place.
llvm-svn: 239018
2015-06-04 07:23:09 +00:00
Filipe Cabecinhas 215046bf98 [sanitizer_common] Added VS-style output for source locations
Summary:
With this patch, we have a flag to toggle displaying source locations in
the regular style:
file:line:column

or Visual Studio style:
file(line,column)

This way, they get picked up on the Visual Studio output window and one
can double-click them to get to that file location.

Reviewers: samsonov, rnk

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10113

llvm-svn: 239000
2015-06-04 01:20:06 +00:00
Evgeniy Stepanov 1b3d46ec30 [asan] Fix undefined MAP_NORESERVE on FreeBSD.
llvm-svn: 238995
2015-06-04 00:42:15 +00:00
Evgeniy Stepanov 42fb96652b [sanitizer] Add -lrt to dyndd link line.
llvm-svn: 238626
2015-05-29 22:57:15 +00:00
Evgeniy Stepanov 8e9c70be7f Add descriptive names to sanitizer entries in /proc/self/maps. Helps debugging.
This is done by creating a named shared memory region, unlinking it
and setting up a private (i.e. copy-on-write) mapping of that instead
of a regular anonymous mapping. I've experimented with regular
(sparse) files, but they can not be scaled to the size of MSan shadow
mapping, at least on Linux/X86_64 and ext3 fs.

Controlled by a common flag, decorate_proc_maps, disabled by default.

This patch has a few shortcomings:
* not all mappings are annotated, especially in TSan.
* our handling of memset() of shadow via mmap() puts small anonymous
  mappings inside larger named mappings, which looks ugly and can, in
  theory, hit the mapping number limit.

llvm-svn: 238621
2015-05-29 22:31:28 +00:00
Reid Kleckner ea09c99a4c Use sanitizer_atomic_clang.h with clang-cl instead of the MSVC variant
llvm-svn: 238585
2015-05-29 17:56:39 +00:00
Evgeniy Stepanov bab1a075df [asan] Add new(unsigned int) to ASan interface list.
Also, sized-delete with size_t == unsigned int.
These guys appear when building for Android with gnu-stl.

Fixes a number of ASan tests in that particular configuration.

llvm-svn: 238484
2015-05-28 20:37:50 +00:00
Ed Maste 3fa1b65c1c Use /usr/bin/env to find python
Python may not be /usr/bin/python on some systems. For example, on
FreeBSD it will be /usr/local/bin/python.

Reviewers: samsonov
Differential Revision: http://reviews.llvm.org/D9914

llvm-svn: 238428
2015-05-28 14:53:14 +00:00
Yury Gribov 73570f4323 [ASan] Add new interceptors to asan_win_dll_thunk.cc to fix build errors on Windows.
Patch by Maria Guseva!

llvm-svn: 238407
2015-05-28 10:21:59 +00:00
Yury Gribov 0ca65fd83d [sanitizer] More string interceptors: strstr, strcasestr, strspn, strcspn, strpbrk.
Patch by Maria Guseva.

Differential Revision: http://reviews.llvm.org/D9017

llvm-svn: 238406
2015-05-28 09:24:33 +00:00
Yury Gribov 63d9764585 [ASan] New approach to dynamic allocas unpoisoning. Patch by Max Ostapenko!
Differential Revision: http://reviews.llvm.org/D7098

llvm-svn: 238401
2015-05-28 07:49:05 +00:00
Evgeniy Stepanov 1f1d9f27fd [asan] Fix build dependency issues with ASan version list file.
CMake pre-3.1 has a bug where a shared library depending on a custom_target
does not really depend on it.

This commit implements a hilariously ugly workaround for this problem, see
code comments for more details.

llvm-svn: 238367
2015-05-27 22:38:01 +00:00
Evgeniy Stepanov 45328240dc [msan] Mprotect all inaccessible memory regions.
Fix 2 bugs in memory mapping setup:
- the invalid region at offset 0 was not protected because mmap at
  address 0 fails with EPERM on most Linux systems. We did not
  notice this because the check condition was flipped: the code was
  checking that mprotect has failed. And the test that was supposed
  to catch this was weakened by the mitigations in the mmap
  interceptor.
- when running without origins, the origin shadow range was left
  unprotected.

The new test ensures that mmap w/o MAP_FIXED always returns valid
application addresses.

llvm-svn: 238109
2015-05-24 02:47:59 +00:00
Kostya Serebryany 05425a88cd [dfsan] ignore more __sanitizer callbacks
llvm-svn: 238085
2015-05-23 01:56:39 +00:00
Saleem Abdulrasool a3b3952ccd builtins: mark functions as aapcs on Windows
Windows does not use AAPCS, but rather AAPCS-VFP, and thus the functions which
are assumed to be AAPCS will cause invalid argument setup.  Ensure that the
functions are marked as AAPCS.

llvm-svn: 238056
2015-05-22 21:47:24 +00:00
Reid Kleckner 1cdd948f5b [ASan/Win] Add DLL thunk for new coverage hook
Should fix dll_host.cc test failing on bots.

llvm-svn: 237725
2015-05-19 21:02:23 +00:00
Evgeniy Stepanov 7f6290ca9a [sanitizer] Recognize static TLS in __tls_get_addr interceptor.
Current code tries to find the dynamic TLS header to the left of the
TLS block without checking that it's not a static TLS allocation.

llvm-svn: 237495
2015-05-16 00:34:15 +00:00