Commit Graph

14937 Commits

Author SHA1 Message Date
Juneyoung Lee 7584ef766a [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default
Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions.
I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default.

Test updates are made as a separate patch: D108453

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D105169
2021-11-06 15:36:42 +09:00
Vitaly Buka 3c7960cba1 [libFuzzer] Disable Msan on InternalStrnlen
It's called from ATTRIBUTE_NO_SANITIZE_MEMORY code.
It worked as expected if inlined and complained otherwise.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D113323
2021-11-05 15:24:09 -07:00
Martin Liska 78d3e0a4f1 sanitizer: Fix -Wpedantic GCC warning
Fixes:
sanitizer_stacktrace.h:212:5: warning: ISO C++ forbids braced-groups within expressions [-Wpedantic]

Differential Revision: https://reviews.llvm.org/D113292
2021-11-05 18:05:23 +01:00
Martin Liska 13a442ca49 Enable -Wformat-pedantic and fix fallout.
Differential Revision: https://reviews.llvm.org/D113172
2021-11-05 13:12:35 +01:00
Vitaly Buka bbc213afd1 [asan] compiler-rt version of D113143 2021-11-04 23:51:16 -07:00
Martin Liska 629b40dafa Fix -Wformat warnings reported by GCC.
Differential Revision: https://reviews.llvm.org/D113099
2021-11-04 08:51:43 +01:00
Julian Lettner f643afa25f Revert "Mark tsan cxa_guard_acquire test as unsupported on Darwin"
This reverts commit 593275c93c.

This test now passes again.
2021-11-03 19:07:56 -07:00
Lang Hames 870fc844d1 [ORC-RT] Add SPS serialization for span<const char> / SPSSequence<char>. 2021-11-03 13:43:49 -07:00
Vitaly Buka 91f0a6ad4e [asan] Disable test on Android Arm 32bit
Caused by D111703.
2021-11-03 13:12:56 -07:00
Vitaly Buka e28c64ecb1 [sanitizer] Disable new test on Android
Test added with D113055
2021-11-03 11:57:04 -07:00
Tamir Duberstein f639882be8 [sanitizer] Allow getsockname with NULL addrlen
This is already permitted in getpeername, and returns EFAULT
on Linux (does not crash the program).

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

Differential Revision: https://reviews.llvm.org/D113055
2021-11-03 10:23:01 -07:00
Tamir Duberstein 33d9b7b4b2 [sanitizer] Mark before deref in PosixSpawnImpl
Read each pointer in the argv and envp arrays before dereferencing
it; this correctly marks an error when these pointers point into
memory that has been freed.

Differential Revision: https://reviews.llvm.org/D113046
2021-11-03 10:18:06 -07:00
Rich Lowe de6f7252da [sanitizer_common] Fix readlink error handling in sanitizer_procmaps_solaris.cpp
As pointed out in Bug 52371, the Solaris version of
`MemoryMappingLayout::Next` completely failed to handle `readlink` errors
or properly NUL-terminate the result.

This patch fixes this.  Originally provided in the PR with slight
formatting changes.

Tested on `amd64-pc-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D112998
2021-11-02 22:06:17 +01:00
Matt Morehouse 498a4c2fd7 [HWASan] Print short tags in tag mismatch description.
I recently spent some extra time debugging a false positive because I
didn't realize the "real" tag was in the short granule.  Adding the
short tag here makes it more obvious that we could be dealing with a
short granule.

Reviewed By: hctim, eugenis

Differential Revision: https://reviews.llvm.org/D112949
2021-11-02 08:00:33 -07:00
Matt Morehouse 8c60e0b632 [HWASan] Print short tags in __hwasan_print_shadow.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D112959
2021-11-02 07:59:25 -07:00
David Carlier 56513e3e42 [sanitizers] remove extra comma for sha2 interceptors 2021-11-02 10:35:44 +00:00
Vitaly Buka 08e0b9235b Revert "[NFC][sanitizer] Disable a test with large stderr output"
This reverts commit 6eb38e5171.

The test was not the reason of sanitizer-x86_64-linux-android failures.
2021-11-02 01:25:46 -07:00
Vitaly Buka 869989dd71 [sanitizer] Restore trivial posix_spawn init in test
It's still needed on Darwin.
2021-11-01 23:58:18 -07:00
Vitaly Buka 57d34cb223 Revert "[sanitizer] Fix compilation of the test"
Revert "[sanitizer] Fix PosixSpawnImpl which fails exitcode test"

This reverts commit 8cabd8f0d2 and part of 9213202abd.

It is not enough for Android.
2021-11-01 22:25:26 -07:00
Vitaly Buka 8cabd8f0d2 [sanitizer] Fix compilation of the test 2021-11-01 21:50:50 -07:00
Vitaly Buka 15361a98aa [sanitizer] Add test for 9213202abd 2021-11-01 21:14:11 -07:00
Vitaly Buka 9213202abd [sanitizer] Fix PosixSpawnImpl which fails exitcode test 2021-11-01 21:03:02 -07:00
Vitaly Buka 0d59efbba4 [sanitizer] Fix test include on Darwin 2021-11-01 16:49:50 -07:00
Matt Morehouse 4d8b0aa5c0 [HWASan] Apply TagMaskByte to every global tag.
Previously we only applied it to the first one, which could allow
subsequent global tags to exceed the valid number of bits.

Reviewed By: hctim

Differential Revision: https://reviews.llvm.org/D112853
2021-11-01 06:31:44 -07:00
Matt Morehouse b298d6d162 [sanitizer] Disable posix_spawn.c test on Android. 2021-11-01 06:22:48 -07:00
David Carlier b4fb42300e [sanitizer] msan build fix on non linux platforms 2021-11-01 07:18:43 +00:00
Vitaly Buka 948b91a08e [NFC][sanitizer] Atomix relaxed in TwoLevelMap
This is NOOP in x86_64.
On arch64 it avoids Data Memory Barrier with visible improvements on micro benchmarks.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D112391
2021-10-31 12:18:03 -07:00
Vitaly Buka e1240745ef [sanitizer] Add posix_spawn interceptor
To make pid initialized for Msan.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D112784
2021-10-31 12:10:54 -07:00
Lang Hames 81a6eabf71 [ORC-RT] Add missing file that was left out of ff846fcb64. 2021-10-31 10:53:17 -07:00
Lang Hames ff846fcb64 [ORC][ORC-RT] Switch MachO EH/TLV registration from EPC-calls to alloc actions.
MachOPlatform used to make an EPC-call (registerObjectSections) to register the
eh-frame and thread-data sections for each linked object with the ORC runtime.

Now that JITLinkMemoryManager supports allocation actions we can use these
instead of an EPC call. This saves us one EPC-call per object linked, and
manages registration/deregistration in the executor, rather than the controller
process. In the future we may use this to allow JIT'd code in the executor to
outlive the controller object while still being able to be cleanly destroyed.

Since the code for allocation actions must be available when the actions are
run, and since the eh-frame registration code lives in the ORC runtime itself,
this change required that MachO eh-frame support be split out of
macho_platform.cpp and into its own macho_ehframe_registration.cpp file that has
no other dependencies. During bootstrap we start by forcing emission of
macho_ehframe_registration.cpp so that eh-frame registration is guaranteed to be
available for the rest of the bootstrap process. Then we load the rest of the
MachO-platform runtime support, erroring out if there is any attempt to use
TLVs. Once the bootstrap process is complete all subsequent code can use all
features.
2021-10-31 10:27:40 -07:00
Dmitry Vyukov d31b2dc235 tsan: add debugging code for ptrace test failures
Debugging of crashes on powerpc after commit:
c80604f7a3 ("tsan: remove real func check from interceptors")
Somehow replacing if with DCHECK leads to strange failures in:
SanitizerCommon-tsan-powerpc64le-Linux :: Linux/ptrace.cpp
https://lab.llvm.org/buildbot/#/builders/105
https://lab.llvm.org/buildbot/#/builders/121
https://lab.llvm.org/buildbot/#/builders/57

The hypothesis is that something writes out-of-bounds
into pt_regs on stack and that corrupts internal tsan state.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112703
2021-10-29 17:37:02 +02:00
Dmitry Vyukov 014c6b0736 sanitizer_common: fix ParseUnixMemoryProfile test linking on Mac
The ParseUnixMemoryProfile function is defined only for a subset
of platforms. Define the test for the same set of platforms.

Also disable the test for 32-bit platforms b/c the pointer
values used in the test are 64-bit and don't fit into 32-bit uptr.

Reported-by: Jan Svoboda (jansvoboda11)

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112815
2021-10-29 16:26:24 +02:00
Rainer Orth 2f353c040f [sanitizer_common] Fix Posix/mmap_write_exec.cpp on 32-bit Solaris
The new `Posix/mmap_write_exec.cpp` test FAILs on 32-bit Solaris/x86.  This
happens because only `mmap` is intercepted, but not `mmap64` which is used
for largefile support.

Fixed by also intercepting `mmap64`.

Tested on `amd64-pc-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D112810
2021-10-29 14:29:41 +02:00
Dmitry Vyukov af0a8b8317 sanitizer_common: bump default file max size to 256MB
I am hitting some cases where /proc/self/maps does not fit into 64MB.
256MB is lots of memory, but it's not radically more than the current 64MB.
Ideally we should read/parse these huge files incrementally,
but that's lots of work for a debugging/introspection interface.
So for now just bump the limit.

Depends on D112793.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112794
2021-10-29 14:03:26 +02:00
Dmitry Vyukov e8861fa6c3 sanitizer_common: fix crashes in parsing of memory profiles
ParseUnixMemoryProfile assumes well-formed input with \n at the end, etc.
It can over-read the input and crash on basically every line
in the case of malformed input.
ReadFileToBuffer has cap the max file size (64MB) and returns
truncated contents if the file is larger. Thus even if kernel behaves,
ParseUnixMemoryProfile crashes on too large /proc/self/smaps.
Fix input over-reading in ParseUnixMemoryProfile.

Depends on D112792.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112793
2021-10-29 14:03:12 +02:00
Dmitry Vyukov 4acad5df33 sanitizer_common: add memory profile parsing test
Depends on D112790.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112792
2021-10-29 14:02:50 +02:00
Dmitry Vyukov ae833dbb81 sanitizer_common: remove unnecessary GetMemoryProfile arg
stats_size argument is unnecessary in GetMemoryProfile and in the callback.
It just clutters code. The callback knowns how many stats to expect.

Depends on D112789.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112790
2021-10-29 13:44:34 +02:00
Dmitry Vyukov d4602f759a sanitizer_common: make parsing of smaps testable (NFC)
Move parsing of /proc/self/smaps into a separate function
so that it can be tested.

Depends on D112788.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112789
2021-10-29 13:44:28 +02:00
Dmitry Vyukov a871c34e8d sanitizer_common: fix up onprint.cpp test more
D112630 ("sanitizer_common: fix up onprint.cpp test")
added O_CREAT, but we also need O_TRUNC b/c the file
may not exist, or may exist as well.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112788
2021-10-29 13:44:04 +02:00
Lang Hames dc8e5e1dc0 [ORC-RT] Add a WrapperFunctionCall utility.
WrapperFunctionCall represents a call to a wrapper function as a pair of a
target function (as an ExecutorAddr), and an argument buffer range (as an
ExecutorAddrRange). WrapperFunctionCall instances can be serialized via
SPS to send to remote machines (only the argument buffer address range is
copied, not any buffer content).

This utility will simplify the implementation of JITLinkMemoryManager
allocation actions in the ORC runtime.
2021-10-28 17:07:28 -07:00
Vitaly Buka 6eb38e5171 [NFC][sanitizer] Disable a test with large stderr output 2021-10-28 15:15:20 -07:00
David CARLIER c9174f63b6 [compiler-rt] fix asan buildbot failure on unit test for darwin 2021-10-28 18:48:54 +01:00
David CARLIER bb168f3207 [compiler-rt] update detect_write_exec option for apple devices.
Reviewed By: yln, vitalybuka

Differential Revision: https://reviews.llvm.org/D111390
2021-10-28 17:08:23 +01:00
Dmitry Vyukov d736002e90 tsan: move memory access functions to a separate file
tsan_rtl.cpp is huge and does lots of things.
Move everything related to memory access and tracing
to a separate tsan_rtl_access.cpp file.
No functional changes, only code movement.

Reviewed By: vitalybuka, melver

Differential Revision: https://reviews.llvm.org/D112625
2021-10-28 13:31:10 +02:00
Florian Mayer dd943ebc6d [hwasan] print exact mismatch offset for short granules.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D104463
2021-10-28 03:31:11 +01:00
Kai Luo 6ea2431d3f [clang][compiler-rt][atomics] Add `__c11_atomic_fetch_nand` builtin and support `__atomic_fetch_nand` libcall
Add `__c11_atomic_fetch_nand` builtin to language extensions and support `__atomic_fetch_nand` libcall in compiler-rt.

Reviewed By: theraven

Differential Revision: https://reviews.llvm.org/D112400
2021-10-28 02:18:43 +00:00
Petr Hosek 22acda48ff [CMake] Cache the compiler-rt library search results
There's a lot of duplicated calls to find various compiler-rt libraries
from build of runtime libraries like libunwind, libc++, libc++abi and
compiler-rt. The compiler-rt helper module already implemented caching
for results avoid repeated Clang invocations.

This change moves the compiler-rt implementation into a shared location
and reuses it from other runtimes to reduce duplication and speed up
the build.

Differential Revision: https://reviews.llvm.org/D88458
2021-10-27 17:53:03 -07:00
Ben Langmuir beb3d48262 [ORC-RT] Fix objc selector corruption
We were writing a pointer to a selector string into the contents of a
string instead of overwriting the pointer to the string, leading to
corruption. This was causing non-deterministic failures of the
'trivial-objc-methods' test case.

Differential Revision: https://reviews.llvm.org/D112671
2021-10-27 16:02:52 -07:00
Ben Langmuir 3d13ee2891 [ORC][ORC-RT] Enable the MachO platform for arm64
Enables the arm64 MachO platform, adds basic tests, and implements the
missing TLV relocations and runtime wrapper function. The TLV
relocations are just handled as GOT accesses.

rdar://84671534

Differential Revision: https://reviews.llvm.org/D112656
2021-10-27 13:36:03 -07:00
Dmitry Vyukov 910aeed77e sanitizer_common: fix up onprint.cpp test
Commit D112602 ("sanitizer_common: tighten on_print hook test")
changed fopen to open in this test. fopen created the file
if if does not exist, but open does not. This was unnoticed
during local testing because lit is not hermetic and reuses
files from previous runs, but it started failing on bots.
Fix the open call.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112630
2021-10-27 18:17:15 +02:00