Commit Graph

14150 Commits

Author SHA1 Message Date
George Balatsouras 070556237e [libfuzzer] Disable failing DFSan-related tests
These have been broken by https://reviews.llvm.org/D104494.
However, `lib/fuzzer/dataflow/` is unused (?) so addressing this is not a priority.

Added TODOs to re-enable them in the future.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D104568
2021-06-19 01:09:19 +00:00
Fangrui Song 5540470f64 [profile][test] Delete profraw directory so that tests are immune to format version upgrade 2021-06-18 16:44:03 -07:00
Leonard Chan f7999e73ca [NFC][compiler-rt][hwasan] Move hwasanThreadList().CreateCurrentThread() into InitThreads
Once D104553 lands, CreateCurrentThread will be able to accept optional
parameters for initializing the hwasan thread object. On fuchsia, we can get
stack info in the platform-specific InitThreads and pass it through
CreateCurrentThread. On linux, this is a no-op.

Differential Revision: https://reviews.llvm.org/D104561
2021-06-18 13:40:55 -07:00
Andrew Browne 14407332de [DFSan] Cleanup code for platforms other than Linux x86_64.
These other platforms are unsupported and untested.
They could be re-added later based on MSan code.

Reviewed By: gbalats, stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D104481
2021-06-18 11:21:46 -07:00
Florian Mayer e0b68f7149 [hwasan] Clarify report for allocation-tail-overwritten.
Explain what the given stack trace means before showing it, rather than
only in the paragraph at the end.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D104523
2021-06-18 18:52:41 +01:00
Leonard Chan 88d93923e6 [compiler-rt][hwasan] Move Thread::Init into hwasan_linux.cpp
This allows for other implementations to define their own version of `Thread::Init`.
This will be the case for Fuchsia where much of the thread initialization can be
broken up between different thread hooks (`__sanitizer_before_thread_create_hook`,
`__sanitizer_thread_create_hook`, `__sanitizer_thread_start_hook`). Namely, setting
up the heap ring buffer and stack info and can be setup before thread creation.
The stack ring buffer can also be setup before thread creation, but storing it into
`__hwasan_tls` can only be done on the thread start hook since it's only then we
can access `__hwasan_tls` for that thread correctly.

Differential Revision: https://reviews.llvm.org/D104248
2021-06-18 10:32:41 -07:00
Matt Morehouse 493565a4aa [HWASan] Run LAM tests with -hwasan-generate-tags-with-calls.
The default callback instrumentation in x86 LAM mode uses ASLR bits
to randomly choose a tag, and thus has a 1/64 chance of choosing a
stack tag of 0, causing stack tests to fail intermittently.  By using
__hwasan_generate_tag to pick tags, we guarantee non-zero tags and
eliminate the test flakiness.

aarch64 doesn't seem to have this problem using thread-local addresses
to pick tags, so perhaps we can remove this workaround once we implement
a similar mechanism for LAM.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D104470
2021-06-18 08:10:51 -07:00
George Balatsouras c6b5a25eeb [dfsan] Replace dfs$ prefix with .dfsan suffix
The current naming scheme adds the `dfs$` prefix to all
DFSan-instrumented functions.  This breaks mangling and prevents stack
trace printers and other tools from automatically demangling function
names.

This new naming scheme is mangling-compatible, with the `.dfsan`
suffix being a vendor-specific suffix:
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-structure

With this fix, demangling utils would work out-of-the-box.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D104494
2021-06-17 22:42:47 -07:00
Andrew Browne 39295e92f7 Revert "[DFSan] Cleanup code for platforms other than Linux x86_64."
This reverts commit 8441b993bd.

Buildbot failures.
2021-06-17 14:19:18 -07:00
Andrew Browne 8441b993bd [DFSan] Cleanup code for platforms other than Linux x86_64.
These other platforms are unsupported and untested.
They could be re-added later based on MSan code.

Reviewed By: gbalats, stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D104481
2021-06-17 14:08:40 -07:00
Yabin Cui ac35ed5d34 [compiler-rt][hwasan]: undefine new/delete operators with alignment on Android.
This is to fix build on Android. And we don't want to intercept more new/delete operators on Android.

Differential Revision: https://reviews.llvm.org/D104313
2021-06-17 09:28:12 -07:00
Kevin Athey 249d9b051f Revert "Remove obsolete call to AsyncSignalSafeLazyInitiFakeStack."
This reverts commit 07481b3796.

Differential Revision: https://reviews.llvm.org/D104469
2021-06-17 09:27:02 -07:00
Florian Mayer ccc0f777f6 [hwasan] Improve report for addresses within regions.
Before: ADDR is located -320 bytes to the right of 1072-byte region
After: ADDR is located 752 bytes inside 1072-byte region

Reviewed By: eugenis, walli99

Differential Revision: https://reviews.llvm.org/D104412
2021-06-17 12:01:30 +01:00
Florian Mayer 18070723ef [hwasan] Do not use short granule tags as poison tags.
Short granule tags as poison cause a UaF to read the referenced
memory to retrieve the tag, and means we do not detect the UaF
if the last granule's tag is still around.

This only increases the change of not catching a UaF from
0.39 % (1 / 256) to 0.42 % (1 / (256 - 17)).

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D104304
2021-06-17 11:59:37 +01:00
Florian Mayer b18f30fb2d [NFC] test commit, fix namespace ending comment. 2021-06-17 11:18:36 +01:00
Kristof Beyls 6f0e74cd58 Avoid unnecessary AArch64 DSB in __clear_cache in some situations.
The dsb after instruction cache invalidation only needs to be executed
if any instruction cache invalidation did happen.
Without this change, if the CTR_EL0.DIC bit indicates that instruction
cache invalidation is not needed, __clear_cache would execute two dsb
instructions in a row; with the second one being unnecessary.

Differential Revision: https://reviews.llvm.org/D104371
2021-06-17 07:45:06 +01:00
Kevin Athey 07481b3796 Remove obsolete call to AsyncSignalSafeLazyInitiFakeStack.
Code was originally added for Myriad D46626 which was removed
with D104279.

related to: https://github.com/google/sanitizers/issues/1394

Reviewed By: vitalybuka, morehouse

Differential Revision: https://reviews.llvm.org/D104419
2021-06-16 18:26:33 -07:00
Kostya Kortchinsky 8b062b6160 [scudo] Ensure proper allocator alignment in TSD test
The `MockAllocator` used in `ScudoTSDTest` wasn't allocated
properly aligned, which resulted in the `TSDs` of the shared
registry not being aligned either. This lead to some failures
like: https://reviews.llvm.org/D103119#2822008

This changes how the `MockAllocator` is allocated, same as
Vitaly did in the combined tests, properly aligning it, which
results in the `TSDs` being aligned as well.

Add a `DCHECK` in the shared registry to check that it is.

Differential Revision: https://reviews.llvm.org/D104402
2021-06-16 14:21:58 -07:00
Kevin Athey c4992bf593 [NFC][sanitizer] Remove calls to __asan_get_current_fake_stack
Unnecessary with -fsanitize-address-use-after-return=never.

for issue: https://github.com/google/sanitizers/issues/1394

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D104154
2021-06-15 18:52:22 -07:00
Vitaly Buka 6478ef61b1 [asan] Remove Asan, Ubsan support of RTEMS and Myriad
Differential Revision: https://reviews.llvm.org/D104279
2021-06-15 12:59:05 -07:00
Leonard Chan fc006b3e5d [compiler-rt][hwasan] Add GetShadowOffset function
Similar to SHADOW_OFFSET on asan, we can use this for hwasan so platforms that
use a constant value for the start of shadow memory can just use the constant
rather than access a global.

Differential Revision: https://reviews.llvm.org/D104275
2021-06-15 10:46:11 -07:00
Alex Richardson 13f0b85212 Fix Windows builders after 244601f472
Apparently __builtin_abort() is not supported when targetting Windows.
This should fix the following builder errors:
clang_rt.builtins-x86_64.lib(int_util.c.obj) : error LNK2019: unresolved
external symbol __builtin_abort referenced in function __compilerrt_abort_impl
2021-06-15 09:47:29 +01:00
Alex Richardson 244601f472 [builtins] Allow compiling the builtins without libc headers
When compiled with -ffreestanding, we should not assume that headers
declaring functions such as abort() are available. While the compiler may
still emit calls to those functions [1], we should not require the headers
to build compiler-rt since that can result in a cyclic dependency graph:
The compiler-rt functions might be required to build libc.so, but the libc
headers such as stdlib.h might only be available once libc has been built.

[1] From https://gcc.gnu.org/onlinedocs/gcc/Standards.html:
GCC requires the freestanding environment provide memcpy, memmove,
memset and memcmp. Finally, if __builtin_trap is used, and the target
does not implement the trap pattern, then GCC emits a call to abort.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D103876
2021-06-15 09:08:59 +01:00
Lang Hames 68c161090e [ORC-RT] Fix void function handling in the WrapperFunction utility.
Handlers returning void previously caused compile errors. Fix that by
substituting SPSEmpty placeholder values.
2021-06-15 15:49:40 +10:00
Vitaly Buka 51ed1c6ccc [NFC][hwasan] Fix "implicitly declaring library function" 2021-06-14 21:58:59 -07:00
Vitaly Buka b8919fb0ea [NFC][sanitizer] clang-format some code 2021-06-14 18:05:22 -07:00
Leonard Chan 312011899a [compiler-rt][hwasan] Add newline between record_addr lines on frame record dumps
If SymbolizePC failes, it's possible for the newline to not be emitted.

Differential Revision: https://reviews.llvm.org/D103845
2021-06-14 17:13:13 -07:00
Matt Morehouse b87894a1d2 [HWASan] Enable globals support for LAM.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D104265
2021-06-14 14:20:44 -07:00
George Balatsouras 98504959a6 [dfsan] Add stack-trace printing functions to dfsan interface
Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D104165
2021-06-14 14:09:00 -07:00
Lang Hames ba9e28064b [ORC-RT] Fix an error check. 2021-06-14 11:59:20 +10:00
Khem Raj 60e32a1f34 [fuzzer] Fix build on musl
cstddef is needed for size_t definition.
(Multiple headers can provide size_t but none of them exists.)

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D96213
2021-06-13 12:32:07 -07:00
Lang Hames a7c3105adb [ORC-RT] Remove unused header in unit test. 2021-06-13 20:45:20 +10:00
Lang Hames e405db075b [ORC-RT] Fix a comment. 2021-06-13 20:26:51 +10:00
Lang Hames 49f4a58d53 [ORC-RT] Split Simple-Packed-Serialization code into its own header.
This will simplify integration of this code into LLVM -- The
Simple-Packed-Serialization code can be copied near-verbatim, but
WrapperFunctionResult will require more adaptation.
2021-06-13 10:17:13 +10:00
Kai Luo 6393164cf2 [AIX][compiler-rt] Fix cmake build of libatomic for cmake-3.16+
cmake-3.16+ for AIX changes the default behavior of building a `SHARED` library which breaks AIX's build of libatomic, i.e., cmake-3.16+ builds `SHARED` as an archive of dynamic libraries. To fix it, we have to build `libatomic.so.1` as `MODULE` which keeps `libatomic.so.1` as an normal dynamic library.

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D103786
2021-06-12 00:12:29 +00:00
Reid Kleckner b9af157fd1 [ASan/Win] Hide index from compiler to avoid new clang warning 2021-06-11 16:12:28 -07:00
Kevin Athey 60084d4900 [sanitizer] Replace -mllvm -asan-use-after-return in compile-rt tests with -fsanitize-address-use-after-return (NFC)
for issue: https://github.com/google/sanitizers/issues/1394

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D104146
2021-06-11 15:13:22 -07:00
John Paul Adrian Glaubitz 27ef43d279 [compiler-rt] Add platform detection support for x32
Currently, the compiler-rt build system checks only whether __X86_64
is defined to determine whether the default compiler-rt target arch
is x86_64. Since x32 defines __X86_64 as well, we must also check that
the default pointer size is eight bytes and not four bytes to properly
detect a 64-bit x86_64 compiler-rt default target arch.

Reviewed By: hvdijk, vitalybuka

Differential Revision: https://reviews.llvm.org/D99988
2021-06-11 19:44:04 +01:00
Matt Morehouse 0867edfc64 [HWASan] Add basic stack tagging support for LAM.
Adds the basic instrumentation needed for stack tagging.

Currently does not support stack short granules or TLS stack histories,
since a different code path is followed for the callback instrumentation
we use.

We may simply wait to support these two features until we switch to
a custom calling convention.

Patch By: xiangzhangllvm, morehouse

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D102901
2021-06-11 08:21:17 -07:00
Stephen Hines 6455418d3d [compiler-rt] [builtins] [AArch64] Add missing AArch64 data synchronization barrier (dsb) to __clear_cache
https://developer.arm.com/documentation/den0024/a/Caches/Cache-maintenance
covers how to properly clear caches on AArch64, and the builtin
implementation was missing a `dsb ish` after clearing the icache for the
selected range.

Reviewed By: kristof.beyls

Differential Revision: https://reviews.llvm.org/D104094
2021-06-11 02:13:48 -07:00
Arthur Eubanks b73742bc8d [Profile] Remove redundant check
This is already checked outside the loop.

Followup to D104050.
2021-06-10 16:24:53 -07:00
Arthur Eubanks 189428c8fc [Profile] Handle invalid profile data
This mostly follows LLVM's InstrProfReader.cpp error handling.
Previously, attempting to merge corrupted profile data would result in
crashes. See https://crbug.com/1216811#c4.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D104050
2021-06-10 16:10:13 -07:00
Kevin Athey ddac31c593 Cleanup for final comment on https://reviews.llvm.org/D103304
Consolidate DEFINE_STACK_MALLOC to simplify.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D103965
2021-06-09 13:47:12 -07:00
David Spickett 11ad9e31eb [compiler-rt] Mark symbolize_stack_fp test unsupported on Arm Thumb
The new test `symbolize_stack_fp.cpp` added in
https://reviews.llvm.org/D102046 assumes that
we can fall back to the fast unwinder.

This is not the case for Thumb and the test is currently
failing on our v7 thumb bot:
https://lab.llvm.org/buildbot/#/builders/26/builds/2096

Skip the test if we're building for a Thumb target.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D103512
2021-06-09 08:50:21 +00:00
serge-sans-paille 4144827514 Prevent generation of dependency on _cxa_guard for static initialization
This fixes an issue introduced by https://reviews.llvm.org/D70662

Function-scope static initialization are guarded in C++, so we should probably
not use it because it introduces a dependency on __cxa_guard* symbols.
In the context of clang, libasan is linked statically, and it currently needs to
the odd situation where compiling C code with clang and asan requires -lstdc++

Differential Revision: https://reviews.llvm.org/D102475
2021-06-09 09:38:59 +02:00
David Blaikie 8051a48e65 ORTRT: Add tests for string_view equality and inequality operators 2021-06-08 17:53:59 -07:00
David Blaikie 4d9cc7c244 Add a couple of missing includes 2021-06-08 17:53:58 -07:00
David Blaikie cb09f2b10c Rename compiler-rt/lib/orc/endian.h to endianness.h to avoid conflict with system headers 2021-06-08 17:53:58 -07:00
Kevin Athey af8c59e06d Update and improve compiler-rt tests for -mllvm -asan_use_after_return=(never|[runtime]|always).
In addition:
  - optionally add global flag to capture compile intent for UAR:
    __asan_detect_use_after_return_always.
    The global is a SANITIZER_WEAK_ATTRIBUTE.

for issue: https://github.com/google/sanitizers/issues/1394

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D103304
2021-06-08 14:39:06 -07:00
Daniel Michael 2551053e8d [scudo] Add Scudo support for Trusty OS
trusty.cpp and trusty.h define Trusty implementations of map and other
platform-specific functions. In addition to adding Trusty configurations
in allocator_config.h and size_class_map.h, MapSizeIncrement and
PrimaryEnableRandomOffset are added as configurable options in
allocator_config.h.
Background on Trusty: https://source.android.com/security/trusty

Differential Revision: https://reviews.llvm.org/D103578
2021-06-08 14:02:10 -07:00