Commit Graph

76 Commits

Author SHA1 Message Date
Evgeniy Stepanov b688a47963 New MSan mapping layout (compiler-rt part).
This is an implementation of
https://github.com/google/sanitizers/issues/579

It has a number of advantages over the current mapping:
* Works for non-PIE executables.
* Does not require ASLR; as a consequence, debugging MSan programs in
  gdb no longer requires "set disable-randomization off".
* Supports linux kernels >=4.1.2.
* The code is marginally faster and smaller.

This is an ABI break. We never really promised ABI stability, but
this patch includes a courtesy escape hatch: a compile-time macro
that reverts back to the old mapping layout.

llvm-svn: 249754
2015-10-08 21:35:34 +00:00
Renato Golin 814e5caebc [LSAN] Mark death callback as unstable while we investigate the cause in AArch64
llvm-svn: 249398
2015-10-06 13:29:44 +00:00
Adhemerval Zanella 19074450ee [MSan] Enable MSAN for aarch64
This patch enabled msan for aarch64 with 39-bit VMA and 42-bit VMA.
As defined by lib/msan/msan.h the memory layout used is for 39-bit is:

   00 0000 0000 - 40 0000 0000:  invalid
   40 0000 0000 - 43 0000 0000:  shadow
   43 0000 0000 - 46 0000 0000:  origin
   46 0000 0000 - 55 0000 0000:  invalid
   55 0000 0000 - 56 0000 0000:  app (low)
   56 0000 0000 - 70 0000 0000:  invalid
   70 0000 0000 - 80 0000 0000:  app (high)

And for 42-bit VMA:

   000 0000 0000 - 100 0000 0000:  invalid
   100 0000 0000 - 11b 0000 0000:  shadow
   11b 0000 0000 - 120 0000 0000:  invalid
   120 0000 0000 - 13b 0000 0000:  origin
   13b 0000 0000 - 2aa 0000 0000:  invalid
   2aa 0000 0000 - 2ab 0000 0000:  app (low)
   2ab 0000 0000 - 3f0 0000 0000:  invalid
   3f0 0000 0000 - 400 0000 0000:  app (high)

Most of tests are passing with exception of:

   * Linux/mallinfo.cc
   * chained_origin_limits.cc
   * dlerror.cc
   * param_tls_limit.cc
   * signal_stress_test.cc
   * nonnull-arg.cpp

The 'Linux/mallinfo.cc' is due the fact AArch64 returns the sret in 'x8'
instead of default first argument 'x1'.  So a function prototype that
aims  to mimic (by using first argument as the return of function) won't
work. For GCC one can make a register alias (register var asm ("r8")), but
for clang it detects is an unused variable and generate wrong code.

The 'chained_origin_limits' is probably due a wrong code generation,
since it fails only when origin memory is used
(-fsanitize-memory-track-origins=2) and only in the returned code
(return buf[50]).

The 'signal_streess_test' and 'nonnull-arg' are due currently missing variadic
argument handling in memory sanitizer code instrumentation on LLVM side.

Both 'dlerror' and 'param_tls_test' are unknown failures that require
further investigation.

All the failures are XFAIL for aarch64 for now.

llvm-svn: 247809
2015-09-16 15:12:25 +00:00
Alexey Samsonov 53b8750e7d [Sanitizers] Make abort_on_error common flag.
Summary:
Teach all sanitizers to call abort() instead of _exit() after printing
an error report, if requested. This behavior is the default on Mac OS.

Reviewers: kcc, kubabrecka

Subscribers: llvm-commits

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

llvm-svn: 246205
2015-08-27 20:40:24 +00:00
Alexey Samsonov 966eba0585 [Sanitizer] Test churn: use %env_tool_opts in sanitizer_common lit tests.
This follows the approach we use in ASan and UBSan lit tests to setup
tool options in a portable way, and to provide a nice way to specify
testsuite-wide defaults.

llvm-svn: 246058
2015-08-26 19:29:07 +00:00
Alexey Samsonov eb4fe7883f [TSan] Support __sanitizer_set_death_callback().
llvm-svn: 245776
2015-08-22 01:07:02 +00:00
Alexey Samsonov fc95c85cb5 [LSan] Support __sanitizer_set_death_callback in standalone LSan.
llvm-svn: 245758
2015-08-21 23:00:30 +00:00
Chris Bieneman 2335bb7e16 [CMake] Fixing r245581 based on feedback from Filcab.
llvm-svn: 245582
2015-08-20 17:46:58 +00:00
Chris Bieneman 5eae197ab0 [CMake] Fix building unit tests on Darwin
Summary:
There are a number of issues with unit tests on Darwin. These patches address the following:
* Unit tests should be passed -arch (-m32/-m64 isn't sufficient)
* Unit tests should be passed ${DARWIN_osx_CFLAGS} because they're being built for OS X
* Test architectures should be filtered based on base system capabilities (i.e. don't try running x86_64h tests on pre-haswell hardware).

Reviewers: bogner, filcab, kubabrecka

Subscribers: llvm-commits

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

llvm-svn: 245580
2015-08-20 17:32:06 +00:00
Renato Golin 86474c7a1a [ASAN/AArch64] Disable forkpty tests until we can fix them
Reported in PR24400. Disable until it works, so we can keep the rest
tested and green.

llvm-svn: 244398
2015-08-08 15:47:17 +00:00
Kostya Serebryany cc9fd3cbe9 [sanitizer] 2-nd attempt. Add the flag handle_sigfpe that is default true to handle SIGFPE crashes same as SIGSEV crashes, patch by Karl Skomski. This time the test is enabled only on x86-64 (it broke on ARM)
llvm-svn: 244234
2015-08-06 17:52:54 +00:00
Renato Golin 4ae2e1f575 Revert "[sanitizer] Add the flag handle_sigfpe that is default true to handle SIGFPE crashes same as SIGSEV crashes, patch by Karl Skomski"
This reverts commit r244136, it was breaking the ARM bots for too long. We should investigate it offline.

llvm-svn: 244210
2015-08-06 12:42:46 +00:00
Kostya Serebryany ce1799a83f [sanitizer] Add the flag handle_sigfpe that is default true to handle SIGFPE crashes same as SIGSEV crashes, patch by Karl Skomski
llvm-svn: 244136
2015-08-05 21:19:11 +00:00
Renato Golin 12a7cdc3a0 [AArch64] Stable runtime required for proc maps test
llvm-svn: 244105
2015-08-05 19:45:26 +00:00
Adhemerval Zanella 975998bf6a [asan] Enable asan for aarch64
This patch enables asan for aarch64/linux.  It marks it as 'unstable-release',
since some tests are failing due either kernel missing support of non-executable
pages in mmap or environment instability (infinite loop in juno reference
boards).

It sets decorate_proc_maps test to require stable-release, since the test expects
the shadow memory to not be executable and the support for aarch64 is only
added recently by Linux (da141706aea52c1a9 - 4.0).

It also XFAIL static_tls test for aarch64 linker may omit the __tls_get_addr call
as a TLS optimization.

llvm-svn: 244054
2015-08-05 15:13:33 +00:00
Nico Weber e099213481 Revert r243604, it (very likely) caused PR24312.
llvm-svn: 243615
2015-07-30 03:41:05 +00:00
Hans Wennborg 78bea23be0 [CMake] Pass -march=i686 when targeting i686 (PR24222)
Clang will not define __i686__, even when the target triple is i686,
without -march=i686.

With this patch, the compiler-rt build will successfully detect that
Clang can target i686.

The open_memstream.cc test is a little funny. Before my patch, it
was invoked with "-m32 -m64". To make it work after my -march
change, I had to add '-march=x86-64'.

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

llvm-svn: 243604
2015-07-30 01:45:17 +00:00
Evgeniy Stepanov df9ed542b5 [sanitizer] Implement include_if_exists with process name substitution.
include_if_exists=/path/to/sanitizer/options reads flags from the
file if it is present. "%b" in the include file path (for both
variants of the flag) is replaced with the basename of the main
executable.

llvm-svn: 242853
2015-07-21 23:03:13 +00:00
Dmitry Vyukov 2e2ac45655 asan: fix a test
Page size is not necessary 4096.
Use sysconf to obtain page size.

llvm-svn: 242651
2015-07-19 21:44:49 +00:00
Evgeniy Stepanov 3b78716207 [sanitizer] De-flake one test.
signal_segv_handler.cc occasionally fails due to a suspected kernel bug.
Increasing the mapped region size seems to make the test pass reliably.

llvm-svn: 242647
2015-07-19 19:57:13 +00:00
Evgeniy Stepanov 8e2fb681e3 [msan] Fix open_memstream handling.
For open_memstream() files, buffer pointer is only valid immediately after
fflush() or fclose(). Fix the fclose() interceptor to unpoison after the
REAL(fclose) call, not before it.

llvm-svn: 242535
2015-07-17 16:10:37 +00:00
Peter Collingbourne 23efcc8ed7 Temporarily disable check-sanitizer tests on 64-bit Windows.
llvm-svn: 241940
2015-07-10 20:35:53 +00:00
Dmitry Vyukov 189f061353 sanitizer_common: fix and re-enable signal_segv_handler test
struct sigaction was not initialized. As the result if SA_RESETHAND is set in sa_flags, then the handler is reset after first invocation leading to crash.
Initialize struct sigaction to zero.

Reviewed in http://reviews.llvm.org/D10803

llvm-svn: 240965
2015-06-29 16:31:10 +00:00
Evgeniy Stepanov 4b4a58ada4 [sanitizer] Disable signal_segv_handler test.
Random failures on the bots.

llvm-svn: 240668
2015-06-25 18:23:58 +00:00
Tim Northover b1f5879f3a Tests: disable test of /proc filesystem on Darwin.
We don't have it. I'm not entirely sure "Posix" is a good name for that
directory, but perhaps we should see how it develops.

llvm-svn: 238874
2015-06-02 21:59:04 +00:00
Evgeniy Stepanov 8e9c70be7f Add descriptive names to sanitizer entries in /proc/self/maps. Helps debugging.
This is done by creating a named shared memory region, unlinking it
and setting up a private (i.e. copy-on-write) mapping of that instead
of a regular anonymous mapping. I've experimented with regular
(sparse) files, but they can not be scaled to the size of MSan shadow
mapping, at least on Linux/X86_64 and ext3 fs.

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

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

llvm-svn: 238621
2015-05-29 22:31:28 +00:00
Yury Gribov 0ca65fd83d [sanitizer] More string interceptors: strstr, strcasestr, strspn, strcspn, strpbrk.
Patch by Maria Guseva.

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

llvm-svn: 238406
2015-05-28 09:24:33 +00:00
Sagar Thakur 3ee5bd9377 [sanitizer][MIPS] Add --target flag for MIPS32
Without the --target flag, clang uses the mips64 triple which selects the n64 abi. We need to add --target=mips-linux-gnu, so that clang can select the correct abi for mips32r2.

Reviewers: dsanders, kcc, samsonov
Subscribers: llvm-commits, mohit.bhakkad, jaydeep
Differential Revision: http://reviews.llvm.org/D9249

llvm-svn: 237675
2015-05-19 09:07:37 +00:00
Kostya Serebryany b044353bb2 [asan] under handle_abort=1 option intercept SIGABRT in addition to SIGSEGV/SIGBUS. Among other things this will allow to set up a death callback for SIGABRT and thus properly handle assert() in lib/Fuzzer
llvm-svn: 236474
2015-05-05 01:37:33 +00:00
Jay Foad fed74298cb [Sanitizer] Fix getpwnam test on ppc64le Fedora 21.
Summary:
On ppc64le Fedora 21, getpwnam_r("no-such-user", ...) returns ENOENT
instead of 0. Tolerate this in the test case.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: llvm-commits

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

llvm-svn: 235654
2015-04-23 22:20:33 +00:00
Dmitry Vyukov 72f169797e tsan: fix signal handling during stop-the-world
Long story short: stop-the-world briefly resets SIGSEGV handler to SIG_DFL.
This breaks programs that handle and continue after SIGSEGV (namely JVM).
See the test and comments for details.

This is reincarnation of reverted r229678 (http://reviews.llvm.org/D7722).
Changed:
- execute TracerThreadDieCallback only on tracer thread
- reset global data in TracerThreadSignalHandler/TracerThreadDieCallback
- handle EINTR from waitpid

Add 3 new test:
- SIGSEGV during leak checking
- StopTheWorld operation during signal storm from an external process
- StopTheWorld operation when the program generates and handles SIGSEGVs

http://reviews.llvm.org/D8032

llvm-svn: 231367
2015-03-05 14:37:28 +00:00
Alexey Samsonov 990864018f [Sanitizer] Run test/sanitizer_common lit tests on all supported architectures.
llvm-svn: 231025
2015-03-02 22:03:52 +00:00
Alexey Samsonov 1ce8745b77 [Sanitizer] Restrict open_memstream to x86_64. Fixes PR22714.
llvm-svn: 230996
2015-03-02 19:34:02 +00:00
Mohit K. Bhakkad b40fed04e7 [MSan][MIPS] Fix for some failing tests on MIPS64
Enabling internal ptrace for mips, which fixes some
ptrace related tests. Along with this fixing some
other failures.

Reviewers: Reviewers: eugenis, kcc, samsonov

Subscribers: dsanders, sagar, lldb-commits

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

llvm-svn: 229656
2015-02-18 09:24:19 +00:00
Kostya Serebryany 3c052cc051 [asan] use getrusage as an alternative to reading /proc/self/statm. Also move GetRSS to sanitizer_linux_libcdep.cc (no change in the function itself)
llvm-svn: 227416
2015-01-29 02:54:39 +00:00
Evgeniy Stepanov 0729053dac [sanitizer] Move sched_getparam test under Linux/.
llvm-svn: 226832
2015-01-22 15:34:50 +00:00
Evgeniy Stepanov 229984947b [sanitizer] Intercept sched_getparam.
llvm-svn: 226827
2015-01-22 14:03:07 +00:00
Evgeniy Stepanov a2edd9159a [sanitizer] Make unrecognized flags not fatal.
Print a warning at verbosity=1 and higher instead of dying immediately.

llvm-svn: 226458
2015-01-19 12:22:57 +00:00
Evgeniy Stepanov 141c5a9ae0 [sanitizer] Move options-related tests to sanitizer_common.
And handle help=1 in standalone LSan.

llvm-svn: 226438
2015-01-19 09:21:44 +00:00
Kostya Serebryany 8cc4002df2 [asan] make a test consume 2x less RAM (we observe flaky bot failures that seem like OOMs)
llvm-svn: 225478
2015-01-08 23:37:09 +00:00
Kostya Serebryany 7e85a9216e [asan] add a flag soft_rss_limit_mb
llvm-svn: 225323
2015-01-06 23:53:32 +00:00
Kostya Serebryany 43eb7735f2 [asan] new flag: hard_rss_limit_mb
llvm-svn: 224353
2014-12-16 19:13:01 +00:00
Kostya Serebryany 42102b110e [asan] introduce __sanitizer_set_death_callback, deprecate __asan_set_death_callback
llvm-svn: 224286
2014-12-15 23:02:57 +00:00
Alexey Samsonov fbaaed6b58 [Sanitizer] Introduce "stack_trace_format" runtime flag.
This flag can be used to specify the format of stack frames - user
can now provide a string with placeholders, which should be printed
for each stack frame with placeholders replaced with actual data.
For example "%p" will be replaced by PC, "%s" will be replaced by
the source file name etc.

"DEFAULT" value enforces default stack trace format currently used in
all the sanitizers except TSan.

This change also implements __sanitizer_print_stack_trace interface
function in TSan.

llvm-svn: 221469
2014-11-06 18:43:45 +00:00
Renato Golin 883abab1e8 Disable XFAIL on ARM since the x86_64 specific code is isolated
llvm-svn: 221347
2014-11-05 14:44:58 +00:00
Jay Foad 70a3841a8f Get the Linux ptrace test working on PowerPC64
The test refers to user_regs_struct.rip so it can only ever have worked
on x86-64. Put this code inside an appropriate #if, and add a similar
case for PowerPC64. (If we do likewise for ARM we can probably remove
the XFAILs, but I have no way of testing that.)

Those changes are enough to get the test working for me on big-endian
PowerPC64 Fedora 19.

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

llvm-svn: 221337
2014-11-05 08:42:48 +00:00
Alexey Samsonov 3ca50c34ec Add runtime flag 'symbolize_inline_frames' to disable symbolization of inlined frames done in llvm-symbolizer
llvm-svn: 220582
2014-10-24 18:34:43 +00:00
Renato Golin 1aaa4bcdd1 Mark sanitizer tests XFAIL on ARMv7
ASAN, UBSAN and profile tests that don't work with arm-linux-gnueabi and
android also don't work on armv7l-linux-gnueabihf. Some of the tests have
known causes, others not yet. In order to get a green bot, I'm disabling
those tests for now and will investigate when the priority rises.

llvm-svn: 219343
2014-10-08 21:13:23 +00:00
Lorenzo Martignoni 60ebffc12f Custom wrappers for DFSanitizing sprintf & snprintf.
Differential Revision: http://reviews.llvm.org/D5561

llvm-svn: 219293
2014-10-08 10:01:42 +00:00
Alexey Samsonov 62063b46fc Use "-gline-tables-only" instead of "-g" in sanitizer test suites.
We are interested in verifying that -gline-tables-only provides enough
debug information for verbose error reports and symbolized stack traces.

llvm-svn: 217284
2014-09-05 22:05:32 +00:00