Commit Graph

999 Commits

Author SHA1 Message Date
Renato Golin 12a7cdc3a0 [AArch64] Stable runtime required for proc maps test
llvm-svn: 244105
2015-08-05 19:45:26 +00:00
Alexey Samsonov 894d5821e7 [UBSan] Fix UBSan-vptr false positive.
Offset from vptr to the start of most-derived object can actually
be positive in some virtual base class vtables.

Patch by Stephan Bergmann!

llvm-svn: 244101
2015-08-05 19:35:46 +00:00
Adhemerval Zanella d7984710ae [tsan] Enable tsan for aarch64
This patch enabled TSAN for aarch64 with 39-bit VMA layout.  As defined by
tsan_platform.h the layout used is:

0000 4000 00 - 0200 0000 00: main binary
2000 0000 00 - 4000 0000 00: shadow memory
4000 0000 00 - 5000 0000 00: metainfo
5000 0000 00 - 6000 0000 00: -
6000 0000 00 - 6200 0000 00: traces
6200 0000 00 - 7d00 0000 00: -
7d00 0000 00 - 7e00 0000 00: heap
7e00 0000 00 - 7fff ffff ff: modules and main thread stack

Which gives it about 8GB for main binary, 4GB for heap and 8GB for
modules and main thread stack.

Most of tests are passing, with the exception of:

 * ignore_lib0, ignore_lib1, ignore_lib3 due a kernel limitation for
   no support to make mmap page non-executable.

 * longjmp tests due missing specialized assembly routines.

These tests are xfail for now.

The only tsan issue still showing is:

  rtl/TsanRtlTest/Posix.ThreadLocalAccesses

Which still required further investigation.  The test is disable for
aarch64 for now.

llvm-svn: 244055
2015-08-05 15:17:59 +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
Naomi Musgrave 2551b62931 Runtime check of poisoning derived class members.
Summary: Simple test case to verify that an instance of a derived class with virtual base is properly poisoned

Reviewers: eugenis, kcc

Subscribers: cfe-commits

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

modified test to be more concise, and check the local pointer to the destroyed object

revised test to not examine padding- only explicit object members

llvm-svn: 243913
2015-08-03 23:01:19 +00:00
Reid Kleckner 646386e779 [asan] Print VAs instead of RVAs for module offsets on Windows
Summary:
This is consistent with binutils and ASan behavior on other platforms,
and makes it easier to use llvm-symbolizer with WinASan. The
--relative-address flag to llvm-symbolizer is also no longer needed.

An RVA is a "relative virtual address", meaning it is the address of
something inside the image minus the base of the mapping at runtime.

A VA in this context is an RVA plus the "preferred base" of the module,
and not a real runtime address. The real runtime address of a symbol
will equal the VA iff the module is loaded at its preferred base at
runtime.

On Windows, the preferred base is stored in the ImageBase field of one
of the PE file header, and this change adds the necessary code to
extract it. On Linux, this offset is typically included in program and
section headers of executables.

ELF shared objects typically use a preferred base of zero, meaning the
smallest p_vaddr field in the program headers is zero. This makes it so
that PIC and PIE module offsets come out looking like RVAs, but they're
actually VAs. The difference between them simply happens to be zero.

Reviewers: samsonov, majnemer

Subscribers: llvm-commits

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

llvm-svn: 243895
2015-08-03 19:51:18 +00:00
Evgeniy Stepanov c86e7cfee9 [asan] Link tests with ld.gold on Android.
ld.bfd fails to find dependencies of asan runtime library w/o an
extra -rpath-link pointing to usr/lib under the sysroot. Gold does
not have this problem.

llvm-svn: 243802
2015-08-01 00:01:23 +00:00
Alexey Samsonov 25ac9311d0 [ASan] Fix two tests on FreeBSD: alloca.h is missing there.
llvm-svn: 243800
2015-07-31 23:57:06 +00:00
Filipe Cabecinhas 698e8cf845 [UBSan] Test: Move coverage-levels.cc out of Linux directory
Summary:
This test is working on other platforms.

Reviewers: samsonov, emaste

Subscribers: llvm-commits

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

llvm-svn: 243771
2015-07-31 18:18:07 +00:00
Sergey Dmitrouk a2ce083d2d Fix __floatsitf() for negative input
Negative numbers were handled properly initially, but got broken
during addressing review, so none of them did actually work.  Issues:
 * Wrong negation.
 * Wrong exponent calculation.

llvm-svn: 243746
2015-07-31 13:32:09 +00:00
Renato Golin 341d42c270 [AArch64|DFSAN] XPASS custom.cc, as it got fixed by r243686
llvm-svn: 243743
2015-07-31 10:50:29 +00:00
Adhemerval Zanella 4e3b4ac241 [dfsan] Enable dfsan for aarch64
This patch enable DFSan for AArch64 (39-bit VMA).  All tests are passing
but:

 * test/dfsan/custom.cc

Due an invalid access in dl_iterate_phdr instrumentation (commenting out
this function make the testcase to pass).  The test is XFAIL for aarch64
for now.

llvm-svn: 243688
2015-07-30 21:13:21 +00:00
Naomi Musgrave 64a1bd9db8 testing for tail call optimization repression when sanitizing use-after-dtor
Summary: Verify that running in optimized mode while checking for use-after-dtor errors, does not generate tail call invocation of destructor. This avoids possible error where stack frame for the destructor is eliminated, making tracking down the errors more difficult.

Reviewers: eugenis, kcc

Subscribers: cfe-commits

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

simplified test cases

updated line numbering on test

renamed test

llvm-svn: 243675
2015-07-30 18:46:18 +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
Kostya Serebryany c69bf1b4c0 [asan,tsan,msan] move the memcmp interceptor from asan/tsan to sanitizer_common. This may potentially lead to more reports from msan as it now sees the reads inside memcmp. To disable, use the flag intercept_memcmp=0. Likewise, it may potentially cause new races to appear due to more strict memcmp checking (flag strict_memcmp=1)
llvm-svn: 243595
2015-07-29 23:53:08 +00:00
Evgeniy Stepanov 1378c683e9 [asan] XFAIL 1 test on Android.
The test uses source file relative paths which does not work when the
test is executed on a remote device.

llvm-svn: 243564
2015-07-29 20:17:21 +00:00
Peter Collingbourne ea087056ae CFI: Update tests for various bit vector sizes following lowerbitsets optzns.
Also add a test to ensure that this doesn't regress.

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

llvm-svn: 243547
2015-07-29 18:12:45 +00:00
Evgeniy Stepanov 7eeb02bd09 [asan] Read process name from /proc/self/cmdline on Linux.
Rename getBinaryBasename() to getProcessName() and, on Linux,
read it from /proc/self/cmdline instead of /proc/self/exe. The former
can be modified by the process. The main motivation is Android, where
application processes re-write cmdline to a package name. This lets
us setup per-application ASAN_OPTIONS through include=/some/path/%b.

llvm-svn: 243473
2015-07-28 20:27:51 +00:00
Kuba Brecka cd7720c970 Fix typo from r243418. Should fix the failing `abort_on_error.cc` test.
See http://reviews.llvm.org/D7203

llvm-svn: 243426
2015-07-28 15:43:45 +00:00
Kuba Brecka a0905079d5 Applying the Darwin-specific default lit ASAN_OPTIONS to UBSan+ASan tests as
well. Should fix the test failures after r243418, see review at
http://reviews.llvm.org/D7203.

llvm-svn: 243423
2015-07-28 15:35:04 +00:00
Kuba Brecka 873855e291 [asan] Set abort_on_error=1 by default on OS X
This sets the default ASan flags to abort_on_error=1 on OS X. For unit tests and lit tests we set ASAN_OPTIONS back to abort_on_error=0 before running the tests (to avoid crashing). I added two tests that intentionally don't respect the default ASAN_OPTIONS to test the behavior of an empty ASAN_OPTIONS (on OS X we should crash, on Linux we should exit()).

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

llvm-svn: 243418
2015-07-28 14:34:13 +00:00
Kuba Brecka a11cfb990a [asan] Rename the ABI versioning symbol to '__asan_version_mismatch_check' instead of abusing '__asan_init'
We currently version `__asan_init` and when the ABI version doesn't match, the linker gives a `undefined reference to '__asan_init_v5'` message. From this, it might not be obvious that it's actually a version mismatch error. This patch makes the error message much clearer by changing the name of the undefined symbol to be `__asan_version_mismatch_check_xxx` (followed by the version string). We obviously don't want the initializer to be named like that, so it's a separate symbol that is used only for the purpose of version checking.

Reviewed at http://reviews.llvm.org/D11004

llvm-svn: 243004
2015-07-23 10:55:13 +00:00
Reid Kleckner d2a8dc88ff [asan] Remove CHECK line for kernel32.dll
Windows 8 users report that it isn't present in the address space by
default anymore.

Fixes PR23773.

llvm-svn: 242958
2015-07-22 22:39:36 +00:00
Reid Kleckner 24e5ee7708 [asan] Disable ctrl+c test until I figure out how to make it portable
llvm-svn: 242952
2015-07-22 22:25:07 +00:00
Reid Kleckner 33b9cd2191 [asan] Make __asan_handle_no_return tolerate unregistered threads
Summary:
On Windows, thread injection by the kernel or other running processes is
a fairly common occurrence, so ASan should be resilient to it.  The
comments on GetCurrentThread() say that it can return null, so we
shouldn't be CHECK failing if it does.

Sending control-C is one way to get the kernel to inject a thread into
your process, so I wrote a test around it.

Reviewers: llvm-commits

Subscribers: samsonov

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

llvm-svn: 242948
2015-07-22 21:58:31 +00:00
Reid Kleckner 83a019d427 [asan] Test clang's SEH implementation as well as MSVC's
llvm-svn: 242933
2015-07-22 20:54:24 +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
Kuba Brecka 8c5db0f852 Reverting r242787, attempt 2.
llvm-svn: 242799
2015-07-21 16:31:35 +00:00
Kuba Brecka e40677434b Reverting r242787 ("[asan] Fix the freopen interceptor to allow NULL instead of a filename") to investigate buildbot failure.
llvm-svn: 242791
2015-07-21 15:27:40 +00:00
Kuba Brecka 4c0cdec138 [asan] Fix the freopen interceptor to allow NULL instead of a filename
According to man freopen, passing NULL instead of a filename is valid, however the current implementation of the interceptor assumes this parameter is non-NULL. Let's fix that and add a test case.

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

llvm-svn: 242787
2015-07-21 14:23:27 +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
Alexey Samsonov e6c614d48a [Sanitizer] Teach ReadFileToBuffer to distinguish empty file from inaccessible file.
Summary:
This fixes https://code.google.com/p/address-sanitizer/issues/detail?id=399
(sanitizers crash with empty suppression files).

Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 242594
2015-07-17 23:50:08 +00:00
Naomi Musgrave 41b3226637 added test file
llvm-svn: 242590
2015-07-17 23:28:02 +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
Alexey Samsonov fd5211a5b3 [ASan] PR24150: restrict test case to i386.
llvm-svn: 242449
2015-07-16 21:46:58 +00:00
Alexey Samsonov 41bcf0bca2 [Sanitizer] Fix fopencookie() interceptor to work with null hook functions.
llvm-svn: 242193
2015-07-14 20:13:42 +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
Alexey Samsonov f40c1076c9 [TSan] Fix dl_iterate_phdr callback for the case when info->dlpi_name is overwritten by user.
llvm-svn: 241876
2015-07-10 00:03:54 +00:00
Diego Novillo eae951415e Add support for generating profiles in a given directory.
When the file is initialized, this patch checks whether the path
specifies a directory. If so, it creates the directory tree before
truncating the file.

Use default.profdata instead of pgo-data for default indexed profile name.

llvm-svn: 241824
2015-07-09 17:21:52 +00:00
Kostya Serebryany 7f1e1f0f8e [asan] relax the test case to allow either 'malloc' or '__interceptor_malloc' ; PR22681
llvm-svn: 241755
2015-07-08 22:57:03 +00:00
Peter Collingbourne 702548d9ea CFI: Get check-cfi passing on Windows.
Specifically:

- Start using %expect_crash.

- Provide an implementation of __ubsan::getDynamicTypeInfoFromVtable
  for the Microsoft C++ ABI. This is all that is needed for CFI
  diagnostics; UBSan's -fsanitize=vptr also requires an implementation of
  __ubsan::checkDynamicType.

- Build the sanitizer runtimes against the release version of the C
  runtime, even in debug builds.

- Accommodate demangling differences in tests.

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

llvm-svn: 241745
2015-07-08 22:10:34 +00:00
Kuba Brecka 61db9ebdea [asan] Add missing $ASAN_OPTIONS to some test cases
Since http://reviews.llvm.org/D10294, ASan test cases now respect default env. options via `ASAN_OPTION=$ASAN_OPTIONS:additional_options=xxx`.  This patch adds this to a few test cases where it's still missing.

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

llvm-svn: 241571
2015-07-07 09:55:00 +00:00
Kuba Brecka 76cc55a94d [asan] Add OS X 10.11's new dyld interposition support
On OS X 10.11 (which is currently a public beta), the dynamic linker has been improved so that it doesn't require the use of DYLD_INSERT_LIBRARIES in order for interposition/wrappers to work. This patch adds support of this behavior into ASan – we no longer need to re-exec in case the env. variable is not set.

Reviewed at http://reviews.llvm.org/D10924

llvm-svn: 241487
2015-07-06 19:07:55 +00:00
Kuba Brecka f3a493638f [asan] Fix an OS X startup crash when an empty section is present
On OS X, when the main instrumented binary contains a custom section with zero length, ASan will crash (assert failure) early in the initialization.

Reviewed at http://reviews.llvm.org/D10944

llvm-svn: 241474
2015-07-06 17:17:06 +00:00
Jay Foad b120712b29 Enable this test for PPC64.
llvm-svn: 241400
2015-07-05 08:11:36 +00:00
Peter Collingbourne a68d90fa52 UBSan: Enable runtime library tests on Windows, and get most tests passing.
Specifically:

- Disable int128 tests on Windows, as MSVC cl.exe does not support
  int128, so we might not have been able to build the runtime
  with int128 support.

- XFAIL the vptr tests as we lack Microsoft ABI support.

- XFAIL enum.cpp as UBSan fails to add the correct instrumentation code
  for some reason.

- Modify certain tests that build executables multiple times to use
  unique names for each executable. This works around a race condition
  observed on Windows.

- Implement IsAccessibleMemoryRange for Windows to fix the last
  misaligned.cpp test.

- Introduce a substitution for testing crashes on Windows using
  KillTheDoctor.

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

llvm-svn: 241303
2015-07-02 22:08:38 +00:00
Evgeniy Stepanov b41e87c534 [asan] Suppress read_binary_name_regtest.c test failure on unsupported hosts.
read_binary_name_regtest.c requires seccomp kernel headers.
Make the test pass if <linux/seccomp.h> is missing.

llvm-svn: 241119
2015-06-30 21:28:55 +00:00
Dmitry Vyukov 1d9b5e6ece tsan: fix handling of condition variable destruction
POSIX states that "It shall be safe to destroy an initialized condition
variable upon which no threads are currently blocked", and later clarifies
"A condition variable can be destroyed immediately after all the threads
that are blocked on it are awakened) (in examples section). Tsan reported
such destruction as a data race.
Fixes https://llvm.org/bugs/show_bug.cgi?id=23616
Reviewed in http://reviews.llvm.org/D10693

llvm-svn: 241082
2015-06-30 17:23:29 +00:00