Commit Graph

13410 Commits

Author SHA1 Message Date
Vitaly Buka 1f3def16f6 [NFC][sanitizer] Fix test on 32bit platform 2020-12-02 07:32:40 -08:00
Ahsan Saghir 5045b831a3 [PowerPC] Mark sanitizer test case unsupported for powerpc64
The author of "https://reviews.llvm.org/D92428" marked
'resize_tls_dynamic.cpp' with XFAIL for powerpc64 since
it fails on a bunch of PowerPC buildbots. However, the
original test case passes on clang-ppc64le-rhel bot. So
marking this as XFAIL makes this bot to fail as the test
case passes unexpectedly. We are marking this unsupported
on all PowerPC64 for now until it is fixed for all the
PowerPC buildbots.
2020-12-02 09:03:28 -06:00
Vitaly Buka 3f0c4bfc64 [NFC][sanitizer] Fix ppc -> powerpc64 in XFAIL 2020-12-01 17:57:42 -08:00
Vitaly Buka bdd6718bef [NFC] Disable new test from D92428 on PPC TSAN 2020-12-01 16:54:14 -08:00
Vitaly Buka 8a300deb3e [sanitizer] Make DTLS_on_tls_get_addr signal safer
Avoid relocating DTV table and use linked list of mmap-ed pages.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D92428
2020-12-01 16:16:04 -08:00
Vitaly Buka adfefa5553 [NFC] Extract ForEachDVT 2020-12-01 16:15:32 -08:00
Alexey Baturo 17427ec3f3 [RISCV][crt] support building without init_array
Reviewed By: luismarques, phosek, kito-cheng

Differential Revision: https://reviews.llvm.org/D87997
2020-12-01 17:17:50 +03:00
Martin Storsjö 2e5aaf65a3 [compiler-rt] [emutls] Handle unused parameters in a compiler agnostic way
The MSVC specific pragmas disable this warning, but the pragmas themselves
(when not guarded by any _MSC_VER ifdef) cause warnings for other targets,
e.g. when targeting mingw.

Instead silence the MSVC warnings about unused parameters by casting
the parameters to void.

Differential Revision: https://reviews.llvm.org/D91851
2020-12-01 10:07:53 +02:00
Reid Kleckner b5af5787b3 [WinASan] Improve exception reporting accuracy
Previously, ASan would produce reports like this:
ERROR: AddressSanitizer: breakpoint on unknown address 0x000000000000 (pc 0x7fffdd7c5e86 ...)

This is unhelpful, because the developer may think this is a null
pointer dereference, and not a breakpoint exception on some PC.

The cause was that SignalContext::GetAddress would read the
ExceptionInformation array to retreive an address for any kind of
exception. That data is only available for access violation exceptions.
This changes it to be conditional on the exception type, and to use the
PC otherwise.

I added a variety of tests for common exception types:
- int div zero
- breakpoint
- ud2a / illegal instruction
- SSE misalignment

I also tightened up IsMemoryAccess and GetWriteFlag to check the
ExceptionCode rather than looking at ExceptionInformation[1] directly.

Differential Revision: https://reviews.llvm.org/D92344
2020-11-30 16:39:22 -08:00
Vy Nguyen 1b723a955d [sanitizer] Disable use_tls_dynamic on on-Android x86 Linux.
https://bugs.chromium.org/p/chromium/issues/detail?id=1153421

Differential Revision: https://reviews.llvm.org/D92273
2020-11-30 11:45:36 -05:00
Reid Kleckner b534beabee Revert builtins fp16 support: tests do not pass on Mac
Revert "[compiler-rt] [builtins] Support conversion between fp16 and fp128" & dependency

Revert "[compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if available"

This reverts commit 7a94829881.

This reverts commit 1fb91fcf9c.
2020-11-25 16:12:49 -08:00
Luís Marques 1bc85cbbb8 [Sanitizer][RISCV] Fix redefinition of REG_SP
The include header sys/ucontext.h already defines REG_SP as 2, causing
redefinition warnings during compilation. This patch fixes that issue.
(We also can't just use the numerical definition provided by the header,
as REG_SP is used in this file this refers to a struct field.)

Differential Revision: https://reviews.llvm.org/D90934
2020-11-25 00:04:47 +00:00
Evgenii Stepanov 237b024b06 [hwasan] Fix tests when vm.overcommit_memory=1.
Remove an invalid check from sizes.cpp that only passes when overcommit is disabled.

Fixes PR48274.

Differential Revision: https://reviews.llvm.org/D91999
2020-11-23 16:05:56 -08:00
Martin Storsjö 33fb9679ec [compiler-rt] [profile] Silence a warning about an unused function on mingw targets
This function is only used within the ifdef below.

Differential Revision: https://reviews.llvm.org/D91850
2020-11-21 22:14:35 +02:00
Evgenii Stepanov 08d90f72ce [hwasan] Implement error report callback.
Similar to __asan_set_error_report_callback, pass the entire report to a
user provided callback function.

Differential Revision: https://reviews.llvm.org/D91825
2020-11-20 16:48:19 -08:00
Vitaly Buka 3b947cc8ce [msan] unpoison_file from fclose and fflash
Also unpoison IO_write_base/_IO_write_end buffer

memcpy from fclose and fflash can copy internal bytes without metadata into user memory.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D91858
2020-11-20 13:09:01 -08:00
Rainer Orth 03d593dd7e [sanitizers][test] Test sanitizer_common and ubsan_minimal on Solaris
During the initial Solaris sanitizer port, I missed to enable the
`sanitizer_common` and `ubsan_minimal` testsuites.  This patch fixes this,
correcting a few unportabilities:

- `Posix/getpass.cpp` failed to link since Solaris lacks `libutil`.
  Omitting the library lets the test `PASS`, but I thought adding `%libutil`
  along the lines of `%librt` to be overkill.
- One subtest of `Posix/getpw_getgr.cpp` is disabled because Solaris
  `getpwent_r` has a different signature than expected.
- `/dev/null` is a symlink on Solaris.
- XPG7 specifies that `uname` returns a non-negative value on success.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D91606
2020-11-20 14:06:25 +01:00
Rainer Orth 0f69cbe269 [sanitizer_common][test] Disable CombinedAllocator32Compact etc. on Solaris/sparcv9
As reported in PR 48202, two allocator tests `FAIL` on Solaris/sparcv9,
presumably because Solaris uses the full 64-bit address space and the
allocator cannot deal with that:

  SanitizerCommon-Unit :: ./Sanitizer-sparcv9-Test/SanitizerCommon.CombinedAllocator32Compact
  SanitizerCommon-Unit :: ./Sanitizer-sparcv9-Test/SanitizerCommon.SizeClassAllocator32Iteration

This patch disables the tests.

Tested on `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D91622
2020-11-20 13:02:15 +01:00
Rainer Orth ce6524d127 [sanitizer_common][test] Disable FastUnwindTest.* on SPARC
Many of the `FastUnwindTest.*` tests `FAIL` on SPARC, both Solaris and
Linux.  The issue is that the fake stacks used in those tests don't match
the requirements of the SPARC unwinder in `sanitizer_stacktrace_sparc.cpp`
which has to look at the register window save area.

I'm disabling the failing tests.

Tested on `sparcv9-sun-solaris2.11`.
Differential Revision: https://reviews.llvm.org/D91618
2020-11-20 12:52:18 +01:00
Jianzhou Zhao b4ac05d763 Replace the equivalent code by UnionTableAddr
UnionTableAddr is always inlined.

Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/DD91758
2020-11-19 20:15:25 +00:00
Teresa Johnson a75b2e87e6 [MemProf] Add interface to dump profile
Add an interface so that the profile can be dumped on demand.

Differential Revision: https://reviews.llvm.org/D91768
2020-11-19 10:21:53 -08:00
Adhemerval Zanella 7a94829881 [compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if available
On AArch64 it allows use the native FP16 ABI (although libcalls are
not emitted for fptrunc/fpext lowering), while on other architectures
the expected current semantic is preserved (arm for instance).

Differential Revision: https://reviews.llvm.org/D91733
2020-11-19 15:14:50 -03:00
Adhemerval Zanella 1fb91fcf9c [compiler-rt] [builtins] Support conversion between fp16 and fp128
This patch adds both extendhftf2 and trunctfhf2 to support
conversion between half-precision and quad-precision floating-point
values. They are enabled iff the compiler supports _Float16.

Some notes on ARM plaforms: while __fp16 is supported on all
architectures, _Float16 is supported only for 32-bit ARM, 64-bit ARM,
and SPIR (as indicated by clang/docs/LanguageExtensions.rst).  Also,
__fp16 is a storage format and promoted to 'float' for argument passing
and 64-bit ARM supports floating-point convert precision to half as
base armv8-a instruction.

It means that although extendhfsf2, truncdfhf2 __truncsfhf2 will be
built for 64-bit ARM, they will be never used in practice (compiler
won't emit libcall to them). This patch does not change the ABI for
32-bit ARM, it will continue to pass _Float16 as uint16.

Differential Revision: https://reviews.llvm.org/D91732
2020-11-19 15:14:50 -03:00
Teresa Johnson 8f778b283d [sanitizer_common] Add facility to get the full report path
Add a new interface __sanitizer_get_report_path which will return the
full path to the report file if __sanitizer_set_report_path was
previously called (otherwise it returns null). This is useful in
particular for memory profiling handlers to access the path which
was specified at compile time (and passed down via
__memprof_profile_filename), including the pid added to the path when
the file is opened.

There wasn't a test for __sanitizer_set_report_path, so I added one
which additionally tests the new interface.

Differential Revision: https://reviews.llvm.org/D91765
2020-11-19 09:19:12 -08:00
Evgenii Stepanov 523cc097fd [hwasan] Fix Thread reuse (try 2).
HwasanThreadList::DontNeedThread clobbers Thread::next_,
Breaking the freelist. As a result, only the top of the freelist ever
gets reused, and the rest of it is lost.

Since the Thread object with its associated ring buffer is only 8Kb, this is
typically only noticable in long running processes, such as fuzzers.

Fix the problem by switching from an intrusive linked list to a vector.

Differential Revision: https://reviews.llvm.org/D91392
2020-11-18 16:04:08 -08:00
Vitaly Buka 0e2585c804 [tsan] Add pthread_cond_clockwait interceptor
Disable the test on old systems.
pthread_cond_clockwait is supported by glibc-2.30.
It also supported by Android api 30 even though we
do not run tsan on Android.

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

Reviewed By: dvyukov
2020-11-18 14:39:19 -08:00
Kostya Kortchinsky 5556616b5b [GWP-ASan] Port tests to Fuchsia
This modifies the tests so that they can be run on Fuchsia:
- add the necessary includes for `set`/`vector` etc
- do the few modifications required to use zxtest instead og gtest

`backtrace.cpp` requires stacktrace support that Fuchsia doesn't have
yet, and `enable_disable.cpp` currently uses `fork()` which Fuchsia
doesn't support yet. I'll revisit this later.

I chose to use `harness.h` to hold my "platform-specific" include and
namespace, and using this header in tests rather than `gtest.h`,
which I am open to change if someone would rather go another direction.

Differential Revision: https://reviews.llvm.org/D91575
2020-11-18 13:36:12 -08:00
Wolfgang Pieb 87369c6261 Revert "[tsan] Add pthread_cond_clockwait interceptor"
This reverts commit 16eb853ffd.

The test is failing on some Linux build bots. See the review for
an example.
2020-11-18 11:58:45 -08:00
Roland McGrath 7810d83786 [GWP-ASan] Respect GWP_ASAN_DEFAULT_ENABLED compile-time macro
If the containing allocator build uses -DGWP_ASAN_DEFAULT_ENABLED=false
then the option will default to false.  For e.g. Scudo, this is simpler
and more efficient than using -DSCUDO_DEFAULT_OPTIONS=... to set gwp-asan
options that have to be parsed from the string at startup.

Reviewed By: hctim

Differential Revision: https://reviews.llvm.org/D91463
2020-11-18 10:34:42 -08:00
Seonghyun Park 096bd9b293 [sanitizer] Fix typo in log messages
Fix typo in log messages

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D91492
2020-11-18 03:42:38 -08:00
Vitaly Buka 16eb853ffd [tsan] Add pthread_cond_clockwait interceptor
Fixes https://github.com/google/sanitizers/issues/1259

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D91684
2020-11-18 03:01:58 -08:00
Vitaly Buka 1c0ef2984d [NFC][tsan] Prepepare for more interceptors which use cond_wait() 2020-11-18 00:03:00 -08:00
Robert Underwood 16de50895e honor Python2_EXECUTABLE and Python3_EXECUTABLE when they are passed to cmake
CMake's find_package(Python3) and find_package(Python2) packages have a PYTHON_EXECUTABLE, Python2_EXECUTABLE, and Python3_EXECUTABLE cmake variables which control which version of python is built against.  As far as I can tell, the rest of LLVM honors these variables. This can cause the build process to fail when  if the automatically selected version of Python can't run due to modifications of LD_LIBRARY_PATH when using spack.  The corresponding Spack issue is https://github.com/spack/spack/issues/19908.  The corresponding LLVM issue is 48180

I believe an appropriate fix is to add the variables to the list of PASSTHROUGH_VARIABLES in cmake/Modules/AddCompilerRT.cmake, and this fixed compilation errors for me.

This bug affects distributions like Gentoo and package managers like Spack which allow for combinatorial versioning.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D91536
2020-11-17 17:49:14 -06:00
Amy Huang bc98034040 [llvm-symbolizer] Add inline stack traces for Windows.
This adds inline stack frames for symbolizing on Windows.

Differential Revision: https://reviews.llvm.org/D88988
2020-11-17 13:19:13 -08:00
Vy Nguyen b16e4d3fc1 [sanitizers-test]add definition for %device_rm on android so it stops complaining
Differential Revision: https://reviews.llvm.org/D91570
2020-11-16 19:57:54 -05:00
Kostya Kortchinsky f0703cb1b2 [scudo][standalone] Correct min/max region indices
The original code to keep track of the minimum and maximum indices
of allocated 32-bit primary regions was sketchy at best.

`MinRegionIndex` & `MaxRegionIndex` were shared between all size
classes, and could (theoretically) have been updated concurrently. This
didn't materialize anywhere I could see, but still it's not proper.

This changes those min/max indices by making them class specific rather
than global: classes are locked when growing, so there is no
concurrency there. This also allows to simplify some of the 32-bit
release code, that now doesn't have to go through all the regions to
get the proper min/max. Iterate and unmap will no longer have access to
the global min/max, but they aren't used as much so this is fine.

Differential Revision: https://reviews.llvm.org/D91106
2020-11-16 12:43:10 -08:00
Jonathan Metzman 91703085f5 [fuzzer] Disable uncaught-exception on non-Win+undo bad fix
Test is failing on non-Windows platforms. Also undo speculative
fix since it causes failures on Windows.
2020-11-16 09:35:35 -08:00
Jonathan Metzman a3be128709 [fuzzer] Add allocator_may_return_null to uncaught-exception.test.
Speculative fix for failing unittest.
2020-11-16 09:13:25 -08:00
Matthew Malcomson 83ac18205e Hwasan reporting check for dladdr failing
In `GetGlobalSizeFromDescriptor` we use `dladdr` to get info on the the
current address.  `dladdr` returns 0 if it failed.
During testing on Linux this returned 0 to indicate failure, and
populated the `info` structure with a NULL pointer which was
dereferenced later.

This patch checks for `dladdr` returning 0, and in that case returns 0
from `GetGlobalSizeFromDescriptor` to indicate failure of identifying
the address.

This occurs when `GetModuleNameAndOffsetForPC` succeeds for some address
not in a dynamically loaded library.  One example is when the found
"module" is '[stack]' having come from parsing /proc/self/maps.

Differential Revision: https://reviews.llvm.org/D91344
2020-11-16 12:25:27 +00:00
Vitaly Buka 2ec25bae5a [NFC][tsan] Simplify call_pthread_cancel_with_cleanup 2020-11-16 04:21:27 -08:00
Vitaly Buka 7006738131 [sanitizer] Fix StackDepotPrint testing
Make test order agnostic as it can change with platform.
2020-11-16 03:07:29 -08:00
Vitaly Buka 581ebf44d2 [sanitizer] Fix setup of android-thread-properties-api 2020-11-14 23:23:10 -08:00
Vitaly Buka dd0b8b94d0 [sanitizer] Add timeouts for adb calls 2020-11-14 18:43:45 -08:00
Vitaly Buka e51631ca4c [sanitizer] Fix Android API level parsing on arm 2020-11-14 01:54:45 -08:00
Vitaly Buka c8f4e06b29
[sanitizer] Fix test on arm 32bit
Make test values suitable for PC alignment arithmetic used
in StackTrace::Print().
2020-11-14 00:02:29 -08:00
Roland McGrath 6ef07111a4 [scudo/standalone] Fix leak in ThreadedGlobalQuarantine test
This unit test code was using malloc without a corresponding free.
When the system malloc is not being overridden by the code under
test, it might an asan/lsan allocator that notices leaks.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D91472
2020-11-13 22:24:44 -08:00
Joe Pletcher f897e82bfd [fuzzer] Add Windows Visual C++ exception intercept
Adds a new option, `handle_winexcept` to try to intercept uncaught
Visual C++ exceptions on Windows. On Linux, such exceptions are handled
implicitly by `std::terminate()` raising `SIBABRT`. This option brings the
Windows behavior in line with Linux.

Unfortunately this exception code is intentionally undocumented, however
has remained stable for the last decade. More information can be found
here: https://devblogs.microsoft.com/oldnewthing/20100730-00/?p=13273

Reviewed By: morehouse, metzman

Differential Revision: https://reviews.llvm.org/D89755
2020-11-12 13:11:14 -08:00
Zhuojia Shen 0c0eeb78eb [builtins] Add support for single-precision-only-FPU ARM targets.
This patch enables building compiler-rt builtins for ARM targets that
only support single-precision floating point instructions (e.g., those
with -mfpu=fpv4-sp-d16).

This fixes PR42838

Differential Revision: https://reviews.llvm.org/D90698
2020-11-12 15:10:48 +00:00
Jianzhou Zhao 3597fba4e5 Add a simple stack trace printer for DFSan
Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/D91235
2020-11-11 19:00:59 +00:00
Nico Weber 6ab31eeb62 Revert "[hwasan] Fix Thread reuse."
This reverts commit e1eeb026e6.
Test fails: https://reviews.llvm.org/D91208#2388613
2020-11-11 09:56:21 -05:00