Commit Graph

3961 Commits

Author SHA1 Message Date
Vedant Kumar 2492b5a125 [profile] Support online merging with continuous sync mode
Make it possible to use online profile merging ("%m" mode) with
continuous sync ("%c" mode).

To implement this, the merged profile is locked in the runtime
initialization step and either a) filled out for the first time or b)
checked for compatibility. Then, the profile can simply be mmap()'d with
MAP_SHARED set. With the mmap() in place, counter updates from every
process which uses an image are mapped onto the same set of physical
pages assigned by the filesystem cache. After the mmap() is set up, the
profile is unlocked.

Differential Revision: https://reviews.llvm.org/D69586
2019-11-18 12:56:58 -08:00
Yi Kong 1689ad27af [builtins] Implement rounding mode support for i386/x86_64
Differential Revision: https://reviews.llvm.org/D69870
2019-11-18 10:32:40 -08:00
Julian Lettner b0567be2b4 [ASan] Mark test as UNSUPPORTED for iOS simulator
coverage-fork.cpp uses `fork()` which requires additional permissions
in the iOS simulator sandbox.  We cannot use `sandbox-exec` to grant
these permissions since this is a Posix (not Darwin) test.
2019-11-18 08:00:46 -08:00
Alexandre Ganea 478ad94c8e [GCOV] Skip artificial functions from being emitted
This is a patch to support  D66328, which was reverted until this lands.

Enable a compiler-rt test that used to fail previously with D66328.

Differential Revision: https://reviews.llvm.org/D67283
2019-11-15 14:23:11 -05:00
Dan Liew 4c39f34199 [SanitizerCommon] Print the current value of options when printing out help.
Summary:
Previously it wasn't obvious what the default value of various sanitizer
options were. A very close approximation of the "default values" for the
options are the current value of the options at the time of printing the
help output.

In the case that no other options are provided then the current values
are the default values (apart from `help`).

```
ASAN_OPTIONS=help=1 ./program
```

This patch causes the current option values to be printed when the
`help` output is enabled. The original intention for this patch was to append
`(Default: <value>)` to an option's help text. However because this
is technically wrong (and misleading) I've opted to append
`(Current Value: <value>)` instead.

When trying to implement a way of displaying the default value of the
options I tried another solution where the default value used in `*.inc` files
were used to create compile time strings that where used when printing
the help output. This solution was not satisfactory for several reasons:

* Stringifying the default values with the preprocessor did not work very
well in several cases.  Some options contain boolean operators which no
amount of macro expansion can get rid of.
* It was much more invasive than this patch. Every sanitizer had to be changed.
* The settings of `__<sanitizer>_default_options()` are ignored.

For those reasons I opted for the solution in this patch.

rdar://problem/42567204

Reviewers: kubamracek, yln, kcc, dvyukov, vitalybuka, cryptoad, eugenis, samsonov

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D69546
2019-11-14 14:04:34 -08:00
Sterling Augustine 38c356176b Fix include guard and properly order __deregister_frame_info.
Summary:
This patch fixes two problems with the crtbegin.c as written:

1. In do_init, register_frame_info is not guarded by a #define, but in
do_fini, deregister_frame_info is guarded by #ifndef
CRT_HAS_INITFINI_ARRAY. Thus when CRT_HAS_INITFINI_ARRAY is not
defined, frames are registered but then never deregistered.

The frame registry mechanism builds a linked-list from the .so's
static variable do_init.object, and when the .so is unloaded, this
memory becomes invalid and should be deregistered.

Further, libgcc's crtbegin treats the frame registry as independent
from the initfini array mechanism.

This patch fixes this by adding a new #define,
"EH_USE_FRAME_INFO_REGISTRY", which is set by the cmake option
COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY Currently, do_init calls
register_frame_info, and then calls the binary's constructors. This
allows constructors to safely use libunwind. However, do_fini calls
deregister_frame_info and then calls the binary's destructors. This
prevents destructors from safely using libunwind.

This patch also switches that ordering, so that destructors can safely
use libunwind. As it happens, this is a fairly common scenario for
thread sanitizer.
2019-11-12 14:54:41 -08:00
Jan Korous 99e2cba219 Reland "[compiler-rt] Fix tests after 03b84e4f6d0"
This reverts commit d6be9273c6.
2019-11-08 14:28:32 -08:00
Lei Huang 71f4761431 [PowerPC][compiler-rt][builtins]Fix __fixunstfti builtin on PowerPC
__fixunstfti converts a long double (IBM double-double) to an unsigned 128 bit
integer.  This patch enables it to handle a previously unhandled case in which
a negative low double may impact the result of the conversion.

Collaborated with @masoud.ataei and @renenkel.
Patch By: Baptiste Saleil

Differential Revision: https://reviews.llvm.org/D69193
2019-11-08 11:57:09 -06:00
Jeremy Morse d6be9273c6 Revert "[compiler-rt] Fix tests after 03b84e4f6d0"
This reverts commit bdeb2724f0.

(Reverting 03b84e4f6d, so this must come out as well)
2019-11-08 12:07:42 +00:00
Jan Korous bdeb2724f0 [compiler-rt] Fix tests after 03b84e4f6d
Fallout from:
[clang] Report sanitizer blacklist as a dependency in cc1

Default blacklists are now passed via -fsanitize-system-blacklist from driver to cc1.
2019-11-07 14:40:22 -08:00
Kamil Rytarowski e345bc6e65 [compiler-rt] [msan] Support POSIX iconv(3) on NetBSD 9.99.17+
Fixes build of test.
2019-11-04 01:08:53 +01:00
Vedant Kumar d889d1efef [profile] Add a mode to continuously sync counter updates to a file
Add support for continuously syncing profile counter updates to a file.

The motivation for this is that programs do not always exit cleanly. On
iOS, for example, programs are usually killed via a signal from the OS.
Running atexit() handlers after catching a signal is unreliable, so some
method for progressively writing out profile data is necessary.

The approach taken here is to mmap() the `__llvm_prf_cnts` section onto
a raw profile. To do this, the linker must page-align the counter and
data sections, and the runtime must ensure that counters are mapped to a
page-aligned offset within a raw profile.

Continuous mode is (for the moment) incompatible with the online merging
mode. This limitation is lifted in https://reviews.llvm.org/D69586.

Continuous mode is also (for the moment) incompatible with value
profiling, as I'm not sure whether there is interest in this and the
implementation may be tricky.

As I have not been able to test extensively on non-Darwin platforms,
only Darwin support is included for the moment. However, continuous mode
may "just work" without modification on Linux and some UNIX-likes. AIUI
the default value for the GNU linker's `--section-alignment` flag is set
to the page size on many systems. This appears to be true for LLD as
well, as its `no_nmagic` option is on by default. Continuous mode will
not "just work" on Fuchsia or Windows, as it's not possible to mmap() a
section on these platforms. There is a proposal to add a layer of
indirection to the profile instrumentation to support these platforms.

rdar://54210980

Differential Revision: https://reviews.llvm.org/D68351
2019-10-31 16:04:09 -07:00
Vedant Kumar ade776b584 [profile] Clean up stale raw profiles in instrprof-write-file.c 2019-10-31 16:04:08 -07:00
Evgenii Stepanov 13e04607f7 [asan] Provide an interface to update an allocation stack trace.
Summary:
Sometimes an allocation stack trace is not very informative. Provide a
way to replace it with a stack trace of the user's choice.

Reviewers: pcc, kcc

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D69208
2019-10-31 13:54:46 -07:00
Dan Liew 23a33d450b Revert "[Builtins] Downgrade duplicate source file warning from a fatal error to a warning."
This reverts commit dc748816e2.

Now that 8ea148dc0c has landed it should
be safe to turning the warning back into a fatal error.
2019-10-30 16:21:46 -07:00
Matt Morehouse 7904bd9409 [sanitizer_common] Create max_allocation_size_mb flag.
Summary:
The flag allows the user to specify a maximum allocation size that the
sanitizers will honor.  Any larger allocations will return nullptr or
crash depending on allocator_may_return_null.

Reviewers: kcc, eugenis

Reviewed By: kcc, eugenis

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D69576
2019-10-30 11:26:05 -07:00
David Tellenbach 67474c60d3 [compiler-rt] libhwasan interceptor ABI intercept longjmp/setjmp
Summary:
The hwasan interceptor ABI doesn't have interceptors for longjmp and setjmp.
This patch introduces them.

We require the size of the jmp_buf on the platform to be at least as large as
the jmp_buf in our implementation. To enforce this we compile
hwasan_type_test.cpp that ensures a compile time failure if this is not true.

Tested on both GCC and clang using an AArch64 virtual machine.

Reviewers: eugenis, kcc, pcc, Sanatizers

Reviewed By: eugenis, Sanatizers

Tags: #sanatizers, #llvm

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

Patch By: Matthew Malcomson <matthew.malcomson@arm.com>
2019-10-30 14:04:40 +00:00
Evgenii Stepanov 7b9d6a2256 [hwasan] Fix typo in the error type.
"alocation-tail-overwritten" -> "allocation-tail-overwritten"
2019-10-28 13:25:45 -07:00
Evgenii Stepanov 3f345732b4 Add missing lld checks in sanitizer tests.
Do not add an lld dependency when this target does not exist. In this
case the system installation of lld is used (or whatever is detected
with -fuse-ld=lld by default).
2019-10-28 10:32:46 -07:00
Evgenii Stepanov a1817996fa Fix lld detection in standalone compiler-rt.
Summary:
Right now all hwasan tests on Android are silently disabled because they
require "has_lld" and standalone compiler-rt can not (and AFAIK was
never able to) set it.

Reviewers: pcc

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

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D69405
2019-10-24 14:46:10 -07:00
Rainer Orth 1876e6c83c [builtins][test] Avoid unportable mmap call in clear_cache_test.c
Within the last two weeks, the Builtins-*-sunos :: clear_cache_test.c started to FAIL
on Solaris.  Running it under truss shows

  mmap(0x00000000, 128, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, 0, 0) Err#22 EINVAL
  _exit(1)

While there are several possible reasons mmap can return EINVAL on Solaris, it turns
out it's this one (from mmap(2)):

  MAP_ANON  was  specified,  but the file descriptor was not
   -1.

And indeed even the Linux mmap(2) documents this as unportable:

  MAP_ANONYMOUS
          The mapping is not backed by any file; its contents are initial‐
          ized to zero.  The fd argument is ignored; however, some  imple‐
          mentations require fd to be -1 if MAP_ANONYMOUS (or MAP_ANON) is
          specified, and portable applications should  ensure  this.   The

This patch follows this advise.  Tested on x86_64-pc-linux-gnu, amd64-pc-solaris2.11
and sparcv9-sun-solaris2.11.

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

llvm-svn: 375490
2019-10-22 08:44:25 +00:00
Evgeniy Stepanov e17b658fc7 [hwasan] Workaround unwinder issues in try-catch test.
Android links the unwinder library to every DSO. The problem is,
unwinder has global state, and hwasan implementation of personality
function wrapper happens to rub it the wrong way.

Switch the test to static libc++ as a temporary workaround.

llvm-svn: 375471
2019-10-21 23:57:12 +00:00
Vedant Kumar b081220cfd [profile] Use -fPIC -shared in a test instead of -dynamiclib
This is more portable than -dynamiclib. Also, fix the path to an input
file that broke when the test was moved in r375315.

llvm-svn: 375317
2019-10-19 00:51:27 +00:00
Vedant Kumar f6a4630417 [profile] Disable instrprof-get-filename-merge-mode.c on Windows
The Windows bots are failing with:

clang: warning: argument unused during compilation: '-dynamiclib' [-Wunused-command-line-argument]
llvm-svn: 375315
2019-10-19 00:46:53 +00:00
Vedant Kumar 937241b0d9 [profile] Do not cache __llvm_profile_get_filename result
When the %m filename pattern is used, the filename is unique to each
image, so the cached value is wrong.

It struck me that the full filename isn't something that's recomputed
often, so perhaps it doesn't need to be cached at all. David Li pointed
out we can go further and just hide lprofCurFilename. This may regress
workflows that depend on using the set-filename API to change filenames
across all loaded DSOs, but this is expected to be very rare.

rdar://55137071

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

llvm-svn: 375301
2019-10-18 23:33:40 +00:00
Evgeniy Stepanov 0b7f320c3a [hwasan] Remove system allocator fallback.
Summary:
This has been an experiment with late malloc interposition, made
possible by a non-standard feature of the Android dynamic loader.

Reviewers: pcc, mmalcomson

Subscribers: srhines, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 375296
2019-10-18 22:36:25 +00:00
Dan Liew dc748816e2 [Builtins] Downgrade duplicate source file warning from a fatal error to a warning.
This is a follow up to r375150 to unbreak the `clang-ppc64be-linux` bot.
The commit caused running the tests to fail due to

```
llvm-lit:
/home/buildbots/ppc64be-clang-multistage-test/clang-ppc64be-multistage/llvm/projects/compiler-rt/test/builtins/Unit/lit.cfg.py:116:
fatal: builtins_source_features contains duplicates:
['librt_has_divtc3']
```

This commit should be reverted once the build system bug for powerpc is
fixed.

llvm-svn: 375162
2019-10-17 20:14:04 +00:00
Dan Liew 5be7eb3ab4 [Builtins] Provide a mechanism to selectively disable tests based on whether an implementation is provided by a builtin library.
Summary:
If a platform removes some builtin implementations (e.g. via the
Darwin-excludes mechanism) then this can lead to test failures because
the test expects an implementation to be available.

To solve this lit features are added for each configuration based
on which sources are included in the builtin library. The features
are of the form `librt_has_<name>` where `<name>` is the name of the
source file with the file extension removed. This handles C and
assembly sources.

With the lit features in place it is possible to make certain tests
require them.

Example:

```
REQUIRES: librt_has_comparedf2
```

All top-level tests in `test/builtins/Unit` (i.e. not under
`arm`, `ppc`, and `riscv`) have been annotated with the appropriate
`REQUIRES: librt_has_*` statement.

rdar://problem/55520987

Reviewers: beanz, steven_wu, arphaman, dexonsmith, phosek, thakis

Subscribers: mgorny, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 375150
2019-10-17 18:12:49 +00:00
Reid Kleckner 0aaa193127 [asan] Update Windows test expectations for LLVM's MS demangler
After r375041 llvm-symbolizer uses it for demangling instead of
UnDecorateSymbolName. LLVM puts spaces after commas while Microsoft does
not.

llvm-svn: 375147
2019-10-17 17:59:11 +00:00
Dmitry Mikulin 034badb312 CFI: wrong type passed to llvm.type.test with multiple inheritance devirtualization.
Differential Revision: https://reviews.llvm.org/D67985

llvm-svn: 374909
2019-10-15 16:32:50 +00:00
Evgeniy Stepanov 53a53e63c8 Add a missing include in test.
A fix for r373993.

llvm-svn: 374448
2019-10-10 20:47:22 +00:00
Julian Lettner 99c9d7bd63 Reland "[ASan] Do not misrepresent high value address dereferences as null dereferences"
Updated: Removed offending TODO comment.

Dereferences with addresses above the 48-bit hardware addressable range
produce "invalid instruction" (instead of "invalid access") hardware
exceptions (there is no hardware address decoding logic for those bits),
and the address provided by this exception is the address of the
instruction (not the faulting address).  The kernel maps the "invalid
instruction" to SEGV, but fails to provide the real fault address.

Because of this ASan lies and says that those cases are null
dereferences.  This downgrades the severity of a found bug in terms of
security.  In the ASan signal handler, we can not provide the real
faulting address, but at least we can try not to lie.

rdar://50366151

Reviewed By: vitalybuka

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

> llvm-svn: 374265

llvm-svn: 374384
2019-10-10 17:19:58 +00:00
David Carlier 69c9c223a0 [Sanitizers] Fix getrandom test
llvm-svn: 374333
2019-10-10 12:48:18 +00:00
David Carlier 90c8b59cfc [Sanitizers] Porting getrandom/getentropy interceptors to FreeBSD
- Available from 12.x branch, by the time it lands next year in FreeBSD tree, the 11.x's might be EOL.
- Intentionally changed the getrandom test to C code as with 12.0 (might be fixed in CURRENT since), there is a linkage issue in C++ context.

Reviewers: emaste, dim, vitalybuka

Reviewed-By: vitalybuka

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

llvm-svn: 374315
2019-10-10 11:31:37 +00:00
Roman Lebedev eb8b6fe745 [UBSan] Split nullptr-and-nonzero-offset-variable.c in another direction
llvm-svn: 374309
2019-10-10 11:03:41 +00:00
Russell Gallop c48e0873af Revert "[ASan] Do not misrepresent high value address dereferences as null dereferences"
As it was breaking bots running sanitizer lint check

This reverts r374265 (git b577efe456)

llvm-svn: 374308
2019-10-10 10:56:52 +00:00
Roman Lebedev 5d59f20cc0 [UBSan] Split nullptr-and-nonzero-offset-variable.cpp into C and C++ variants
I do not understand the BB failire, it fully passes locally.

llvm-svn: 374306
2019-10-10 10:41:42 +00:00
Roman Lebedev 3de28b83c2 [UBSan] Revisit nullptr-and-nonzero-offset-variable.cpp test to hopefully make it pass on sanitizer-windows BB
llvm-svn: 374298
2019-10-10 09:51:13 +00:00
Roman Lebedev 536b0ee40a [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour
Summary:
Quote from http://eel.is/c++draft/expr.add#4:
```
4     When an expression J that has integral type is added to or subtracted
      from an expression P of pointer type, the result has the type of P.
(4.1) If P evaluates to a null pointer value and J evaluates to 0,
      the result is a null pointer value.
(4.2) Otherwise, if P points to an array element i of an array object x with n
      elements ([dcl.array]), the expressions P + J and J + P
      (where J has the value j) point to the (possibly-hypothetical) array
      element i+j of x if 0≤i+j≤n and the expression P - J points to the
      (possibly-hypothetical) array element i−j of x if 0≤i−j≤n.
(4.3) Otherwise, the behavior is undefined.
```

Therefore, as per the standard, applying non-zero offset to `nullptr`
(or making non-`nullptr` a `nullptr`, by subtracting pointer's integral value
from the pointer itself) is undefined behavior. (*if* `nullptr` is not defined,
i.e. e.g. `-fno-delete-null-pointer-checks` was *not* specified.)

To make things more fun, in C (6.5.6p8), applying *any* offset to null pointer
is undefined, although Clang front-end pessimizes the code by not lowering
that info, so this UB is "harmless".

Since rL369789 (D66608 `[InstCombine] icmp eq/ne (gep inbounds P, Idx..), null -> icmp eq/ne P, null`)
LLVM middle-end uses those guarantees for transformations.
If the source contains such UB's, said code may now be miscompiled.
Such miscompilations were already observed:
* https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190826/687838.html
* https://github.com/google/filament/pull/1566

Surprisingly, UBSan does not catch those issues
... until now. This diff teaches UBSan about these UB's.

`getelementpointer inbounds` is a pretty frequent instruction,
so this does have a measurable impact on performance;
I've addressed most of the obvious missing folds (and thus decreased the performance impact by ~5%),
and then re-performed some performance measurements using my [[ https://github.com/darktable-org/rawspeed | RawSpeed ]] benchmark:
(all measurements done with LLVM ToT, the sanitizer never fired.)
* no sanitization vs. existing check: average `+21.62%` slowdown
* existing check vs. check after this patch: average `22.04%` slowdown
* no sanitization vs. this patch: average `48.42%` slowdown

Reviewers: vsk, filcab, rsmith, aaron.ballman, vitalybuka, rjmccall, #sanitizers

Reviewed By: rsmith

Subscribers: kristof.beyls, nickdesaulniers, nikic, ychen, dtzWill, xbolva00, dberris, arphaman, rupprecht, reames, regehr, llvm-commits, cfe-commits

Tags: #clang, #sanitizers, #llvm

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

llvm-svn: 374293
2019-10-10 09:25:02 +00:00
Julian Lettner b577efe456 [ASan] Do not misrepresent high value address dereferences as null dereferences
Dereferences with addresses above the 48-bit hardware addressable range
produce "invalid instruction" (instead of "invalid access") hardware
exceptions (there is no hardware address decoding logic for those bits),
and the address provided by this exception is the address of the
instruction (not the faulting address).  The kernel maps the "invalid
instruction" to SEGV, but fails to provide the real fault address.

Because of this ASan lies and says that those cases are null
dereferences.  This downgrades the severity of a found bug in terms of
security.  In the ASan signal handler, we can not provide the real
faulting address, but at least we can try not to lie.

rdar://50366151

Reviewed By: vitalybuka

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

llvm-svn: 374265
2019-10-10 00:33:04 +00:00
Vitaly Buka ff5a7c4ca6 [sanitizer, NFC] Fix grammar in comment
llvm-svn: 374223
2019-10-09 20:52:39 +00:00
Vitaly Buka 3afc77dbbc [sanitizer] Disable signal_trap_handler on s390
llvm-svn: 374220
2019-10-09 20:48:50 +00:00
Vitaly Buka 39f759189d [sanitizer] Make signal_name a C test
llvm-svn: 374213
2019-10-09 20:22:14 +00:00
Vitaly Buka c3317658cf [sanitizer] Use raise() in test and cover more signals
llvm-svn: 374211
2019-10-09 20:18:27 +00:00
Vitaly Buka d5f92e345c [sanitizer] Fix crypt.cpp on Android again
llvm-svn: 374125
2019-10-08 22:09:51 +00:00
Vitaly Buka f3ae951c09 [sanitizer] Fix crypt.cpp test on Darwin
llvm-svn: 374115
2019-10-08 20:50:46 +00:00
Dan Liew 196eae533b Fix `compiler_rt_logbf_test.c` test failure for Builtins-i386-darwin test suite.
Summary:
It seems that compiler-rt's implementation and Darwin
libm's implementation of `logbf()` differ when given a NaN
with raised sign bit. Strangely this behaviour only happens with
i386 Darwin libm. For x86_64 and x86_64h the existing compiler-rt
implementation matched Darwin libm.

To workaround this the `compiler_rt_logbf_test.c` has been modified
to do a comparison on the `fp_t` type and if that fails check if both
values are NaN. If both values are NaN they are equivalent and no
error needs to be raised.

rdar://problem/55565503

Reviewers: rupprecht, scanon, compnerd, echristo
Subscribers: #sanitizers, llvm-commits
Tags: #llvm, #sanitizers
Differential Revision: https://reviews.llvm.org/D67999

llvm-svn: 374109
2019-10-08 20:06:01 +00:00
Vitaly Buka d8245e7a36 [sanitizer] Disable crypt*.cpp tests on Android
llvm-svn: 374088
2019-10-08 17:06:27 +00:00
Vitaly Buka 54d767f508 [sanitizer] Fix signal_trap_handler.cpp on android
llvm-svn: 374010
2019-10-08 02:00:53 +00:00
Evgeniy Stepanov 2e2c934762 [msan] Add interceptors: crypt, crypt_r.
Reviewers: vitalybuka

Subscribers: srhines, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 373993
2019-10-08 00:00:30 +00:00
Vitaly Buka 9917c76107 [sanitizer] Print SIGTRAP for corresponding signal
Reviewers: eugenis, jfb

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 373979
2019-10-07 22:43:19 +00:00
Vitaly Buka 87dd968849 [tsan] Don't delay SIGTRAP handler
Reviewers: eugenis, jfb

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 373978
2019-10-07 22:43:17 +00:00
Vitaly Buka bb91a833c6 [compiler-rt] Remove O1 tests from signal_line.cpp
It does not work on arm

llvm-svn: 373702
2019-10-04 07:25:53 +00:00
Vitaly Buka 053391fa86 [compiler-rt] Fix signal_line.cpp test
r373682 committed wrong experimental version

llvm-svn: 373684
2019-10-04 00:43:05 +00:00
Vitaly Buka 57b6536ba1 [compiler-rt] Remove O2, O3 from signal_line test for fix android tests
llvm-svn: 373682
2019-10-04 00:38:08 +00:00
Vitaly Buka 6fb03a290b [compiler-rt] More optimization levels in signal_line.cpp test
llvm-svn: 373642
2019-10-03 18:18:35 +00:00
Matt Morehouse 38ac6bdb83 [sanitizer_common] Disable onprint.cpp on Android.
The test fails to find the written file on Android.

llvm-svn: 373531
2019-10-02 21:38:22 +00:00
Vitaly Buka d39e7e2cf1 [compiler-rt] Use GetNextInstructionPc in signal handlers
Summary:
All other stack trace callers assume that PC contains return address.
HWAsan already use GetNextInstructionPc in similar code.

PR43339

Reviewers: eugenis, kcc, jfb

Subscribers: dexonsmith, dberris, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 373529
2019-10-02 21:20:37 +00:00
Matt Morehouse e55c442b1b [sanitizer_common] Rename OnPrint to __sanitizer_on_print.
Summary:
https://reviews.llvm.org/D28596 exposed OnPrint in the global namespace,
which can cause collisions with user-defined OnPrint() functions.

Reviewers: vitalybuka, dvyukov

Reviewed By: vitalybuka, dvyukov

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 373518
2019-10-02 20:13:21 +00:00
Dan Liew bbde056b88 [CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #3.
The main problem here is that `-*-version_min=` was not being passed to
the compiler when building test cases. This can cause problems when
testing on devices running older OSs because Clang would previously
assume the minimum deployment target is the the latest OS in the SDK
which could be much newer than what the device is running.

Previously the generated value looked like this:

`-arch arm64 -isysroot
<path_to_xcode>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk`

With this change it now looks like:

`-arch arm64 -stdlib=libc++ -miphoneos-version-min=8.0 -isysroot
<path_to_xcode>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk`

This mirrors the setting of config.target_cflags on macOS.

This change is made for ASan, LibFuzzer, TSan, and UBSan.

To implement this a new `get_test_cflags_for_apple_platform()` function
has been added that when given an Apple platform name and architecture
returns a string containing the C compiler flags to use when building
tests. This also calls a new helper function `is_valid_apple_platform()`
that validates Apple platform names.

This is the third attempt at landing the patch.

The first attempt (r359305) had to be reverted (r359327) due to a buildbot
failure. The problem was that calling `get_test_cflags_for_apple_platform()`
can trigger a CMake error if the provided architecture is not supported by the
current CMake configuration. Previously, this could be triggered by passing
`-DCOMPILER_RT_ENABLE_IOS=OFF` to CMake. The root cause is that we were
generating test configurations for a list of architectures without checking if
the relevant Sanitizer actually supported that architecture. We now intersect
the list of architectures for an Apple platform with
`<SANITIZER>_SUPPORTED_ARCH` (where `<SANITIZER>` is a Sanitizer name) to
iterate through the correct list of architectures.

The second attempt (r363633) had to be reverted (r363779) due to a build
failure. The failed build was using a modified Apple toolchain where the iOS
simulator SDK was missing. This exposed a bug in the existing UBSan test
generation code where it was assumed that `COMPILER_RT_ENABLE_IOS` implied that
the toolchain supported both iOS and the iOS simulator. This is not true. This
has been fixed by using the list `SANITIZER_COMMON_SUPPORTED_OS` for the list
of supported Apple platforms for UBSan. For consistency with the other
Sanitizers we also now intersect the list of architectures with
UBSAN_SUPPORTED_ARCH.

rdar://problem/50124489

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

llvm-svn: 373405
2019-10-01 23:08:18 +00:00
Matt Morehouse 1c8e05110c [libFuzzer] Remove lazy counters.
Summary: Lazy counters haven't improved performance for large fuzz targets.

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 373403
2019-10-01 22:49:06 +00:00
Evgeniy Stepanov 72131161a4 [msan] Intercept __getrlimit.
Summary:
This interceptor is useful on its own, but the main purpose of this
change is to intercept libpthread initialization on linux/glibc in
order to run __msan_init before any .preinit_array constructors.

We used to trigger on pthread_initialize_minimal -> getrlimit(), but
that call has changed to __getrlimit at some point.

Reviewers: vitalybuka, pcc

Subscribers: jfb, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 373239
2019-09-30 17:49:48 +00:00
Vedant Kumar 84ca5c8cbf Revert "[profile] Add a test dependency on cxx-headers"
This reverts commit b539350f7d006b7d6f42c5c4b5715da87a52e5d8.

See: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/52140/steps/annotate/logs/stdio

The cxx-headers target doesn't exist everywhere.

llvm-svn: 373123
2019-09-27 20:24:48 +00:00
Vedant Kumar 9639f3572a [profile] Mark instrprof-gcov-fork.test UNSUPPORTED on Darwin as well
This test remains flaky everywhere, I think. We should consider deleting
it and accompanying support code in GCOVProfiling: I've stopped short of
doing that now as the gcov exec* tests appear to be stable.

See the thread re: r347779.

llvm-svn: 373121
2019-09-27 20:12:38 +00:00
Vedant Kumar 20daf91af2 [profile] Add a test dependency on cxx-headers
This enables running profile runtime tests which #include <string>, etc.
via just `check-profile`.

llvm-svn: 373120
2019-09-27 20:12:35 +00:00
Peter Collingbourne c336557f02 hwasan: Compatibility fixes for short granules.
We can't use short granules with stack instrumentation when targeting older
API levels because the rest of the system won't understand the short granule
tags stored in shadow memory.

Moreover, we need to be able to let old binaries (which won't understand
short granule tags) run on a new system that supports short granule
tags. Such binaries will call the __hwasan_tag_mismatch function when their
outlined checks fail. We can compensate for the binary's lack of support
for short granules by implementing the short granule part of the check in
the __hwasan_tag_mismatch function. Unfortunately we can't do anything about
inline checks, but I don't believe that we can generate these by default on
aarch64, nor did we do so when the ABI was fixed.

A new function, __hwasan_tag_mismatch_v2, is introduced that lets code
targeting the new runtime avoid redoing the short granule check. Because tag
mismatches are rare this isn't important from a performance perspective; the
main benefit is that it introduces a symbol dependency that prevents binaries
targeting the new runtime from running on older (i.e. incompatible) runtimes.

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

llvm-svn: 373035
2019-09-27 01:02:10 +00:00
Mitch Phillips da3cf61654 [libFuzzer] [NFC] Fix grammar error with "it's"
llvm-svn: 372937
2019-09-26 00:54:30 +00:00
Nico Weber cddc153102 builtins test: Move clear_cache_test.c from a mprotect()ed global to a mmap()ed variable
ld64 in the macOS 10.15 SDK gives __DATA a maxprot of 3, meaning it
can't be made executable at runtime by default.

Change clear_cache_test.c to use mmap()ed data that's mapped as writable
and executable from the beginning, instead of trying to mprotect()ing a
__DATA variable as executable. This fixes the test on macOS with the
10.15 SDK.

PR43407.

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

llvm-svn: 372849
2019-09-25 11:57:51 +00:00
Joachim Protze 886a4ff977 [TSAN] Add read/write range interface functions with PC
Adding annotation function variants __tsan_write_range_pc and
__tsan_read_range_pc to annotate ranged access to memory while providing a
program counter for the access.

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

llvm-svn: 372730
2019-09-24 11:19:02 +00:00
Artem Dergachev 837273711e [llvm-cov] NFC: Specify a specific C++ standard in the test.
Makes life easier for downstream users with customized default standard.

llvm-svn: 372674
2019-09-24 00:01:51 +00:00
Kamil Rytarowski 5fe1e55d35 Avoid memory leak in ASan test
Summary:
Add missing free(3) for the malloc(3) call.

Detected on NetBSD with LSan.

Reviewers: joerg, mgorny, vitalybuka, dvyukov

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers, #llvm

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

llvm-svn: 372460
2019-09-21 07:43:55 +00:00
Evgeniy Stepanov f1b6bd403d [lsan] Fix deadlock in dl_iterate_phdr.
Summary:
Do not grab the allocator lock before calling dl_iterate_phdr. This may
cause a lock order inversion with (valid) user code that uses malloc
inside a dl_iterate_phdr callback.

Reviewers: vitalybuka, hctim

Subscribers: jfb, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 372348
2019-09-19 19:52:57 +00:00
Vedant Kumar c693aa3def [test] Clean up previous raw profile before merging into it
This fixes a test failure in instrprof-set-file-object-merging.c which
seems to have been caused by reuse of stale data in old raw profiles.

llvm-svn: 372041
2019-09-16 22:32:18 +00:00
Kamil Rytarowski f7877dd4b6 Commit missing part of "Split many_tls_keys.cpp into two tests"
https://reviews.llvm.org/D67428

This change was lost due to a file rename and modification.

llvm-svn: 371941
2019-09-15 21:04:50 +00:00
Nico Weber 34b6f49c2c compiler-rt/builtins: Make check-builtins run tests on macOS.
Differential Revision: https://reviews.llvm.org/D66984

llvm-svn: 371926
2019-09-14 22:22:47 +00:00
Kamil Rytarowski d2e0f207aa Split many_tls_keys.cpp into two tests
Summary:
many_tls_keys_pthread.cpp for TSD
many_tls_keys_thread.cpp for TLS

The TSD test is unsupported on NetBSD as it assumes TLS used internally.
TSD on NetBSD does not use TLS.

Reviewers: joerg, vitalybuka, mgorny, dvyukov, kcc

Reviewed By: vitalybuka

Subscribers: jfb, llvm-commits, #sanitizers

Tags: #sanitizers, #llvm

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

llvm-svn: 371757
2019-09-12 18:55:18 +00:00
Vitaly Buka d2af368aee [compiler-rt] Remove some cpplint filters
llvm-svn: 371704
2019-09-12 02:20:36 +00:00
Vitaly Buka 6e8c21857e [compiler-rt] Run cpplint only for check-sanitizer
llvm-svn: 371703
2019-09-12 01:35:11 +00:00
Vitaly Buka c0fa632236 Remove NOLINTs from compiler-rt
llvm-svn: 371687
2019-09-11 23:19:48 +00:00
Vitaly Buka 48eb4a27d1 Update compiler-rt cpplint.py
adb3500107

llvm-svn: 371675
2019-09-11 21:33:06 +00:00
Max Moroz aff633f68d [libFuzzer] Remove hardcoded number of new features in merge_two_step.test.
Summary:
The number of features can be different on different platforms.

This should fixed broken builders, e.g.
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/7946

Reviewers: Dor1s

Reviewed By: Dor1s

Subscribers: kristof.beyls, delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 371647
2019-09-11 19:43:03 +00:00
Max Moroz f054067f27 [libFuzzer] Make -merge=1 to reuse coverage information from the control file.
Summary:
This change allows to perform corpus merging in two steps. This is useful when
the user wants to address the following two points simultaneously:

1) Get trustworthy incremental stats for the coverage and corpus size changes
    when adding new corpus units.
2) Make sure the shorter units will be preferred when two or more units give the
    same unique signal (equivalent to the `REDUCE` logic).

This solution was brainstormed together with @kcc, hopefully it looks good to
the other people too. The proposed use case scenario:

1) We have a `fuzz_target` binary and `existing_corpus` directory.
2) We do fuzzing and write new units into the `new_corpus` directory.
3) We want to merge the new corpus into the existing corpus and satisfy the
    points mentioned above.
4) We create an empty directory `merged_corpus` and run the first merge step:

    `
    ./fuzz_target -merge=1 -merge_control_file=MCF ./merged_corpus ./existing_corpus
    `

    this provides the initial stats for `existing_corpus`, e.g. from the output:

    `
    MERGE-OUTER: 3 new files with 11 new features added; 11 new coverage edges
    `

5) We recreate `merged_corpus` directory and run the second merge step:

    `
    ./fuzz_target -merge=1 -merge_control_file=MCF ./merged_corpus ./existing_corpus ./new_corpus
    `

    this provides the final stats for the merged corpus, e.g. from the output:

    `
    MERGE-OUTER: 6 new files with 14 new features added; 14 new coverage edges
    `

Alternative solutions to this approach are:

A) Store precise coverage information for every unit (not only unique signal).
B) Execute the same two steps without reusing the control file.

Either of these would be suboptimal as it would impose an extra disk or CPU load
respectively, which is bad given the quadratic complexity in the worst case.

Tested on Linux, Mac, Windows.

Reviewers: morehouse, metzman, hctim, kcc

Reviewed By: morehouse

Subscribers: JDevlieghere, delcypher, mgrang, #sanitizers, llvm-commits, kcc

Tags: #llvm, #sanitizers

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

llvm-svn: 371620
2019-09-11 14:11:08 +00:00
Kamil Rytarowski 8b83f50c03 Remove xfail i386 NetBSD mark in vptr-non-unique-typeinfo.cpp
This test passes now.

llvm-svn: 371575
2019-09-10 23:55:03 +00:00
Kamil Rytarowski 0910a03bc2 Remove xfail NetBSD mark from ignored-interceptors-mmap.cpp
This test now passes.

llvm-svn: 371574
2019-09-10 23:42:16 +00:00
Max Moroz ac3dce595c [UBSan] Follow up fix for r371442.
Reviewers: vitalybuka, hctim, Dor1s

Reviewed By: Dor1s

Subscribers: delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 371453
2019-09-09 21:00:25 +00:00
Julian Lettner 6d04ee0f86 [TSan] Add AnnotateIgnoreReadsBegin declaration to tsan/test.h
Declare the family of AnnotateIgnore[Read,Write][Begin,End] TSan
annotations in compiler-rt/test/tsan/test.h so that we don't have to
declare them separately in every test that needs them.  Replace usages.

Leave usages that explicitly test the annotation mechanism:
  thread_end_with_ignore.cpp
  thread_end_with_ignore3.cpp

llvm-svn: 371446
2019-09-09 20:07:03 +00:00
Max Moroz 9508738cd1 [UBSan] Do not overwrite the default print_summary sanitizer option.
Summary:
This option is true by default in sanitizer common. The default
false value was added a while ago without any reasoning in
524e934112

so, presumably it's safe to remove for consistency.

Reviewers: hctim, samsonov, morehouse, kcc, vitalybuka

Reviewed By: hctim, samsonov, vitalybuka

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

Tags: #llvm, #sanitizers

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

llvm-svn: 371442
2019-09-09 19:30:48 +00:00
Julian Lettner fc910c507e [TSan] Add interceptors for mach_vm_[de]allocate
I verified that the test is red without the interceptors.

rdar://40334350

Reviewed By: kubamracek, vitalybuka

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

llvm-svn: 371439
2019-09-09 18:57:32 +00:00
Kamil Rytarowski dd0c00b5f8 Enable LSan for NetBSD/i386 in test/asan/lit.cfg.py
llvm-svn: 371354
2019-09-08 23:53:36 +00:00
Kamil Rytarowski def6ca8b33 Enable LSan tests for NetBSD/i386
llvm-svn: 371338
2019-09-08 17:07:28 +00:00
Kamil Rytarowski 90d2be0163 Stop marking 5 ASan tests as failing on NetBSD/i386
Unexpected Passing Tests (4):
    AddressSanitizer-i386-netbsd :: TestCases/Posix/coverage-reset.cpp
    AddressSanitizer-i386-netbsd :: TestCases/Posix/coverage.cpp
    AddressSanitizer-i386-netbsd :: TestCases/Posix/interception-in-shared-lib-test.cpp
    AddressSanitizer-i386-netbsd :: TestCases/suppressions-library.cpp

llvm-svn: 371337
2019-09-08 16:15:18 +00:00
Jonas Hahnfeld 307daa71a8 [ASan] Only run dlopen-mixed-c-cxx.c with static runtime
This is what the original bug (http://llvm.org/PR39641) and the fix
in https://reviews.llvm.org/D63877 have been about.
With the dynamic runtime the test only passes when the asan library
is linked against libstdc++: In contrast to libc++abi, it does not
implement __cxa_rethrow_primary_exception so the regex matches the
line saying that asan cannot intercept this function. Indeed, there
is no message that the runtime failed to intercept  __cxa_throw.

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

llvm-svn: 371336
2019-09-08 16:08:54 +00:00
Kamil Rytarowski 14f1990921 Enable leak-detection for NetBSD/amd64 in test/asan
llvm-svn: 371335
2019-09-08 15:54:48 +00:00
Yi Kong 33b8a55329 Revert "Revert "[builtins] Rounding mode support for addxf3/subxf3""
Test failure fixed.

This reverts commit e204d244ba.

llvm-svn: 371003
2019-09-05 01:05:05 +00:00
Alexander Richardson 83d2f0e799 Further relax checks in asan-symbolize-bad-path.cpp
It turns out that the DarwinSymbolizer does not print the "in" part for
invalid files but instead prints
#0 0xabcdabcd (.../asan-symbolize-bad-path.cpp.tmp/bad/path:i386+0x1234)
This tests is only checking that asan_symbolize.py doesn't hang or crash,
so further relax the checks to ensure that the test passes on macOS.

llvm-svn: 370243
2019-08-28 18:37:53 +00:00
David Carlier 72cb9db5c7 [XRay] Fixing one test case for FreeBSD
Reviewers: dberris

Reviewed By: dberris

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

llvm-svn: 370209
2019-08-28 14:18:05 +00:00
Alexander Richardson 79f3459deb Fix asan-symbolize-bad-path.cpp on Darwin
I accidentally made the CHECK line stricter when committing D65322.
While it happens to work for Linux and FreeBSD, it broke on Darwin.
This commit restores the previous behaviour.

llvm-svn: 370110
2019-08-27 21:10:47 +00:00
Alexander Richardson 23a12fc3ac Relax test introduced in D65322
It is possible that addr2line returns a valid function and file name for
the passed address on some build configuations.
The test is only checking that asan_symbolize doesn't assert any more when
passed a valid file with an invalid address so there is no need to check
that it can't find a valid function name.
This should fix http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux

llvm-svn: 370021
2019-08-27 06:50:36 +00:00
Vitaly Buka aeca56964f msan, codegen, instcombine: Keep more lifetime markers used for msan
Reviewers: eugenis

Subscribers: hiraditya, cfe-commits, #sanitizers, llvm-commits

Tags: #clang, #sanitizers, #llvm

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

llvm-svn: 369979
2019-08-26 22:15:50 +00:00
Evgeniy Stepanov ed4fefb0df [hwasan] Fix test failure in r369721.
Try harder to emulate "old runtime" in the test.
To get the old behavior with the new runtime library, we need both
disable personality function wrapping and enable landing pad
instrumentation.

llvm-svn: 369977
2019-08-26 21:44:55 +00:00
Alexander Richardson e320db434e [asan_symbolize] Avoid blocking when llvm-symbolizer is installed as addr2line
Summary:
Currently, llvm-symbolizer will print -1 when presented with -1 and not
print a second line. In that case we will block for ever trying to read
the file name. This also happens for non-existent files, in which case GNU
addr2line exits immediate, but llvm-symbolizer does not (see
https://llvm.org/PR42754). While touching these lines, I also added some
more debug logging to help diagnose this and potential future issues.

Reviewers: kcc, eugenis, glider, samsonov

Reviewed By: eugenis

Subscribers: kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 369924
2019-08-26 16:22:04 +00:00
Peter Collingbourne 21a1814417 hwasan: Untag unwound stack frames by wrapping personality functions.
One problem with untagging memory in landing pads is that it only works
correctly if the function that catches the exception is instrumented.
If the function is uninstrumented, we have no opportunity to untag the
memory.

To address this, replace landing pad instrumentation with personality function
wrapping. Each function with an instrumented stack has its personality function
replaced with a wrapper provided by the runtime. Functions that did not have
a personality function to begin with also get wrappers if they may be unwound
past. As the unwinder calls personality functions during stack unwinding,
the original personality function is called and the function's stack frame is
untagged by the wrapper if the personality function instructs the unwinder
to keep unwinding. If unwinding stops at a landing pad, the function is
still responsible for untagging its stack frame if it resumes unwinding.

The old landing pad mechanism is preserved for compatibility with old runtimes.

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

llvm-svn: 369721
2019-08-23 01:28:44 +00:00
Julian Lettner 9f985dd380 [sanitizer_common] Extend test after switch to posix_spawn
llvm-svn: 369311
2019-08-19 23:47:35 +00:00
David Carlier 949f190810 [Sanitizer] arc4random interception on Mac
Reviewers: yln,vitalybuka

Reviewed By: yln

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

llvm-svn: 369285
2019-08-19 18:12:15 +00:00
Julian Lettner 4a9b747bfb [TSan] Add interceptors for os_unfair_lock
llvm-svn: 369164
2019-08-16 22:41:25 +00:00
Julian Lettner 399408a92f [sanitizer_common] Replace forkpty with posix_spawn on Darwin
On Darwin, we currently use forkpty to communicate with the "atos"
symbolizer. There are several problems that fork[pty] has, e.g. that
after fork, interceptors are still active and this sometimes causes
crashes or hangs. This is especially problematic for TSan, which uses
interceptors for OS-provided locks and mutexes, and even Libc functions
use those.

This patch replaces forkpty with posix_spawn on Darwin. Since
posix_spawn doesn't fork (at least on Darwin), the interceptors are not
a problem. Another benefit is that we'll handle post-fork failures (e.g.
sandbox disallows "exec") gracefully now.

Related revisions and previous attempts that were blocked by or had to
be revered due to test failures:
https://reviews.llvm.org/D48451
https://reviews.llvm.org/D40032

Reviewed By: kubamracek

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

llvm-svn: 368947
2019-08-15 00:18:55 +00:00
Julian Lettner d8c47d52da [TSan] Fix test failing on Linux
llvm-svn: 368641
2019-08-13 00:37:48 +00:00
Dan Liew c3b93bed29 [asan_symbolize] Fix bug where the frame counter was not incremented.
Summary:
This bug occurred when a plug-in requested that a binary not be
symbolized while the script is trying to symbolize a stack frame. In
this case `self.frame_no` would not be incremented. This would cause
subsequent stack frames that are symbolized to be incorrectly numbered.

To fix this `get_symbolized_lines()` has been modified to take an
argument that indicates whether the stack frame counter should
incremented. In `process_line_posix()` `get_symbolized_lines(None, ...)`
is now used in in the case where we don't want to symbolize a line so
that we can keep the frame counter increment in a single function.

A test case is included. The test uses a dummy plugin that always asks
`asan_symbolize.py` script to not symbolize the first binary that the
script asks about. Prior to the patch this would cause the output to
script to look something like

```
  #0 0x0
  #0 0x0 in do_access
  #1 0x0 in main
```

This is the second attempt at landing this patch. The first (r368373)
failed due to failing some android bots and so was reverted in r368472.
The new test is now disabled for Android. It turns out that the patch
also fails for iOS too so it is also disabled for that family of
platforms too.

rdar://problem/49476995

Reviewers: kubamracek, yln, samsonov, dvyukov, vitalybuka

Subscribers: #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 368603
2019-08-12 18:51:25 +00:00
Dimitry Andric c09d888632 Add support for FreeBSD's LD_32_LIBRARY_PATH
Summary:
Because the dynamic linker for 32-bit executables on 64-bit FreeBSD uses
the environment variable `LD_32_LIBRARY_PATH` instead of
`LD_LIBRARY_PATH` to find needed dynamic libraries, running the 32-bit
parts of the dynamic ASan tests will fail with errors similar to:

```
ld-elf32.so.1: Shared object "libclang_rt.asan-i386.so" not found, required by "Asan-i386-inline-Dynamic-Test"
```

This adds support for setting up `LD_32_LIBRARY_PATH` for the unit and
regression tests.  It will likely also require a minor change to the
`TestingConfig` class in `llvm/utils/lit/lit`.

Reviewers: emaste, kcc, rnk, arichardson

Reviewed By: arichardson

Subscribers: kubamracek, krytarowski, fedor.sergeev, delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 368516
2019-08-10 19:07:38 +00:00
Julian Lettner 5ef4b190d9 [Sanitizer][Darwin] Add interceptor for malloc_zone_from_ptr
Ensure that malloc_default_zone and malloc_zone_from_ptr return the
sanitizer-installed malloc zone even when MallocStackLogging (MSL) is
requested. This prevents crashes in certain situations. Note that the
sanitizers and MSL cannot be used together. If both are enabled, MSL
functionality is essentially deactivated since it only hooks the default
allocator which is replaced by a custom sanitizer allocator.

rdar://53686175

Reviewed By: kubamracek

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

llvm-svn: 368492
2019-08-09 21:46:32 +00:00
Mitch Phillips cace571c91 Revert "[asan_symbolize] Fix bug where the frame counter was not incremented."
This reverts commit 52a36fae2a.

This commit broke the sanitizer_android buildbot. See comments at
https://reviews.llvm.org/rL368373 for more details.

llvm-svn: 368472
2019-08-09 19:36:41 +00:00
Dan Liew 52a36fae2a [asan_symbolize] Fix bug where the frame counter was not incremented.
Summary:
This bug occurred when a plug-in requested that a binary not be
symbolized while the script is trying to symbolize a stack frame. In
this case `self.frame_no` would not be incremented. This would cause
subsequent stack frames that are symbolized to be incorrectly numbered.

To fix this `get_symbolized_lines()` has been modified to take an
argument that indicates whether the stack frame counter should
incremented. In `process_line_posix()` `get_symbolized_lines(None, ...)`
is now used in in the case where we don't want to symbolize a line so
that we can keep the frame counter increment in a single function.

A test case is included. The test uses a dummy plugin that always asks
`asan_symbolize.py` script to not symbolize the first binary that the
script asks about. Prior to the patch this would cause the output to
script to look something like

```
  #0 0x0
  #0 0x0 in do_access
  #1 0x0 in main
```

rdar://problem/49476995

Reviewers: kubamracek, yln, samsonov, dvyukov, vitalybuka

Subscribers: #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 368373
2019-08-09 00:52:07 +00:00
Douglas Yung 11538f0afa Add LLD as a requirement for hwasan tests because of change in r368111.
llvm-svn: 368242
2019-08-08 01:08:22 +00:00
Mitch Phillips c96387fce3 [HWASan] Use LLD for check-hwasan.
HWASan+globals build fix in rL368111 unfortunately didn't fix the
problem when clang_cflags specified -fuse-ld=ld.gold. Change the order
to force lld in an attempt to fix the Android sanitizer bot.

llvm-svn: 368218
2019-08-07 21:56:21 +00:00
Peter Collingbourne feef101ac2 Require lld for hwasan tests.
We're using relocations that are unsupported by the version of gold on the
bot, so force the use of lld. One of the tests is already using lld,
so this should be safe.

llvm-svn: 368111
2019-08-06 23:43:20 +00:00
Alexander Richardson 0b168ffdc3 [TSAN] Fix tsan on FreeBSD after D54889
Summary:
It appears that since https://reviews.llvm.org/D54889, BackgroundThread()
crashes immediately because cur_thread()-> will return a null pointer
which is then dereferenced. I'm not sure why I only see this issue on
FreeBSD and not Linux since it should also be unintialized on other platforms.

Reviewers: yuri, dvyukov, dim, emaste

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

Tags: #sanitizers, #llvm

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

llvm-svn: 368103
2019-08-06 22:30:48 +00:00
Peter Collingbourne 0930643ff6 hwasan: Instrument globals.
Globals are instrumented by adding a pointer tag to their symbol values
and emitting metadata into a special section that allows the runtime to tag
their memory when the library is loaded.

Due to order of initialization issues explained in more detail in the comments,
shadow initialization cannot happen during regular global initialization.
Instead, the location of the global section is marked using an ELF note,
and we require libc support for calling a function provided by the HWASAN
runtime when libraries are loaded and unloaded.

Based on ideas discussed with @evgeny777 in D56672.

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

llvm-svn: 368102
2019-08-06 22:07:29 +00:00
Vitaly Buka ac9ee01fcb [compiler-rt] Implement getrandom interception
Summary:
Straightforward implementation of `getrandom` syscall and libc
hooks.

Test Plan: Local MSAN failures caused by uninstrumented `getrandom`
calls stop failing.

Patch by Andrew Krieger.

Reviewers: eugenis, vitalybuka

Reviewed By: vitalybuka

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

Tags: #sanitizers, #llvm

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

llvm-svn: 367999
2019-08-06 08:41:53 +00:00
Peter Collingbourne e757cadb07 hwasan: Untag global variable addresses in tests.
Once we start instrumenting globals, all addresses including those of string literals
that we pass to the operating system will start being tagged. Since we can't rely
on the operating system to be able to cope with these addresses, we need to untag
them before passing them to the operating system. This change introduces a macro
that does so and uses it everywhere it is needed.

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

llvm-svn: 367938
2019-08-05 21:46:10 +00:00
Nico Weber 307beb13af compiler-rt: Remove .cc from all lit config files
All cc files have been renamed to cpp now.

llvm-svn: 367911
2019-08-05 19:25:35 +00:00
Nico Weber bb7ad98a47 Follow-up for r367863 and r367656
llvm-svn: 367888
2019-08-05 16:50:56 +00:00
Nico Weber 673dc3d4a0 compiler-rt: Rename cc files below test/asan to cpp
See r367803 and similar other changes.

llvm-svn: 367887
2019-08-05 16:48:12 +00:00
Nico Weber 74989aff53 compiler-rt: Rename cc files below test/sanitizer_common to cpp
See r367803 and similar other changes.

llvm-svn: 367863
2019-08-05 13:57:03 +00:00
Nico Weber 8b8f66d993 compiler-rt: Rename remaining cc files in test/profile to cpp
See r367803 and similar other changes.

llvm-svn: 367858
2019-08-05 13:42:31 +00:00
Nico Weber 2f7d11be6f More follow-up to r367851
llvm-svn: 367856
2019-08-05 13:27:37 +00:00
Nico Weber 6eed7e7e94 compiler-rt: Rename last few cc files below test/ubsan to cpp
See r367803 and similar other changes.

llvm-svn: 367855
2019-08-05 13:23:38 +00:00
Nico Weber c4310f921d compiler-rt: Rename .cc file in test/dfsan to cpp
See r367849 et al.

llvm-svn: 367854
2019-08-05 13:19:28 +00:00
Nico Weber 53770e78ae compiler-rt: Rename cc files in test/hwasan/TestCases subdirectories as well
Should've been part of r367849.

llvm-svn: 367851
2019-08-05 13:12:23 +00:00
Nico Weber f9e0df071e compiler-rt: Rename .cc file in test/hwasan to .cpp
Like r367463, but for test/hwasan.

llvm-svn: 367849
2019-08-05 13:10:50 +00:00
Fangrui Song 97ccf6b8c1 compiler-rt: Rename .cc file in test/lsan to .cpp
Like r367463, but for test/lsan.

llvm-svn: 367803
2019-08-05 07:04:42 +00:00
Fangrui Song bcaeed49cb compiler-rt: Rename .cc file in test/tsan to .cpp
Like r367463, but for test/tsan.

llvm-svn: 367656
2019-08-02 07:18:07 +00:00
Fangrui Song d21b3d346a compiler-rt: Rename .cc file in test/msan to .cpp
Like r367463, but for test/msan.

llvm-svn: 367653
2019-08-02 06:07:05 +00:00
Fangrui Song 6db8c59f21 compiler-rt: Rename .cc file in test/xray to .cpp
Like r367463, but for test/xray.

Update test/xray/lit.cfg.py config.suffixes to remove .cc (we actually
don't have .c tests now)

llvm-svn: 367652
2019-08-02 05:49:58 +00:00
Nico Weber 4ef767dfe9 try to fix bots more after r367562
llvm-svn: 367587
2019-08-01 17:31:49 +00:00
Nico Weber 558ee6544e try to fix bots after r367562
llvm-svn: 367586
2019-08-01 17:30:41 +00:00
Nico Weber 5a3bb1a4d6 compiler-rt: Rename .cc file in lib/tsan/rtl to .cpp
Like r367463, but for tsan/rtl.

llvm-svn: 367564
2019-08-01 14:22:42 +00:00
Nico Weber 60c66db476 compiler-rt: Rename .cc file in lib/msan to .cpp
Like r367463, but for msan.

llvm-svn: 367562
2019-08-01 14:08:18 +00:00
Nico Weber 217222abea compiler-rt: Rename .cc file in lib/asan to .cpp
Like r367463, but for asan.

llvm-svn: 367558
2019-08-01 13:43:28 +00:00
Nico Weber 65492d959b compiler-rt: Rename .cc file in lib/sanitizer_common to .cpp
See https://reviews.llvm.org/D58620 for discussion, and for the commands
I ran. In addition I also ran

  for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $f . ; done

and manually updated (many) references to renamed files found by that.

llvm-svn: 367463
2019-07-31 18:51:27 +00:00
Nico Weber 46ba969752 compiler-rt: Rename .cc files in lib/ubsan to .cpp.
See https://reviews.llvm.org/D58620 for discussion, and for the commands
I ran. In addition I also ran

  for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $f . ; done

and manually updated references to renamed files found by that.

llvm-svn: 367452
2019-07-31 17:51:05 +00:00
Alexander Richardson a4ea27de92 [Sanitizer][ASAN][MSAN] Fix infinite recursion on FreeBSD
Summary:
MSAN was broken on FreeBSD by https://reviews.llvm.org/D55703: after this
change accesses to the key variable call __tls_get_addr, which is
intercepted. The interceptor then calls GetCurrentThread which calls
MsanTSDGet which again calls __tls_get_addr, etc...
Using the default implementation in the SANITIZER_FREEBSD case fixes MSAN
for me.

I then applied the same change to ASAN (introduced in https://reviews.llvm.org/D55596)
but that did not work yet. In the ASAN case, we get infinite recursion
again during initialization, this time because calling pthread_key_create() early on
results in infinite recursion. pthread_key_create() calls sysctlbyname()
which is intercepted but COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED returns
true, so the interceptor calls internal_sysctlbyname() which then ends up
calling the interceptor again. I fixed this issue by using dlsym() to get
the libc version of sysctlbyname() instead.

This fixes https://llvm.org/PR40761

Reviewers: vitalybuka, krytarowski, devnexen, dim, bsdjhb, #sanitizers, MaskRay

Reviewed By: MaskRay

Subscribers: MaskRay, emaste, kubamracek, jfb, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 367442
2019-07-31 16:31:55 +00:00
Rainer Orth 63d9605091 [builtins][test] XFAIL two SPARC tests
Two SPARC builtins tests are currently FAILing due to codegen bugs:

  Builtins-sparc-sunos :: divtc3_test.c
  Builtins-sparcv9-sunos :: compiler_rt_logbl_test.c
  Builtins-sparcv9-sunos :: divtc3_test.c

I'd like to XFAIL them to reduce testsuite noise. 
  
Done as follows, tested on sparcv9-sun-solaris2.11 and x86_64-pc-solaris2.11.

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

llvm-svn: 367295
2019-07-30 08:05:14 +00:00
Rainer Orth 58aa6a87a6 [ASan][test] XFAIL AddressSanitizer-*-sunos :: TestCases/intercept-rethrow-exception.cc on Solaris
AddressSanitizer-*-sunos :: TestCases/intercept-rethrow-exception.cc currently FAILs
on Solaris.  This happens because std::rethrow_exception cannot be intercepted, as
detailed in Bug 42703.

To account for this and reduce testsuite noise, this patch XFAILs the test.

Tested on x86_64-pc-solaris2.11.

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

llvm-svn: 367293
2019-07-30 07:59:43 +00:00
Lei Huang 686cee0945 [NFC][ASAN] Add brackets around not command
Under certain execution conditions, the `not` command binds to the command the
output is piped to rather than the command piping the output. In this case, that
flips the return code of the FileCheck invocation, causing a failure when
FileCheck succeeds.

llvm-svn: 366805
2019-07-23 13:10:29 +00:00
Julian Lettner 2ef9ec4050 [TSan] Enable fiber tests on iOS simulator
These tests *do not* work on device, but they *do* work in the
simulator.

rdar://53403778

llvm-svn: 366738
2019-07-22 21:13:19 +00:00
Serge Guelton a30a4a35ec Fix asan infinite loop on undefined symbol
Fix llvm#39641

Recommit of r366413

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

> llvm-svn: 366632

llvm-svn: 366638
2019-07-20 17:44:30 +00:00
Serge Guelton 7a3d4c15a7 Revert "Fix asan infinite loop on undefined symbol"
This reverts commit cbd28cd05b.

Buildbot fail: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/22434/steps/64-bit%20check-asan-dynamic/

llvm-svn: 366634
2019-07-20 13:00:12 +00:00
Serge Guelton cbd28cd05b Fix asan infinite loop on undefined symbol
Fix llvm#39641

Recommit of r366413

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

llvm-svn: 366632
2019-07-20 12:01:18 +00:00
Matthew Voss 407e837540 Revert "Fix asan infinite loop on undefined symbol"
This reverts commit 8e46275488.

This was failing on sanitizer-x86_64-linux and our internal CI.

llvm-svn: 366618
2019-07-19 21:41:07 +00:00
Serge Guelton 8e46275488 Fix asan infinite loop on undefined symbol
Fix llvm#39641

Recommit of r366413

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

llvm-svn: 366588
2019-07-19 15:20:36 +00:00
Matthew Voss 892758a526 [compiler-rt] Complete revert of r366413
Incomplete revert. Mea culpa. This test is failing on sanitizer-x86_64-linux
and our internal CI.

llvm-svn: 366482
2019-07-18 18:39:06 +00:00
Serge Guelton ec2a7c463e Restrict asan + dlopen testcase to x86
llvm-svn: 366436
2019-07-18 13:47:28 +00:00
Serge Guelton 6a61bea4d6 Relax regexp to detect failed interception by asan
This should fix failed detection on aarch64/ppc64/thumbv8...

llvm-svn: 366432
2019-07-18 13:13:29 +00:00
Serge Guelton 63719119c7 Fix asan infinite loop on undefined symbol
Fix llvm#39641

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

llvm-svn: 366413
2019-07-18 08:09:31 +00:00
Peter Collingbourne 749f556bbd hwasan: Use C++ driver for cfi.cc test.
It turns out that this test was only passing by accident. It was relying on
the optimizer to remove the only reference to A's vtable by realizing that
the CFI check will always fail. The vtable contains a reference to RTTI in
libc++, which will be unresolved because the C driver won't link against it.

This was found by my prototype implementation of HWASAN for globals, which
happens to end up preserving the reference.

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

llvm-svn: 366389
2019-07-17 23:35:15 +00:00
Julian Lettner 9a050f92bb [ASan] Support `{f}puts(NULL)` on Darwin
On Darwin, the man page states that "both fputs() and puts() print
`(null)' if str is NULL."

rdar://48227136

Reviewed By: Lekensteyn

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

llvm-svn: 366342
2019-07-17 16:09:25 +00:00
Stephan Bergmann e215996a29 Finish "Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO"
i.e., recent 5745eccef54ddd3caca278d1d292a88b2281528b:

* Bump the function_type_mismatch handler version, as its signature has changed.

* The function_type_mismatch handler can return successfully now, so
  SanitizerKind::Function must be AlwaysRecoverable (like for
  SanitizerKind::Vptr).

* But the minimal runtime would still unconditionally treat a call to the
  function_type_mismatch handler as failure, so disallow -fsanitize=function in
  combination with -fsanitize-minimal-runtime (like it was already done for
  -fsanitize=vptr).

* Add tests.

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

llvm-svn: 366186
2019-07-16 06:23:27 +00:00
Diana Picus 0bf0b8ff7c [libFuzzer] Disable fork.test on AArch64
This crashes sporadically on our AArch64 buildbots. Disable for now.

llvm-svn: 366055
2019-07-15 11:33:41 +00:00
Rainer Orth 4a9a772f44 Enable compiler-rt on SPARC
This patch enables compiler-rt on SPARC targets. Most of the changes are straightforward:

- Add 32 and 64-bit sparc to compiler-rt

- lib/builtins/fp_lib.h needed to check if the int128_t and uint128_t types exist (which they don't on sparc)

There's one issue of note: many asan tests fail to compile on Solaris/SPARC:

fatal error: error in backend: Function "_ZN7testing8internal16BoolFromGTestEnvEPKcb": over-aligned dynamic alloca not supported.

Therefore, while asan is still built, both asan and ubsan-with-asan testing is disabled. The
goal is to check if asan keeps compiling on Solaris/SPARC. This serves asan in gcc,
which doesn't have the problem above and works just fine.

With this patch, sparcv9-sun-solaris2.11 test results are pretty good:

Failing Tests (9):
    Builtins-sparc-sunos :: divtc3_test.c
    Builtins-sparcv9-sunos :: compiler_rt_logbl_test.c
    Builtins-sparcv9-sunos :: divtc3_test.c
[...]
    UBSan-Standalone-sparc :: TestCases/TypeCheck/misaligned.cpp
    UBSan-Standalone-sparcv9 :: TestCases/TypeCheck/misaligned.cpp

The builtin failures are due to Bugs 42493 and 42496. The tree contained a few additonal
patches either currently in review or about to be submitted.

Tested on sparcv9-sun-solaris2.11.

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

llvm-svn: 365880
2019-07-12 08:30:17 +00:00
Artem Dergachev 8bd441af8b NFC: Unforget a colon in a few CHECK: directives.
Differential Revision: https://reviews.llvm.org/D64526

llvm-svn: 365863
2019-07-12 02:16:56 +00:00
Reid Kleckner 1a285c27fd Use clang driver for libfuzzer tests on Windows
Summary:
There's no real reason to use clang-cl on Windows, the clang driver
works just as well. This fixes a test which uses the -O0 flag, which was
recently removed from clang-cl to match MSVC, which lacks this flag.

While I'm here, remove the explicit -std=c++11 flag. Previously, this
flag was necessary when the default C++ standard was C++98. Now that the
default is C++14, this is no longer necessary. It's problematic on
Windows, because the Visual C++ standard library relies on C++14
features, and attempting to compile it with C++11 results in errors.
Rather than adding logic to conditionally set the standard to C++11 only
on non-Win, this flag can be removed.

See http://lab.llvm.org:8011/builders/clang-x64-windows-msvc and
https://reviews.llvm.org/D64506.

Reviewers: morehouse, thakis

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 365841
2019-07-11 23:20:04 +00:00
Rainer Orth 9512c0a1d1 [profile][test] Fix Profile-* :: instrprof-merge.c etc. on SPARC
While working on https://reviews.llvm.org/D40900 (which effectively is about enabling compiler-rt on sparc these days), I came across two failing profile testcases:

  Profile-sparc :: instrprof-merge-match.test
  Profile-sparc :: instrprof-merge.c
  Profile-sparcv9 :: instrprof-merge-match.test
  Profile-sparcv9 :: instrprof-merge.c

All of them crashed with a SIGBUS in __llvm_profile_merge_from_buffer:

  Thread 2 received signal SIGSEGV, Segmentation fault.
  [Switching to Thread 1 (LWP 1)]
  0x00012368 in __llvm_profile_merge_from_buffer (
      ProfileData=0x2384c <main.Buffer> "\377lprofR\201", ProfileSize=360)
      at /vol/llvm/src/llvm/local/projects/compiler-rt/lib/profile/InstrProfilingMerge.c:95
  95        SrcDataEnd = SrcDataStart + Header->DataSize;

where Header is insufficiently aligned for a strict-alignment target like SPARC.

Fixed by forcing the alignment to uint64_t, the members of struct __llvm_profile_header,
in the callers.

Tested on sparcv9-sun-solaris2.11.

https://reviews.llvm.org/D64498

llvm-svn: 365805
2019-07-11 18:26:24 +00:00
Kamil Rytarowski 983d7ddd0b Add NetBSD LSan support
Summary:
Combine few relatively small changes into one:

 - implement internal_ptrace() and internal_clone() for NetBSD
 - add support for stoptheworld based on the ptrace(2) API
 - define COMPILER_RT_HAS_LSAN for NetBSD
 - enable tests for NetBSD/amd64

Inspired by the original implementation by Christos Zoulas in netbsd/src for GCC.

The implementation is in theory CPU independent through well defined macros
across all NetBSD ports, however only the x86_64 version was tested.

Reviewers: mgorny, dvyukov, vitalybuka, joerg, jfb

Reviewed By: vitalybuka

Subscribers: dexonsmith, jfb, srhines, kubamracek, llvm-commits, christos

Tags: #llvm

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

llvm-svn: 365735
2019-07-11 06:22:35 +00:00
Nico Weber e837847ec6 Change another test I missed in r365724
llvm-svn: 365725
2019-07-11 01:21:17 +00:00
Nico Weber da233838c9 clang-cl: Remove -O0 option
cl.exe doesn't understand it; there's /Od instead. See also the review
thread for r229575.

Update lots of compiler-rt tests to use -Od instead of -O0.
Ran `rg -l 'clang_cl.*O0' compiler-rt/test/ | xargs sed -i -c 's/-O0/-Od/'`

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

llvm-svn: 365724
2019-07-11 01:18:05 +00:00
Fangrui Song 7f9a94e1f8 [ubsan][test] Restore float-divide-by-zero test
Removed by rCTE365307 to fix buildbots. It can be restored now because D64317/rC365587 brought back -fsanitize=float-divide-by-zero

llvm-svn: 365591
2019-07-10 01:53:11 +00:00
Peter Collingbourne 1366262b74 hwasan: Improve precision of checks using short granule tags.
A short granule is a granule of size between 1 and `TG-1` bytes. The size
of a short granule is stored at the location in shadow memory where the
granule's tag is normally stored, while the granule's actual tag is stored
in the last byte of the granule. This means that in order to verify that a
pointer tag matches a memory tag, HWASAN must check for two possibilities:

* the pointer tag is equal to the memory tag in shadow memory, or
* the shadow memory tag is actually a short granule size, the value being loaded
  is in bounds of the granule and the pointer tag is equal to the last byte of
  the granule.

Pointer tags between 1 to `TG-1` are possible and are as likely as any other
tag. This means that these tags in memory have two interpretations: the full
tag interpretation (where the pointer tag is between 1 and `TG-1` and the
last byte of the granule is ordinary data) and the short tag interpretation
(where the pointer tag is stored in the granule).

When HWASAN detects an error near a memory tag between 1 and `TG-1`, it
will show both the memory tag and the last byte of the granule. Currently,
it is up to the user to disambiguate the two possibilities.

Because this functionality obsoletes the right aligned heap feature of
the HWASAN memory allocator (and because we can no longer easily test
it), the feature is removed.

Also update the documentation to cover both short granule tags and
outlined checks.

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

llvm-svn: 365551
2019-07-09 20:22:36 +00:00
Matthew G McGovern 4e636156ef [sanitizers][windows] FIX: Rtl-Heap Interception and tests
- Adds interceptors for Rtl[Allocate|Free|Size|ReAllocate]Heap
   - Adds unit tests for the new interceptors and expands HeapAlloc
     tests to demonstrate new functionality.
   Reviewed as D62927
   - adds fixes for ~win and x64 tests

> llvm-svn: 365381

llvm-svn: 365424
2019-07-09 01:55:11 +00:00
Matthew G McGovern 848a19e4eb [sanitizers][windows] Rtl-Heap Interception and tests
- Adds interceptors for Rtl[Allocate|Free|Size|ReAllocate]Heap
   - Adds unit tests for the new interceptors and expands HeapAlloc
     tests to demonstrate new functionality.
   Reviewed as D62927

llvm-svn: 365422
2019-07-09 01:47:08 +00:00
JF Bastien c5630ac641 Revert "[sanitizers][windows] Rtl-Heap Interception and tests"
Causes build failure on clang-ppc64be-linux-lnt:

compiler-rt/lib/asan/asan_malloc_win.cc:23:2: error: #error "Missing arch or unsupported platform for Windows."
 #error "Missing arch or unsupported platform for Windows."
  ^~~~~
compiler-rt/lib/asan/asan_malloc_win.cc:25:10: fatal error: heapapi.h: No such file or directory
 #include <heapapi.h>
          ^~~~~~~~~~~
compilation terminated.
[39/1151] Building CXX object projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_debugging.cc.o
[40/1151] Building CXX object projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o
FAILED: projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o
/usr/bin/c++  -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/compiler-rt/lib/asan -Icompiler-rt/lib/asan -Iinclude -I/home/buildbots/ppc64be-clang-lnt-test/clang-ppc64be-lnt/llvm/include -Icompiler-rt/lib/asan/.. -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -std=c++11 -Wno-unused-parameter -O2    -UNDEBUG  -m64 -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fvisibility=hidden -fno-lto -O3 -g -Wno-variadic-macros -Wno-non-virtual-dtor -fno-rtti -MD -MT projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o -MF projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o.d -o projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o -c compiler-rt/lib/asan/asan_malloc_win.cc
compiler-rt/lib/asan/asan_malloc_win.cc:23:2: error: #error "Missing arch or unsupported platform for Windows."
 #error "Missing arch or unsupported platform for Windows."
  ^~~~~
compiler-rt/lib/asan/asan_malloc_win.cc:25:10: fatal error: heapapi.h: No such file or directory
 #include <heapapi.h>
          ^~~~~~~~~~~

llvm-svn: 365384
2019-07-08 20:21:09 +00:00
Matthew G McGovern c9fa99d066 [sanitizers][windows] Rtl-Heap Interception and tests
- Adds interceptors for Rtl[Allocate|Free|Size|ReAllocate]Heap
   - Adds unit tests for the new interceptors and expands HeapAlloc
     tests to demonstrate new functionality.
   Reviewed as D62927

llvm-svn: 365381
2019-07-08 19:58:50 +00:00
Julian Lettner 611c122045 Revert "[TSan] Attempt to fix iOS on-device test"
This reverts commit a2ca358291.

llvm-svn: 365375
2019-07-08 19:26:21 +00:00
Fangrui Song 1f7bd40f68 [ubsan][test] Fix cast-overflow.cpp and delete float-divide-by-zero test after D63793/rC365272
llvm-svn: 365307
2019-07-08 09:47:04 +00:00
Rainer Orth 04ea772d5a [ubsan][test] Fix several UBSan-* :: TestCases/ImplicitConversion tests on Solaris
A couple of UBSan-*  :: TestCases/ImplicitConversion testcases FAIL on Solaris/x86
(and Solaris/SPARC with https://reviews.llvm.org/D40900):

  FAIL: UBSan-AddressSanitizer-i386 :: TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c (49187 of 49849)
  ******************** TEST 'UBSan-AddressSanitizer-i386 :: TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c' FAILED ********************
  [...]
  Command Output (stderr):
  --
  /vol/llvm/src/compiler-rt/local/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c:53:11: error: CHECK: expected string not found in input
  // CHECK: {{.*}}signed-integer-truncation-or-sign-change-blacklist.c:[[@LINE-1]]:10: runtime error: implicit conversion from type '{{.*}}' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type '{{.*}}' (aka 'signed char') changed the value to -1 (8-bit, signed)
            ^
  <stdin>:1:1: note: scanning from here
  /vol/llvm/src/compiler-rt/local/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c:52:10: runtime error: implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type 'int8_t' (aka 'char') changed the value to -1 (8-bit, signed)
  ^
  <stdin>:1:1: note: with "@LINE-1" equal to "52"
  /vol/llvm/src/compiler-rt/local/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c:52:10: runtime error: implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type 'int8_t' (aka 'char') changed the value to -1 (8-bit, signed)
  ^
  <stdin>:1:69: note: possible intended match here
  /vol/llvm/src/compiler-rt/local/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c:52:10: runtime error: implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 4294967295 (32-bit, unsigned) to type 'int8_t' (aka 'char') changed the value to -1 (8-bit, signed)
                                                                      ^

This is always a difference for int8_t where signed char is expected, but only
char seen.

I could trace this to <sys/int_types.h> which has

  /*
   * Basic / Extended integer types
   *
   * The following defines the basic fixed-size integer types.
   *
   * Implementations are free to typedef them to Standard C integer types or
   * extensions that they support. If an implementation does not support one
   * of the particular integer data types below, then it should not define the
   * typedefs and macros corresponding to that data type.  Note that int8_t
   * is not defined in -Xs mode on ISAs for which the ABI specifies "char"
   * as an unsigned entity because there is no way to define an eight bit
   * signed integral.
   */
  #if defined(_CHAR_IS_SIGNED)
  typedef char			int8_t;
  #else
  #if defined(__STDC__)
  typedef signed char		int8_t;
  #endif
  #endif

_CHAR_IS_SIGNED is always defined on both sparc and x86.  Since it seems ok
to have either form, I've changed the affected tests to use
'{{(signed )?}}char' instead of 'signed char'.

Tested on x86_64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu.

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

llvm-svn: 365303
2019-07-08 09:22:05 +00:00
Rainer Orth d11df93898 [ubsan][test] Don't disable ubsan testing on 64-bit Solaris/x86
Unlike asan, which isn't supported yet on 64-bit Solaris/x86, there's no reason to disable
ubsan.  This patch does that, but keeps the 64-bit ubsan-with-asan tests disabled.

Tested on x86_64-pc-solaris2.11.

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

llvm-svn: 365302
2019-07-08 09:18:38 +00:00
Julian Lettner a2ca358291 [TSan] Attempt to fix iOS on-device test
llvm-svn: 365257
2019-07-06 00:49:44 +00:00
Julian Lettner b1ff896e92 XFAIL a few failing TSan-fiber tests for iOS
llvm-svn: 365254
2019-07-05 23:23:36 +00:00
Julian Lettner b6654319f7 Remove `XFAIL: ios` from test that passes in CI
llvm-svn: 365253
2019-07-05 22:53:18 +00:00
Mitch Phillips 7339ca278c [GWP-ASan] Add generic unwinders and structure backtrace output.
Summary:
Adds two flavours of generic unwinder and all the supporting cruft. If the
supporting allocator is okay with bringing in sanitizer_common, they can use
the fast frame-pointer based unwinder from sanitizer_common. Otherwise, we also
provide the backtrace() libc-based unwinder as well. Of course, the allocator
can always specify its own unwinder and unwinder-symbolizer.

The slightly changed output format is exemplified in the first comment on this
patch. It now better incorporates backtrace information, and displays
allocation details on the second line.

Reviewers: eugenis, vlad.tsyrklevich

Reviewed By: eugenis, vlad.tsyrklevich

Subscribers: srhines, kubamracek, mgorny, cryptoad, #sanitizers, llvm-commits, morehouse

Tags: #sanitizers, #llvm

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

llvm-svn: 364941
2019-07-02 16:04:52 +00:00
Peter Collingbourne d11ea6518c hwasan: Teach the runtime to identify the local variable being accessed in UAR reports.
Each function's PC is recorded in the ring buffer. From there we can access
the function's local variables and reconstruct the tag of each one with the
help of the information printed by llvm-symbolizer's new FRAME command. We
can then find the variable that was likely being accessed by matching the
pointer's tag against the reconstructed tag.

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

llvm-svn: 364607
2019-06-27 23:16:13 +00:00
Reid Kleckner 8007ff1ab1 [compiler-rt] Rename lit.*.cfg.* -> lit.*.cfg.py.*
These lit configuration files are really Python source code. Using the
.py file extension helps editors and tools use the correct language
mode. LLVM and Clang already use this convention for lit configuration,
this change simply applies it to all of compiler-rt.

Reviewers: vitalybuka, dberris

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

llvm-svn: 364591
2019-06-27 20:56:04 +00:00
Rainer Orth e6474e682a [compiler-rt][test] Set shared_libasan_path in test/asan/lit.cfg on Solaris
While checking warnings from the Solaris buildbots, I noticed

  llvm-lit: /opt/llvm-buildbot/home/solaris11-amd64/clang-solaris11-amd64/llvm/projects/compiler-rt/test/asan/lit.cfg:119: warning: %shared_libasan substitution not set but dynamic ASan is available.

Fixed as follows.  Tested on x86_64-pc-solaris2.11.

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

llvm-svn: 364394
2019-06-26 08:19:57 +00:00
Dan Liew d38e251bf2 Follow up fix for r364366.
When setting the parallelism group support MSan and use a syntactically
compact condition.

rdar://problem/51754620

llvm-svn: 364369
2019-06-26 00:54:06 +00:00
Dan Liew 5242fbde5a Add USan+ASan and UBSan+TSan tests to shadow-memory lit parallelism group.
Summary:
Previously we were running these tests without the "shadow-memory"
lit parallelism group even though we run the ASan and TSan tests in
this group to avoid problems with many processes using shadow memory
in parallel.

On my local machine the UBSan+TSan tests would previously timeout
if I set a 30 second per test limit. With this change I no longer
see individual test timeouts.

This change was made in response to the greendragon build bot reporting
individual test timeouts for these tests. Given that the UBSan+ASan and
UBSan+TSan tests did not have a parallelism group previously it's likely
that some other change has caused the performance degradation. However
I haven't been able to track down the cause so until we do, this change
seems reasonable and is in line with what we already do with ASan and
TSan tests.

rdar://problem/51754620

Reviewers: yln, kubamracek, vsk, samsonov

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 364366
2019-06-26 00:35:51 +00:00
Vitaly Buka 5b9d0205aa [sanitizer] Enabled getpw_getgr.cc on iOS
Reviewers: kubamracek, delcypher, yln

Reviewed By: delcypher

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

Tags: #sanitizers, #llvm

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

llvm-svn: 364261
2019-06-25 01:01:46 +00:00
Sajjad Mirza 6694b2b36b (Reland with changes) Adding a function for setting coverage output file.
Summary:
User code can open a file on its own and pass it to the runtime, rather than
specifying a name and having the runtime open the file. This supports the use
case where a process cannot open a file on its own but can receive a file
descriptor from another process.

Relanding https://reviews.llvm.org/D62541. The original revision unlocked
the file before calling flush, this revision fixes that.

Reviewers: Dor1s, davidxl

Reviewed By: Dor1s

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 364231
2019-06-24 21:32:50 +00:00
Reid Kleckner 08b2bd0f30 [asan] Quote the path to the Python exe in case it has spaces
These days, Python 3 installs itself into Program Files, so it often has
spaces. At first, I resisted this, and I reinstalled it globally into
C:/Python37, similar to the location used for Python 2.7. But then I
updated VS 2019, and it uninstalled my copy of Python and installed a
new one inside "C:/Program Files (x86)/Microsoft Visual Studio/". At
this point, I gave up and switched to using its built-in version of
Python. However, now these tests fail, and have to be made aware of the
possibility of spaces in paths. :(

llvm-svn: 364077
2019-06-21 16:54:58 +00:00
Kostya Serebryany 679669a77e [libFuzzer] split DataFlow.cpp into two .cpp files, one of which can be compiled w/o dfsan to speed things up (~25% speedup)
llvm-svn: 364002
2019-06-21 01:39:35 +00:00
Kostya Serebryany 27cf743bff [libFuzzer] ensure that DFT and autofocus works for C++ (mangled) functions
llvm-svn: 363905
2019-06-20 01:48:45 +00:00
Hans Wennborg 2cf990fa27 Revert r363633 "[CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #2."
This caused Chromium's clang package to stop building, see comment on
https://reviews.llvm.org/D61242 for details.

> Summary:
> The main problem here is that `-*-version_min=` was not being passed to
> the compiler when building test cases. This can cause problems when
> testing on devices running older OSs because Clang would previously
> assume the minimum deployment target is the the latest OS in the SDK
> which could be much newer than what the device is running.
>
> Previously the generated value looked like this:
>
> `-arch arm64 -isysroot
> <path_to_xcode>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk`
>
> With this change it now looks like:
>
> `-arch arm64 -stdlib=libc++ -miphoneos-version-min=8.0 -isysroot
> <path_to_xcode>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk`
>
> This mirrors the setting of `config.target_cflags` on macOS.
>
> This change is made for ASan, LibFuzzer, TSan, and UBSan.
>
> To implement this a new `get_test_cflags_for_apple_platform()` function
> has been added that when given an Apple platform name and architecture
> returns a string containing the C compiler flags to use when building
> tests. This also calls a new helper function `is_valid_apple_platform()`
> that validates Apple platform names.
>
> This is the second attempt at landing the patch. The first attempt (r359305)
> had to be reverted (r359327) due to a buildbot failure. The problem was
> that calling `get_test_cflags_for_apple_platform()` can trigger a CMake
> error if the provided architecture is not supported by the current
> CMake configuration. Previously, this could be triggered by passing
> `-DCOMPILER_RT_ENABLE_IOS=OFF` to CMake. The root cause is that we were
> generating test configurations for a list of architectures without
> checking if the relevant Sanitizer actually supported that architecture.
> We now intersect the list of architectures for an Apple platform
> with `<SANITIZER>_SUPPORTED_ARCH` (where `<SANITIZER>` is a Sanitizer
> name) to iterate through the correct list of architectures.
>
> rdar://problem/50124489
>
> Reviewers: kubamracek, yln, vsk, juliehockett, phosek
>
> Subscribers: mgorny, javed.absar, kristof.beyls, #sanitizers, llvm-commits
>
> Tags: #llvm, #sanitizers
>
> Differential Revision: https://reviews.llvm.org/D61242

llvm-svn: 363779
2019-06-19 09:09:39 +00:00
Dan Liew 9216358c21 Disable recently added Darwin symbolization tests for iOS.
These tests won't necessarily work because the reported modules paths
from the device don't match what's on the host and so offline
symbolization fails.

llvm-svn: 363641
2019-06-18 01:38:03 +00:00
Dan Liew 745632c63a [NFC] Split `Darwin/asan-symbolize-partial-report-with-module-map.cc`.
Split `Darwin/asan-symbolize-partial-report-with-module-map.cc` into two
separate test cases due to them testing slightly different things.

llvm-svn: 363640
2019-06-18 01:38:02 +00:00
Dan Liew 3c9f66dccf [asan_symbolize] Teach `asan_symbolize.py` to symbolicate partially symbolicated ASan reports.
Summary:
The use case here is to be able symbolicate ASan reports that might be
partially symbolicated, in particular where the function name is known but no source
location is available. This can be caused by missing debug info. Previously we
would only try to symbolicate completely unsymbolicated reports.

The code currently contains an unfortunate quirk to handle a darwin
specific bug (rdar://problem/49784442) in the way partially symbolicated
reports are emitted when the source location is missing.

rdar://problem/49476995

Reviewers: kubamracek, yln, samsonov, dvyukov, vitalybuka

Subscribers: aprantl, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 363639
2019-06-18 01:21:16 +00:00
Peter Collingbourne d57f7cc15e hwasan: Use bits [3..11) of the ring buffer entry address as the base stack tag.
This saves roughly 32 bytes of instructions per function with stack objects
and causes us to preserve enough information that we can recover the original
tags of all stack variables.

Now that stack tags are deterministic, we no longer need to pass
-hwasan-generate-tags-with-calls during check-hwasan. This also means that
the new stack tag generation mechanism is exercised by check-hwasan.

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

llvm-svn: 363636
2019-06-17 23:39:51 +00:00
Dan Liew 964909e4a6 [CMake] Fix the value of `config.target_cflags` for non-macOS Apple platforms. Attempt #2.
Summary:
The main problem here is that `-*-version_min=` was not being passed to
the compiler when building test cases. This can cause problems when
testing on devices running older OSs because Clang would previously
assume the minimum deployment target is the the latest OS in the SDK
which could be much newer than what the device is running.

Previously the generated value looked like this:

`-arch arm64 -isysroot
<path_to_xcode>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk`

With this change it now looks like:

`-arch arm64 -stdlib=libc++ -miphoneos-version-min=8.0 -isysroot
<path_to_xcode>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk`

This mirrors the setting of `config.target_cflags` on macOS.

This change is made for ASan, LibFuzzer, TSan, and UBSan.

To implement this a new `get_test_cflags_for_apple_platform()` function
has been added that when given an Apple platform name and architecture
returns a string containing the C compiler flags to use when building
tests. This also calls a new helper function `is_valid_apple_platform()`
that validates Apple platform names.

This is the second attempt at landing the patch. The first attempt (r359305)
had to be reverted (r359327) due to a buildbot failure. The problem was
that calling `get_test_cflags_for_apple_platform()` can trigger a CMake
error if the provided architecture is not supported by the current
CMake configuration. Previously, this could be triggered by passing
`-DCOMPILER_RT_ENABLE_IOS=OFF` to CMake. The root cause is that we were
generating test configurations for a list of architectures without
checking if the relevant Sanitizer actually supported that architecture.
We now intersect the list of architectures for an Apple platform
with `<SANITIZER>_SUPPORTED_ARCH` (where `<SANITIZER>` is a Sanitizer
name) to iterate through the correct list of architectures.

rdar://problem/50124489

Reviewers: kubamracek, yln, vsk, juliehockett, phosek

Subscribers: mgorny, javed.absar, kristof.beyls, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 363633
2019-06-17 23:37:46 +00:00
Mitch Phillips 21184ec5c4 [GWP-ASan] Integration with Scudo [5].
Summary:
See D60593 for further information.

This patch adds GWP-ASan support to the Scudo hardened allocator. It also
implements end-to-end integration tests using Scudo as the backing allocator.
The tests include crash handling for buffer over/underflow as well as
use-after-free detection.

Reviewers: vlad.tsyrklevich, cryptoad

Reviewed By: vlad.tsyrklevich, cryptoad

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

Tags: #sanitizers, #llvm

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

llvm-svn: 363584
2019-06-17 17:45:34 +00:00
Kostya Serebryany db88fc56b9 [libFuzzer] implement a better queue for the fork mode. Add an internal flag -stop_file to allow graceful shutdown of fuzzing. Enhance the logging in the fork mode
llvm-svn: 363470
2019-06-14 22:56:50 +00:00
Kostya Serebryany 3f39123d15 [libFuzzer] simplify the DFT trace collection using the new faster DFSan mode that traces up to 16 labels at a time and never runs out of labels. Second attempt. This time with a fix for windows (putenv instead of setenv))
llvm-svn: 363445
2019-06-14 19:54:32 +00:00
Max Moroz 0784e01a98 [libFuzzer] Disable len_control by default if LLVMFuzzerCustomMutator is used.
Summary:
Some custom mutators may not peform well when size restriction is
enforced by len_control. Because of that, it's safer to disable len_control
by default in such cases, but still allow users to enable it manually.
Bug example: https://bugs.chromium.org/p/chromium/issues/detail?id=919530.

Tested manually with LPM-based and regular fuzz targets.

Reviewers: kcc, vitalybuka, metzman

Reviewed By: kcc, metzman

Subscribers: delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 363443
2019-06-14 19:34:11 +00:00
Hans Wennborg 9bc707c0e5 Revert r363326 "[libFuzzer] simplify the DFT trace collection using the new faster DFSan mode that traces up to 16 labels at a time and never runs out of labels."
It broke the Windows build:

C:\b\s\w\ir\cache\builder\src\third_party\llvm\compiler-rt\lib\fuzzer\FuzzerDataFlowTrace.cpp(243): error C3861: 'setenv': identifier not found

This also reverts the follow-up r363327.

llvm-svn: 363358
2019-06-14 07:32:22 +00:00