Commit Graph

13275 Commits

Author SHA1 Message Date
Nico Weber 6f9d84bb26 Revert "hwasan: Disable operator {new,delete} interceptors when interceptors are disabled."
This reverts commit fa66bcf4bc.
Seems to break tests, see https://reviews.llvm.org/D89827#2351930
2020-10-24 15:04:22 -04:00
Benjamin Kramer 39a0d6889d [X86] Add a stub for Intel's alderlake.
No scheduling, no autodetection.
2020-10-24 19:01:22 +02:00
Vitaly Buka 21d64c32ec [NFC][UBSAN] Refine CHECK pattern in test
As-is it was failed by unrelated linker warning with filename in the
output.
2020-10-23 21:11:03 -07:00
Peter Collingbourne fa66bcf4bc hwasan: Disable operator {new,delete} interceptors when interceptors are disabled.
Differential Revision: https://reviews.llvm.org/D89827
2020-10-23 21:03:47 -07:00
Vitaly Buka 776a15d8ae [NFC][UBSAN] Avoid "not FileCheck" in tests
It's not clear if "not FileCheck" succeeded because
input is empty or because input does not match "CHECK:"
pattern.
2020-10-23 19:13:01 -07:00
Max Moroz dc62d5ec97 [libFuzzer] Added -print_full_coverage flag.
-print_full_coverage=1 produces a detailed branch coverage dump when run on a single file.
Uses same infrastructure as -print_coverage flag, but prints all branches (regardless of coverage status) in an easy-to-parse format.
Usage: For internal use with machine learning fuzzing models which require detailed coverage information on seed files to generate mutations.

Differential Revision: https://reviews.llvm.org/D85928
2020-10-23 16:05:54 -07:00
Teresa Johnson eeba325b12 [MemProf] Attempt to debug avr bot failure
Reverts the XFAIL added in b67a2aef8a,
which had no effect.

Adjust the test to make sure all output is dumped to stderr, so that
hopefully I can get a better idea of where/why this is failing.

Remove some redundant checking while here.
2020-10-23 16:00:08 -07:00
Amy Huang 3827effe3a [Asan][Windows] Fix asan stack traces on Windows.
While implementing inline stack traces on Windows I noticed that the stack
traces in many asan tests included an inlined frame that shouldn't be there.

Currently we get the PC and then do a stack unwind and use the PC to
find the beginning of the stack trace.
In the failing tests the first thing in the stack trace is inside an inline
call site that shouldn't be in the stack trace, so replace it with the PC.

Differential Revision: https://reviews.llvm.org/D89996
2020-10-23 13:14:14 -07:00
Teresa Johnson b67a2aef8a [MemProf] XFAIL test on avr until issue can be debugged
For unknown reasons, this test started failing only on the
llvm-avr-linux bot after 5c20d7db9f2791367b9311130eb44afecb16829c:
http://lab.llvm.org:8011/#/builders/112/builds/365

The error message is not helpful, and I have an email out to the bot
owner to help with debugging. XFAIL it on avr for now.
2020-10-23 11:32:11 -07:00
Alex Orlov 9df832d1c3 These compiler-rt tests should be UNSUPPORTED instead of XFAIL.
These compiler-rt tests should be UNSUPPORTED instead of XFAIL, which seems to be the real intent of the authors.

Reviewed By: vvereschaka

Differential Revision: https://reviews.llvm.org/D89840
2020-10-23 20:57:18 +04:00
Kostya Kortchinsky 3580a45014 [GWP-ASan] Move random-related code in the allocator (redo)
This is a redo of D89908, which triggered some `-Werror=conversion`
errors with GCC due to assignments to the 31-bit variable.

This CL adds to the original one a 31-bit mask variable that is used
at every assignment to silence the warning.

Differential Revision: https://reviews.llvm.org/D89984
2020-10-22 13:56:24 -07:00
Nikita Popov 04e42f6254 Revert "[GWP-ASan] Move random-related code in the allocator"
This reverts commit 9903b0586c.

Causes build failures (on GCC 10.2) with the following error:

In file included from /home/nikic/llvm-project/compiler-rt/lib/scudo/standalone/combined.h:29,
                 from /home/nikic/llvm-project/compiler-rt/lib/scudo/standalone/allocator_config.h:12,
                 from /home/nikic/llvm-project/compiler-rt/lib/scudo/standalone/wrappers_cpp.cpp:14:
/home/nikic/llvm-project/compiler-rt/lib/scudo/standalone/../../gwp_asan/guarded_pool_allocator.h: In member function ‘bool gwp_asan::GuardedPoolAllocator::shouldSample()’:
/home/nikic/llvm-project/compiler-rt/lib/scudo/standalone/../../gwp_asan/guarded_pool_allocator.h:82:69: error: conversion from ‘uint32_t’ {aka ‘unsigned int’} to ‘unsigned int:31’ may change value [-Werror=conversion]
   82 |           (getRandomUnsigned32() % (AdjustedSampleRatePlusOne - 1)) + 1;
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
2020-10-22 21:56:37 +02:00
Kostya Kortchinsky 9903b0586c [GWP-ASan] Move random-related code in the allocator
We need to have all thread specific data packed into a single `uintptr_t`
for the upcoming Fuchsia support. We can move the `RandomState` into the
`ThreadLocalPackedVariables`, reducing the size of `NextSampleCounter`
to 31 bits (or we could reduce `RandomState` to 31 bits).

We move `getRandomUnsigned32` into the platform agnostic part of the
class, and `initPRNG` in the platform specific part.

`ScopedBoolean` is replaced by actual assignments since non-const
references to bitfields are prohibited.

`random.{h,cpp}` are removed.

Differential Revision: https://reviews.llvm.org/D89908
2020-10-22 11:52:08 -07:00
Teresa Johnson 5c20d7db9f [MemProf] Allow the binary to specify the profile output filename
This will allow the output directory to be specified by a build time
option, similar to the directory specified for regular PGO profiles via
-fprofile-generate=. The memory profiling instrumentation pass will
set up the variable. This is the same mechanism used by the PGO
instrumentation and runtime.

Depends on D87120 and D89629.

Differential Revision: https://reviews.llvm.org/D89086
2020-10-22 08:30:19 -07:00
Vy Nguyen e2858997ab Do not intercept __libc_memalign and cfree on Android because neither of these exists in Bionic.
Differential Revision: https://reviews.llvm.org/D89616
2020-10-21 23:21:45 -04:00
Teresa Johnson 1bb68c9b18 [sanitizer] Allow log_path to distinguish default from explicit stderr
Split out of D89086 as suggested.

Change the default of the log_path flag to nullptr, and the code
consuming that flag (ReportFile::SetReportPath), to treat nullptr as
stderr (so no change to the behavior of existing users). This allows
code to distinguish between the log_path being specified explicitly as
stderr vs the default.

This is so the flag can be used to override the new report path variable
that will be encoded in the binary for memprof for runtime testing.

Differential Revision: https://reviews.llvm.org/D89629
2020-10-21 19:32:36 -07:00
Vy Nguyen 3b3aef198b [sanitizer]Update tests to be compatible with Android.
Split off from D89251

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D89884
2020-10-21 17:16:54 -07:00
Teresa Johnson 31bc55d602 [sanitizer] Convert PrintModuleMap to DumpProcessMap
As discussed in the review for D87120 (specifically at
https://reviews.llvm.org/D87120#inline-831939), clean up PrintModuleMap
and DumpProcessMap usage differences. The former is only implemented for
Mac OSX, whereas the latter is implemented for all OSes. The former is
called by asan and tsan, and the latter by hwasan and now memprof, under
the same option. Simply rename the PrintModuleMap implementation for Mac
to DumpProcessMap, remove other empty PrintModuleMap implementations,
and convert asan/tsan to new name. The existing posix DumpProcessMap is
disabled for SANITIZER_MAC.

Differential Revision: https://reviews.llvm.org/D89630
2020-10-21 12:46:49 -07:00
Luís Marques 58f6b16c49 [compiler-rt][builtins][RISCV] Always include __mul[sd]i3 builtin definitions
The RISC-V implementations of the `__mulsi3`, `__muldi3` builtins were
conditionally compiling the actual function definitions depending on whether
the M extension was present or not. This caused Compiler-RT testing failures
for RISC-V targets with the M extension, as when these sources were included
the `librt_has_mul*i3` features were still being defined. These `librt_has_*`
definitions are used to conditionally run the respective tests. Since the
actual functions were not being compiled-in, the generic test for `__muldi3`
would fail. This patch makes these implementations follow the normal
Compiler-RT convention of always including the definition, and conditionally
running the respective tests by using the lit conditional
`REQUIRES: librt_has_*`.

Since the `mulsi3_test.c` wasn't actually RISC-V-specific, this patch also
moves it out of the `riscv` directory. It now only depends on
`librt_has_mulsi3` to run.

Differential Revision: https://reviews.llvm.org/D86457
2020-10-21 09:49:03 +01:00
Vitaly Buka 60913ebcbc [NFC][LSAN] Use InitializeCommonFlags in LSAN 2020-10-21 01:41:52 -07:00
Kostya Kortchinsky be8e4de724 [GWP-ASan] Rework utilities (NFC)
Few changes wrt utilities:
- split `Check` into a platform agnostic condition test and a platform
  specific termination, for which we introduce the function `die`.
- add a platform agnostic `utilities.cpp` that gets the allocation
  alignment functions original in the platform specific file, as they
  are reusable by all platforms.

Differential Revision: https://reviews.llvm.org/D89811
2020-10-20 16:04:21 -07:00
Vitaly Buka 343410d1cc [LSAN][NFC] Reformat test 2020-10-20 14:16:27 -07:00
Evgenii Stepanov b3ccfa1e0c [hwasan] Increase max allocation size to 1Tb.
2Gb is unreasonably low on devices with 12Gb RAM and more.

Differential Revision: https://reviews.llvm.org/D89750
2020-10-20 14:01:48 -07:00
Martin Liska ad2be02a83 ASAN: Support detect_invalid_pointer_pairs=1 with detect_stack_use_after_return=1
Do not crash when AsanThread::GetStackVariableShadowStart does not find
a variable for a pointer on a shadow stack.

Differential Revision: https://reviews.llvm.org/D89552
2020-10-20 19:28:12 +02:00
Jianzhou Zhao 91dc545bf2 Set Huge Page mode on shadow regions based on no_huge_pages_for_shadow
It turned out that at dynamic shared library mode, the memory access
pattern can increase memory footprint significantly on OS when transparent
hugepages (THP) are enabled. This could cause >70x memory overhead than
running a static linked binary. For example, a static binary with RSS
overhead 300M can use > 23G RSS if it is built dynamically.
/proc/../smaps shows in 6204552 kB RSS 6141952 kB relates to
AnonHugePages.

Also such a high RSS happens in some rate: around 25% runs may use > 23G RSS, the
rest uses in between 6-23G. I guess this may relate to how user memory
is allocated and distributted across huge pages.

THP is a trade-off between time and space. We have a flag
no_huge_pages_for_shadow for sanitizer. It is true by default but DFSan
did not follow this. Depending on if a target is built statically or
dynamically, maybe Clang can set no_huge_pages_for_shadow accordingly
after this change. But it still seems fine to follow the default setting of
no_huge_pages_for_shadow. If time is an issue, and users are fine with
high RSS, this flag can be set to false selectively.
2020-10-20 16:50:59 +00:00
Jianzhou Zhao cc07fbe37d Release pages to OS when setting 0 label
This is a follow up patch of https://reviews.llvm.org/D88755.

When set 0 label for an address range, we can release pages within the
corresponding shadow address range to OS, and set only addresses outside
the pages to be 0.

Reviewed-by: morehouse, eugenis
Differential Revision: https://reviews.llvm.org/D89199
2020-10-20 16:22:11 +00:00
Luís Marques fc3f9dfad3 [compiler-rt][builtins] Add tests for atomic builtins support functions
Adds some simple sanity checks that the support functions for the atomic
builtins do the right thing. This doesn't test concurrency and memory model
issues.

Differential Revision: https://reviews.llvm.org/D86278
2020-10-20 12:08:57 +01:00
David Carlier 53065c543f [Sanitizers] Remove OpenBSD support (new attempt)
- Fixing VS compiler and other cases settings this time.

Reviewers: dmajor, hans

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D89759
2020-10-20 11:16:09 +01:00
Vitaly Buka f97ca48b1c [sanitizer] Fix compilation on older systems
Fixes https://bugs.llvm.org/show_bug.cgi?id=47896
2020-10-19 22:45:51 -07:00
Kostya Kortchinsky ae9d040028 [GWP-ASan] Cleanup (NFC)
Cleaning up some of the GWP-ASan code base:
- lots of headers didn't have the correct file name
- adding `#ifdef` guard to `utilities.h`
- correcting an `#ifdef` guard based on actual file name
- removing an extra `;`
- clang-format'ing the code (`-style=llvm`)

Differential Revision: https://reviews.llvm.org/D89721
2020-10-19 18:13:11 -07:00
Evgenii Stepanov 7ecd60bb70 Revert "[Sanitizers] Remove OpenBSD support" + 1
Revert "Fix compiler-rt build on Windows after D89640"

This reverts commit a7acee89d6.
This reverts commit d09b08919c.

Reason: breaks Linux / x86_64 build.
2020-10-19 16:11:21 -07:00
Luís Marques 7ddd354d47 [RISCV][ASAN] Fix TLS offsets
Fix a RISC-V ASan test failure: `TestCases/Linux/static_tls.cpp`.

Differential Revision: https://reviews.llvm.org/D89244
2020-10-19 13:41:50 +01:00
Hans Wennborg a7acee89d6 Fix compiler-rt build on Windows after D89640
It moved the cmake code from the else-branch to the if-branch
but forgot to flip the condition.
2020-10-19 14:39:37 +02:00
Dávid Bolvanský 2554619adb [ASAN] Restore and adjust tests
There are optimized out with -fno-builtin
2020-10-18 17:28:05 +02:00
David Carlier d09b08919c [Sanitizers] Remove OpenBSD support
- Removing unused and unusable code.

Reviewers: krytarowski

Reviewed By: krytarowski

Differential Revision: https://reviews.llvm.org/D89640
2020-10-18 14:57:07 +01:00
Dávid Bolvanský 65e94cc946 [InferAttrs] Add argmemonly attribute to string libcalls
Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D89602
2020-10-18 01:33:26 +02:00
Luís Marques b7ff218f1c [RISCV][ASAN] Fix passing XFAIL tests
These tests pass for RV64 Linux, but they are marked as XFAIL. This patch
fixes that.

Differential Revision: https://reviews.llvm.org/D89299
2020-10-17 16:55:11 +01:00
Richard Smith efd02c1548 Fix accidental use of VLAs that causes these tests to fail after Clang
commit 552c6c2328.
2020-10-16 15:14:28 -07:00
Teresa Johnson 3ed77ecd0a [MemProf] Don't build memprof if sanitizer not being built
This should fix a couple of debian bot failures:
http://lab.llvm.org:8011/#builders/14/builds/380
http://lab.llvm.org:8011/#builders/109/builds/533

They disable building of the sanitizer, which memprof relies on. So
disable building of memprof in that case.
2020-10-16 10:47:37 -07:00
Teresa Johnson 3d4bba302d [MemProf] Memory profiling runtime support
See RFC for background:
http://lists.llvm.org/pipermail/llvm-dev/2020-June/142744.html

Follow on companion to the clang/llvm instrumentation support in D85948
and committed earlier.

This patch adds the compiler-rt runtime support for the memory
profiling.

Note that much of this support was cloned from asan (and then greatly
simplified and renamed). For example the interactions with the
sanitizer_common allocators, error handling, interception, etc.

The bulk of the memory profiling specific code can be found in the
MemInfoBlock, MemInfoBlockCache, and related classes defined and used
in memprof_allocator.cpp.

For now, the memory profile is dumped to text (stderr by default, but
honors the sanitizer_common log_path flag). It is dumped in either a
default verbose format, or an optional terse format.

This patch also adds a set of tests for the core functionality.

Differential Revision: https://reviews.llvm.org/D87120
2020-10-16 09:47:02 -07:00
Hiroshi Yamauchi 1ebee7adf8 [PGO] Remove the old memop value profiling buckets.
Following up D81682 and D83903, remove the code for the old value profiling
buckets, which have been replaced with the new, extended buckets and disabled by
default.

Also syncing InstrProfData.inc between compiler-rt and llvm.

Differential Revision: https://reviews.llvm.org/D88838
2020-10-15 10:09:49 -07:00
Petr Hosek 220de1f32a Revert "[CMake] Avoid accidental C++ standard library dependency in sanitizers"
This reverts commit 287c318690 which broke
sanitizer tests that use C++ standard library.
2020-10-14 18:44:09 -07:00
Petr Hosek 287c318690 [CMake] Avoid accidental C++ standard library dependency in sanitizers
While sanitizers don't use C++ standard library, we could still end
up accidentally including or linking it just by the virtue of using
the C++ compiler. Pass -nostdinc++ and -nostdlib++ to avoid these
accidental dependencies.

Differential Revision: https://reviews.llvm.org/D88922
2020-10-14 18:26:56 -07:00
Calixte Denizet 5502bd66bb [profile] Remove useless msync when dumping gcda files
Summary:
According the mmap man page (https://man7.org/linux/man-pages/man2/mmap.2.html) is only required to precisely control updates, so we can safely remove it.
Since gcda files are dumped just before to call exec** functions, dump need to be fast.
On my computer, Firefox built with --coverage needs ~1min40 to display something and in removing msync it needs ~8s.

Reviewers: void

Subscribers: #sanitizers, marco-c, sylvestre.ledru

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D81060
2020-10-14 17:07:20 +02:00
Vitaly Buka 20e78eb304 [sanitizer][NFC] Fix few cpplint warnings 2020-10-13 20:39:37 -07:00
David Tenty 19856c5982 [NFC][compiler-rt] Add ppc32 to the list of arch
This should have been done when it was added to the symmetrical list in
the builtins config-ix in D87383, but it was overlooked.
2020-10-13 23:28:47 -04:00
Kamil Rytarowski d4b0404732 [compiler-rt] [lldb] Mark syscall_acquire and syscall_release as USED
Fixes build warnings on NetBSD.
2020-10-14 03:57:15 +02:00
Vitaly Buka bcdd4359e1 [sanitizer] Escape quotes in tests to fix android bot after D88361 2020-10-13 18:09:38 -07:00
Hafiz Abid Qadeer eddbadfe13 [compiler-rt] Allow override of 'emulator' value from lit_config.
Currently the 'emulator' value is fixed at build time. This patch allows changing the emulator
at testing time and enables us to run the tests on different board or simulators without needing
to run CMake again to change the value of emulator.

With this patch in place, the value of 'emulator' can be changed at test time from the command
line like this:

$ llvm-lit --param=emulator="..."

Reviewed By: delcypher

Differential Revision: https://reviews.llvm.org/D84708
2020-10-13 17:12:34 +01:00
Vitaly Buka 25a8881b72 Revert " Enable LSAN for Android"
Breaks android build.
asan_malloc_dispatch_k needs memalign interceptor disabled in this patch.

This reverts commit a2291a58bf.
2020-10-13 03:14:09 -07:00