Commit Graph

7069 Commits

Author SHA1 Message Date
Dean Michael Berris 66faaceeb1 [XRay][compiler-rt] Return the pointer associated with the function instead of the sled
Summary:
XRay has erroneously been returning the address of the first sled in the
instrumentation map for a function id instead of the (runtime-relocated)
functison address. This causes confusion and issues for applications
where:

  - The first sled in the function may not be an entry sled (due to
    re-ordering or some other reason).
  - The caller attempts to find a symbol associated with the pointer at
    runtime, because the sled may not be exactly where the function's
    known address is (in case of inlined functions or those that have an
    external definition for symbols).

This fixes http://llvm.org/PR34340.

Reviewers: eizan

Subscribers: llvm-commits

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

llvm-svn: 311871
2017-08-28 03:58:23 +00:00
Petr Hosek 00b760ed48 [asan] Move __asan_handle_no_return to public header
Heretofore asan_handle_no_return was used only by interceptors,
i.e. code private to the ASan runtime. However, on systems without
interceptors, code like libc++abi is built with -fsanitize=address
itself and should call asan_handle_no_return directly from
__cxa_throw so that no interceptor is required.

Patch by Roland McGrath

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

llvm-svn: 311869
2017-08-28 00:45:12 +00:00
George Karpenkov bebcbfb46d [libFuzzer] Use custom allocators for STL containers in libFuzzer.
Avoids ODR violations causing spurious ASAN warnings.

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

llvm-svn: 311866
2017-08-27 23:20:09 +00:00
Michal Gorny 7298595a2c Revert r311842 - [cmake] Remove i686 target that is duplicate to i386
The required change in clang is being reverted because of the Android
build bot failure.

llvm-svn: 311859
2017-08-27 20:37:06 +00:00
Michal Gorny 34ca7168ae [cmake] Remove i686 target that is duplicate to i386
Remove the explicit i686 target that is completely duplicate to
the i386 target, with the latter being used more commonly.

1. The runtime built for i686 will be identical to the one built for
i386.

2. Supporting both -i386 and -i686 suffixes causes unnecessary confusion
on the clang end which has to expect either of them.

3. The checks are based on wrong assumption that __i686__ is defined for
all newer x86 CPUs. In fact, it is only declared when -march=i686 is
explicitly used. It is not available when a more specific (or newer)
-march is used.

Curious enough, if CFLAGS contain -march=i686, the runtime will be built
both for i386 and i686. For any other value, only i386 variant will be
built.

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

llvm-svn: 311842
2017-08-27 07:44:41 +00:00
George Karpenkov 24069a0424 Revert "[libFuzzer] Use custom allocators for STL containers in libFuzzer"
This reverts commit 3539efc2f2218dba2bcbd645d0fe276f2b5cf588.

llvm-svn: 311831
2017-08-26 17:50:35 +00:00
George Karpenkov d50410bfb1 [libFuzzer] Use custom allocators for STL containers in libFuzzer
Avoids ODR violations causing spurious ASAN container overflow warnings.

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

llvm-svn: 311830
2017-08-26 17:17:37 +00:00
Kostya Serebryany 09c4161029 [libFuzzer] prepare tests for switching from -fsanitize-coverage=trace-pc-guard to -fsanitize-coverage=inline-8bit-counters
llvm-svn: 311798
2017-08-25 20:20:46 +00:00
Kostya Serebryany 2eef816e6e [libFuzzer] add -print_funcs=1 (on bey default): print newly discovered functions during fuzzing
llvm-svn: 311797
2017-08-25 20:09:25 +00:00
Max Moroz 1dbb7578ff [compiler-rt] Test commit: remove some trailing white spaces.
Summary: [compiler-rt] Test commit: remove some trailing white spaces.

Reviewers: Dor1s

Reviewed By: Dor1s

Subscribers: dberris

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

llvm-svn: 311796
2017-08-25 19:36:30 +00:00
Kostya Serebryany d3e4b7e24a [sanitizer-coverage] extend fsanitize-coverage=pc-table with flags for every PC
llvm-svn: 311794
2017-08-25 19:29:47 +00:00
Dmitry Vyukov 714ac2e781 tsan: don't pass bogus PCs to __tsan_symbolize_external
See the added comment for an explanation.

Reviewed in https://reviews.llvm.org/D37107

llvm-svn: 311768
2017-08-25 08:52:28 +00:00
Xinliang David Li c7c5303fa3 [Profile] create a copy of profile file name from environment
Original patch by Max Moroz.

Differential Revsion: http://reviews.llvm.org/D36903

llvm-svn: 311607
2017-08-23 21:39:33 +00:00
Oleg Ranevskyy 6c75b51bb5 [ARM][Compiler-rt] Fix AEABI builtins to correctly pass arguments to non-AEABI functions on HF targets
Summary:
This is a patch for PR34167.

On HF targets functions like `__{eq,lt,le,ge,gt}df2` and `__{eq,lt,le,ge,gt}sf2` expect their arguments to be passed in d/s registers, while some of the AEABI builtins pass them in r registers.

Reviewers: compnerd, peter.smith, asl

Reviewed By: peter.smith, asl

Subscribers: peter.smith, aemerson, dberris, javed.absar, llvm-commits, asl, kristof.beyls

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

llvm-svn: 311555
2017-08-23 14:26:31 +00:00
Dean Michael Berris 71f88a955d [XRay][compiler-rt] Support sled versioning for custom event sleds
Summary:
This change introduces versions to the instrumentation map entries we
emit for XRay instrumentaiton points. The status quo for the version is
currently set to 0 (as emitted by the LLVM back-end), and versions will
count up to 255 (unsigned char).

This change is in preparation for supporting the newer version of the
custom event sleds that will be emitted by the LLVM compiler.

While we're here, we take the opportunity to stash more registers and
align the stack properly in the __xray_CustomEvent trampoline.

Reviewers: kpw, pcc, dblaikie

Subscribers: llvm-commits

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

llvm-svn: 311524
2017-08-23 04:42:37 +00:00
Hans Wennborg c5e7cee0a2 [profile] Fix warning about C++ style comment in C file
llvm-svn: 311496
2017-08-22 21:54:37 +00:00
Hans Wennborg 67ef655026 [esan] Use stack_t instead of struct sigaltstack (PR34011)
The struct tag is going away in soon-to-be-released glibc 2.26 and the
stack_t typedef seems to have been there forever.

Patch by Bernhard Rosenkraenzer!

llvm-svn: 311495
2017-08-22 21:54:37 +00:00
Matt Morehouse b1fa8255db [SanitizerCoverage] Optimize stack-depth instrumentation.
Summary:
Use the initialexec TLS type and eliminate calls to the TLS
wrapper.  Fixes the sanitizer-x86_64-linux-fuzzer bot failure.

Reviewers: vitalybuka, kcc

Reviewed By: kcc

Subscribers: hiraditya, llvm-commits

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

llvm-svn: 311490
2017-08-22 21:28:29 +00:00
George Karpenkov 6bb45f793f [libFuzzer] Move check for thread_local back into libFuzzer's CMake,
as it breaks builtin standalone build on some bots.

llvm-svn: 311482
2017-08-22 18:34:28 +00:00
Saleem Abdulrasool 84315ec513 Revert "builtins: erase `struct` modifier for EH personality"
This reverts SVN r311425 which broke one of the buildbots.  It is
unclear what header is being used there.  Revert it until that can be
handled properly.

llvm-svn: 311426
2017-08-22 04:19:51 +00:00
Saleem Abdulrasool 94fd3c41fb builtins: erase `struct` modifier for EH personality
On ARM, the `_Unwind_Exception` is an alias for
`struct _Unwind_Control_Block`.  The extra `struct` modifier causes a
warning due to the locally scoped type.  Special case this to avoid the
warning.  NFC.

llvm-svn: 311425
2017-08-22 04:05:50 +00:00
Kostya Serebryany 33fb36c353 [libFuzzer] fix the stack-depth initialization, add a lit test for DeepRecursionTest.cpp
llvm-svn: 311421
2017-08-22 01:50:00 +00:00
Kostya Serebryany f65cf64fa2 [libFuzzer] apply changes lost during the migration to compiler-rt
llvm-svn: 311420
2017-08-22 01:28:32 +00:00
Kostya Serebryany 055f441bd2 [libFuzzer] better README.txt
llvm-svn: 311418
2017-08-22 01:15:40 +00:00
Kostya Serebryany 0977643039 [libFuzzer] remove stale file
llvm-svn: 311417
2017-08-22 01:14:53 +00:00
George Karpenkov 10ab2ace13 Move libFuzzer to compiler_rt.
Resulting library binaries will be named libclang_rt.fuzzer*, and will
be placed in Clang toolchain, allowing redistribution.

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

llvm-svn: 311407
2017-08-21 23:25:50 +00:00
Evgeniy Stepanov 753297e634 Fix ASan version list dependency in multi-arch builds.
Fixes PR32390.

Patch by Andrey Krayniak.

llvm-svn: 311394
2017-08-21 22:31:31 +00:00
Kostya Kortchinsky 0d3439a29c [sanitizer] Do not over-dup string flags
Summary:
String flags values appear to be duped twice. Once in `FlagParser::parse_flag`
using the `LowLevelAllocator` via `ll_strndup`, once in
`FlagHandler<const char *>::Parse` using the `InternalAllocator` via
`internal_strdup`. It looks like the second one is redundant, as the memory
for the first one is never freed and not used for anything else.

Assigning the value to the flag instead of duping it has a few advantages:
- if it was the only use of the `InternalAllocator` (which is the case for
  Scudo), then the related code will not be compiled it, which saves us a
  whole instantiation of the CombinedAllocator worth of extra code;
- in the event a string flag is parsed, the `InternalAllocator` would have
  created a whole SizeClassAllocator32 region for a single allocation, which is
  kind of wasteful.
- also, the string is dup'ed twice for the whole lifetime of a process.

I tested check-{sanitizer,asan,tsan,ubsan,scudo} successfully, so as far as I
can tell this doesn't appear to have bad side effects.

Reviewers: eugenis, alekseyshl

Reviewed By: eugenis

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 311386
2017-08-21 21:25:38 +00:00
George Karpenkov 9d7a75d617 Fix multi-architecture build for lib/xray.
Differential Revision: https://reviews.llvm.org/D36881

llvm-svn: 311379
2017-08-21 20:28:32 +00:00
Vlad Tsyrklevich 599b11784a [TSan] Update test values
Summary:
This test was broken by the tail duplication logic being changed in
r311139, update the test values and add a note about how to properly run
a benchmark to verify that the values are safe to update.

Reviewers: vitalybuka

Reviewed By: vitalybuka

Subscribers: dvyukov, kubamracek

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

llvm-svn: 311189
2017-08-18 19:22:39 +00:00
Francis Ricci 69639c24f9 Add C++17 aligned new/delete interceptors to standalone lsan
Summary: Based on r282019.

Reviewers: kcc, jakubjelinek, alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 311030
2017-08-16 18:09:29 +00:00
Kostya Kortchinsky 43917720a7 [scudo] Application & platform compatibility changes
Summary:
This patch changes a few (small) things around for compatibility purposes for
the current Android & Fuchsia work:
- `realloc`'ing some memory that was not allocated with `malloc`, `calloc` or
  `realloc`, while UB according to http://pubs.opengroup.org/onlinepubs/009695399/functions/realloc.html
  is more common that one would think. We now only check this if
  `DeallocationTypeMismatch` is set; change the "mismatch" error
  messages to be more homogeneous;
- some sketchily written but widely used libraries expect a call to `realloc`
  to copy the usable size of the old chunk to the new one instead of the
  requested size. We have to begrundingly abide by this de-facto standard.
  This doesn't seem to impact security either way, unless someone comes up with
  something we didn't think about;
- the CRC32 intrinsics for 64-bit take a 64-bit first argument. This is
  misleading as the upper 32 bits end up being ignored. This was also raising
  `-Wconversion` errors. Change things to take a `u32` as first argument.
  This also means we were (and are) only using 32 bits of the Cookie - not a
  big thing, but worth mentioning.
- Includes-wise: prefer `stddef.h` to `cstddef`, move `scudo_flags.h` where it
  is actually needed.
- Add tests for the memalign-realloc case, and the realloc-usable-size one.

(Edited typos)

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 311018
2017-08-16 16:40:48 +00:00
George Karpenkov 769124dc5e [sanitizers CMake] NFC Refactor the logic for compiling and generating tests
into a function.

Most CMake configuration under compiler-rt/lib/*/tests have
almost-the-same-but-not-quite functions of the form add_X_[unit]tests
for compiling and running the tests.
Much of the logic is duplicated with minor variations across different
sub-folders.
This can harm productivity for multiple reasons:

For newcomers, resulting CMake files are very large, hard to understand,
and hide the intention of the code.
Changes for enabling certain architectures end up being unnecessarily
large, as they get duplicated across multiple folders.
Adding new sub-projects requires more effort than it should, as a
developer has to again copy-n-paste the configuration, and it's not even
clear from which sub-project it should be copy-n-pasted.
With this change the logic of compile-and-generate-a-set-of-tests is
extracted into a function, which hopefully makes writing and reading
CMake much easier.

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

llvm-svn: 310971
2017-08-15 22:56:10 +00:00
George Karpenkov 83ea28116e [CMake compiler-rt] NFC: Minor CMake refactoring.
Detect ObjC files in `clang_compile` and pass an appropriate flag to a
compiler, also change `clang_compile` to a function.

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

llvm-svn: 310945
2017-08-15 18:38:14 +00:00
George Karpenkov d46f17db06 [compiler-rt CMake] CMake refactoring: create directories in helper func.
Change macro to a function, move creating test directory into
`add_compiler_rt_test`.

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

llvm-svn: 310943
2017-08-15 18:32:28 +00:00
Xinliang David Li 1c9320cd4d Revert r310857 due to internal test failure
llvm-svn: 310907
2017-08-15 03:13:01 +00:00
Weiming Zhao 1c617be054 [builtins] fix build error on non-ARM for r310884
llvm-svn: 310890
2017-08-14 21:44:33 +00:00
Weiming Zhao 8bf15723ae [builtins][ARM] Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA
Summary:
Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation
 mode (-mthumb, -marm), it reflect's capability of given CPU.

Due to this:
•use tbumb and thumb2 insteand of __ARM_ARCH_ISA_THUMB
•use '.thumb' directive consistently in all affected files
•decorate all thumb functions using DEFINE_COMPILERRT_THUMB_FUNCTION()

(This is based off  Michal's patch https://reviews.llvm.org/D30938)

Reviewers: dim, rengolin, compnerd, strejda

Reviewed By: compnerd

Subscribers: peter.smith, kubamracek, mgorny, javed.absar, kristof.beyls, jamesduley, aemerson, llvm-commits

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

llvm-svn: 310884
2017-08-14 20:48:47 +00:00
Xinliang David Li 533d4c90bd [PGO] Add support for relocate profile dumping directory
Differential Revsion: http://reviews.llvm.org/D36648

llvm-svn: 310857
2017-08-14 16:51:05 +00:00
Kostya Kortchinsky e1dde07640 [sanitizers] Add a blocking boolean to GetRandom prototype
Summary:
On platforms with `getrandom`, the system call defaults to blocking. This
becomes an issue in the very early stage of the boot for Scudo, when the RNG
source is not set-up yet: the syscall will block and we'll stall.

Introduce a parameter to specify that the function should not block, defaulting
to blocking as the underlying syscall does.

Update Scudo to use the non-blocking version.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 310839
2017-08-14 14:53:47 +00:00
Kamil Rytarowski 4ad374ea76 Add NetBSD support in asan_linux.cc
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

llvm-svn: 310647
2017-08-10 18:51:51 +00:00
Kamil Rytarowski fbd51b954d Enable SafeStack on NetBSD
Summary:
make check-safestack:

-- Testing: 8 tests, 8 threads --
Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
Testing Time: 0.44s
  Expected Passes    : 7
  Unsupported Tests  : 1

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, kcc, fjricci, filcab

Reviewed By: vitalybuka

Subscribers: mgorny, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 310646
2017-08-10 18:40:09 +00:00
Alexander Potapenko 925c0741ab [sanitizer_common] Update sanitizers w.r.t. the new comparisons instrumentation API
Added declarations of __sanitizer_cov_trace_const_cmp[1248] callbacks.
For more details, please see https://reviews.llvm.org/D36465.

Patch by Victor Chibotaru.

llvm-svn: 310596
2017-08-10 14:22:57 +00:00
Oleg Ranevskyy a02114b651 [compiler-rt][ARM] Fix filtering of ARM targets
Summary:
Similarly to i686, the ARM build target has multiple names, such as armhf, armv7 and so on. Currently we get duplicated symbol definitions for these targets while compiling the library. Each duplicated definition has its generic version from `lib/builtins` and an ARM-specialized version from `lib/builtins/arm`. 

This patch fixes filtering for ARM to ignore the generic definitions if they have their ARM specializations.

Reviewers: compnerd

Reviewed By: compnerd

Subscribers: aemerson, dberris, llvm-commits, mgorny, asl, kristof.beyls

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

llvm-svn: 310588
2017-08-10 13:27:29 +00:00
Vitaly Buka 7030354744 [asan] Refactor thread creation bookkeeping
Summary:
This is a pure refactoring change.  It paves the way for OS-specific
implementations, such as Fuchsia's, that can do most of the
per-thread bookkeeping work in the creator thread before the new
thread actually starts.  This model is simpler and cleaner, avoiding
some race issues that the interceptor code for thread creation has
to do for the existing OS-specific implementations.

Submitted on behalf of Roland McGrath.

Reviewers: vitalybuka, alekseyshl, kcc

Reviewed By: alekseyshl

Subscribers: phosek, filcab, llvm-commits, kubamracek

Tags: #sanitizers

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

llvm-svn: 310432
2017-08-09 00:38:57 +00:00
Vitaly Buka 83832fe7db [asan] Complete the Fuchsia port
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

llvm-svn: 310431
2017-08-09 00:21:45 +00:00
Kamil Rytarowski e5a9d9f17c Try to appease compiler and break multiline comment.
llvm-svn: 310428
2017-08-08 23:31:21 +00:00
Reid Kleckner c3fc3bc5af [winasan] Fix hotpatching ntdll!strcpy for Win10 creators edition
The 9 byte nop is a suffix of the 10 byte nop, and we need at most 6
bytes.

ntdll's version of strcpy is written in assembly and is very clever.
strcat tail calls strcpy but with a slightly different arrangement of
argument registers at an alternate entry point. It looks like this:

  ntdll!strcpy:
  00007ffd`64e8a7a0 4c8bd9          mov     r11,rcx
  ntdll!__entry_from_strcat_in_strcpy:
  00007ffd`64e8a7a3 482bca          sub     rcx,rdx
  00007ffd`64e8a7a6 f6c207          test    dl,7

If we overwrite more than two bytes in our interceptor, that label will
no longer be a valid instruction boundary.

By recognizing the 9 byte nop, we use the two byte backwards branch to
start our trampoline, avoiding this issue.

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

Patch by David Major

llvm-svn: 310419
2017-08-08 21:18:36 +00:00
Kamil Rytarowski a1e4edd155 Add NetBSD support in asan_malloc_linux.cc
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
2017-08-08 20:52:54 +00:00
Kamil Rytarowski c5c9ba1ca9 Add NetBSD support in asan_symbolize.py
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, filcab, vitalybuka, kcc, fjricci

Reviewed By: fjricci

Subscribers: kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 310413
2017-08-08 20:50:07 +00:00