17105 Commits

Author SHA1 Message Date
Christopher Ferris
f95a4a2833 [scudo] Disable new/delete mismatch tests on Android.
Android does not do any checking of new/delete mismatches, so disable
this test when compiling for Android.

Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D152958
2023-06-14 16:07:50 -07:00
Vitaly Buka
ad1dd78793 [hwasan] Fixup mmap tagging regions
Reviewed By: thurston

Differential Revision: https://reviews.llvm.org/D152893
2023-06-14 15:32:12 -07:00
Vitaly Buka
aeb13a4459 [test][hwasan] Use perror and abort in test 2023-06-14 15:22:12 -07:00
Chia-hung Duan
163f8e1b01 Revert "[scudo] Temporariy dispatch region from RegionBeg"
This reverts commit 9d9a7732e14d7d4c0db7b46d6ebe588e8f43b951.

This was a workaround for some platform and it has been fixed in
bfa02523b2e7ed66368ea61866a474e55ef354a3

Differential Revision: https://reviews.llvm.org/D152964
2023-06-14 21:48:59 +00:00
Christopher Ferris
261d9e58d4 [scudo] Fix MallocIterateBoundary test on 32 bit Android.
On Android, the min alignment is 16 bytes. This test needs
the BlockDelta to match the min alignment, so set this value
differently for Android.

Update the comment in to explain these details.

Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D152884
2023-06-14 10:35:41 -07:00
Kirill Stoimenov
ceab8e3af7 [HWASAN] Fix bot test failure caused by D152763 by switching to
unaligned memory tagging
2023-06-14 14:55:31 +00:00
Vitaly Buka
c93ca4bcb8 [test][hwasan] Allow test for any platform with tagging 2023-06-14 01:16:54 -07:00
Vitaly Buka
4a69e0a0ad [test][hwasan] Rename constants in test 2023-06-14 01:00:35 -07:00
Kirill Stoimenov
fba9fd1afa [HWASAN] Implement munmap interceptor for HWASAN
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D152763
2023-06-14 05:36:12 +00:00
Fabio D'Urso
bd96d7b81f [scudo] Fix bound checks in MemMap and ReservedMemory methods
Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D152690
2023-06-14 03:55:54 +00:00
Wu, Yingcong
f154f10887 [sanitizer] Adjust code path of ChooseExternalSymbolizer for Windows
If `path` is null, `user_path` must also be null. With the current code path, the message of explicitly disabling symbolizer will never be reported. This patch adjusts the if-else structure to make that message can be reported.

Reviewed By: cchen15, MaskRay

Differential Revision: https://reviews.llvm.org/D148907
2023-06-13 14:51:47 -07:00
Vitaly Buka
08dd72de89 [test][asan] Remove XFAIL after D152604 2023-06-13 14:04:13 -07:00
Vitaly Buka
a37bd13744 [test][sanitizer] Fix test on windows 2023-06-13 12:34:26 -07:00
Vitaly Buka
5360258bce [test][sanitizer] Fix test on windows 2023-06-13 12:27:13 -07:00
Vitaly Buka
d8a3070c32 [test][sanitizer] Remove test missing include
We don't need to test with std::array anyway, as we don't use them in
sanitizers.
2023-06-13 09:48:52 -07:00
Vitaly Buka
78c6d2faa0 [NFC][sanitizer] Fix build on Windows
Macro was defined twice.
2023-06-13 09:06:02 -07:00
Vitaly Buka
c3c37a64f7 [test][sanitizer] Unsupport test on Android 2023-06-13 08:53:32 -07:00
Vitaly Buka
f35d0608fb [test][sanitizer] Add ArrayRef tests
Tests are subset of llvm/unittests/ADT/ArrayRefTest.cpp.
Added more members to match tests and
make class more useful.

Reviewed By: hctim

Differential Revision: https://reviews.llvm.org/D152760
2023-06-13 08:52:56 -07:00
Marco Elver
2c1ec06d45 [compiler-rt] Disable interceptor trampoline for SPARC
SPARC jmp requires a delay slot after, and without it will likely result
in a crash. For now, just disable interceptor trampolines on SPARC,
because the specific usecase for them (3 interceptors) does not exist on
SPARC (yet). We can revisit, and carefully implement the support for
SPARC when required.

Reported-by: ro
2023-06-13 13:52:00 +02:00
Christopher Ferris
6ee594be53 Revert "[scudo] Fix MallocIterateBoundary on 32 bit."
This reverts commit 5e691a1c9b0ad22689d4a434ddf4fed940e58dec.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D152779
2023-06-13 00:15:16 -07:00
Christopher Ferris
5e691a1c9b [scudo] Fix MallocIterateBoundary on 32 bit.
On Android, the 32 bit value of 8 for BlockDelta results in a
failure because a valid pointer can never be found.

Change the code to always use 16 which passes on both 32 bit
and 64 bit.

Verified that re-introducing the old bug causes the test to fail
on both 32 bit and 64 with the new BlockDelta value.

Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D152767
2023-06-12 21:51:41 -07:00
Christopher Ferris
c981f0b428 [scudo] Check support for pvalloc/valloc tests.
Some platforms do not support pvalloc/valloc so add checks so
that these tests are only run on the appropriate platforms.

Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D152756
2023-06-12 17:51:35 -07:00
Jin Xin Ng
fcf92cb800
[tsan] Check for nullptr on user_alloc_usable_size_fast
MBlock could be null (in the context of a call from RunFreeHooks)
if a static object was runtime initialized before tsan finished
initializing and that object later did a free().

While having the check isn't strictly required by
__sanitizer_get_allocated_size_fast's contract, a user's static object
would expect ptrs returned from malloc to be valid inputs.

Differential Revision: https://reviews.llvm.org/D152755
2023-06-13 00:00:31 +00:00
Vitaly Buka
679d9ea14d [NFC][sanitizer] Rename sanitizer_common_range -> sanitizer_range 2023-06-12 15:36:27 -07:00
Vitaly Buka
05181357ac [NFC][sanitizer] Move ArrayRef into own header 2023-06-12 15:24:35 -07:00
Kirill Stoimenov
686cb26edb [Sanitizer] Add munmap interceptor in sanitizer_common
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D152598
2023-06-12 21:33:43 +00:00
Fangrui Song
49f282b549 [sanitizer][test] Remove no-op REQUIRES:
Some patches around D109843 added `REQUIRES: freebsd` but they have no effects
due to sanitizer_common/TestCases/Linux/lit.local.cfg.py . I informed the author
but don't plan to move the tests.
2023-06-12 14:15:03 -07:00
Fangrui Song
314d181416 [CMake] Remove unused COMPILER_RT_HAS_MSSE3_FLAG and COMPILER_RT_HAS_WNON_VIRTUAL_DTOR_FLAG
D106948 and commit 9c31e12609e1935eb84a2497ac08a49e3139859a removed the last
user, respectively.
2023-06-12 11:38:29 -07:00
David Carlier
f5a8802fa6 sanitizers: enable pthread_getaffinity_np interception on freebsd.
Reviewers: mevler

Reviewed-By: mevler

Differential Revision: https://reviews.llvm.org/D152735
2023-06-12 19:25:43 +01:00
Vitaly Buka
e7e6088ee5 [test][HWASAN] Trim leading zeros from hex value
Match like [[#T2]] does not include leading zeroes.
2023-06-12 10:59:28 -07:00
Justin Cady
10e1d50809 [test][ASAN] Fix incorrect REQUIRES directive for scandir.c
The missing colon caused the test to run on unintended platforms.

Reviewed By: emaste

Differential Revision: https://reviews.llvm.org/D152711
2023-06-12 11:16:31 -04:00
David Carlier
203078bc14 sanitizers: intercept FreeBSD's cpuset_getaffinity call.
Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D152609
2023-06-12 09:05:31 +01:00
Vitaly Buka
c097c2548e [HWASAN] Fix verbose_threads
Looks like D104248 acidentally moved the code.
2023-06-09 20:56:23 -07:00
Vitaly Buka
5914ae340c [test][HWASAN] Add verbose_threads test 2023-06-09 20:33:39 -07:00
Marco Elver
cf6d7d5f6d Fix "[compiler-rt] Allow 3 simultaneous interceptors on Linux"
Build bots have been failing with:

	/usr/bin/ld: read-only segment has dynamic relocations

Remove support for interceptor trampoline on s390, and revert new
implementation of __tls_get_offset.
2023-06-09 14:34:01 +02:00
Marco Elver
406131b4c2 Fix "[compiler-rt] Introduce asm macros for interceptor trampolines"
Add missing ASM_INTERCEPTOR_TRAMPOLINE(setjmp).
2023-06-09 13:08:13 +02:00
Marco Elver
85d3873a45 Fix "[compiler-rt] Allow 3 simultaneous interceptors on Linux"
Fix inline asm trampoline type. Some architectures will complain:

<inline asm>:8:41: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '%<type>' or "<type>"
    8 | .type  __interceptor_trampoline_malloc, @function

Just use %function instead, which is what is also used in
sanitizer_asm.h
2023-06-09 12:14:45 +02:00
Marco Elver
37445e96d8 [compiler-rt] Allow 3 simultaneous interceptors on Linux
Rework Linux (and *BSD) interceptors to allow for up to 3 (2 for *BSD)
simultaneous interceptors. See code comments for details.

The main motivation is to support new sampling sanitizers (in the spirit
of GWP-ASan), that have to intercept few functions. Unfortunately, the
reality is that there are user interceptors that exist in the wild.

To support foreign user interceptors, foreign dynamic analysis
interceptors, and compiler-rt interceptors all at the same time,
including any combination of them, this change enables up to 3
interceptors on Linux (2 on *BSD).

v2:
* Revert to to the simpler "weak wrapper -(alias)-> __interceptor"
  scheme on architectures that cannot implement a trampoline efficiently
  due to complexities of resolving a preemptible symbol (PowerPC64
  ELFv2 global entry, and i386 PIC).
* Avoid duplicate intercepted functions in gen_dynamic_list.py, due to
  matching __interceptor_X and ___interceptor_X.
* Fix s390 __tls_get_offset.

Reviewed By: dvyukov, MaskRay, vitalybuka

Differential Revision: https://reviews.llvm.org/D151085
2023-06-09 11:30:41 +02:00
Marco Elver
4d927fc035 [compiler-rt] Reformat interception macros
Reformat interception macros to be more readable.

NFC.
2023-06-09 10:43:37 +02:00
Ellis Hoag
6ebf7cd7ed [InstrProf][compiler-rt] Fix counter section alignment issue
I recently discovered that `.profraw` headers are expected to be 8 byte
aligned.
643ba926c1/llvm/lib/ProfileData/InstrProfReader.cpp (L503-L506)

When function entry coverage mode is used, function counters are single
bytes, so it is likely that the size of the counters section is not 8
byte aligned. We can add padding after the counters section to guarantee
this.

Reviewed By: kyulee, gulfem

Differential Revision: https://reviews.llvm.org/D152479
2023-06-08 17:26:18 -07:00
usama hameed
16946466fd
Revert "[Sanitizers][Darwin] In DlAddrSymbolizer, return only the module file name instead of the comlpete module path during symbolication."
The commit broke asan_symbolize.py script on Darwin which depended on
using the complete module path to symolize crash traces offline.

This reverts commit f6ea869f7c043c70722b8db6be94d9ad4cc9eb92.

rdar://110487521
2023-06-08 16:02:54 -07:00
Marco Elver
84a64df3a0 [memprof] Fix rawprofile test on 32-bit architectures
The first argument of StackTrace constructor is a pointer to uptr. Match
the type accordingly.

This fixes builds on 32-bit architectures.
2023-06-08 13:03:08 +02:00
Marco Elver
90653579c0 [sanitizer_common] Move UNDEFINED attribute outside _MSC_VER guard
The __has_attribute check is sufficient, and if clang-cl is used, the
attribute will be available as well.
2023-06-08 13:03:08 +02:00
usama hameed
e487713a21
[Sanitizers] UUID/Build ID is 16 bytes on Darwin.
https://reviews.llvm.org/D114294 changed the kModuleUUIDSize from 16 to 32 for
all platforms. This is not true for Darwin where the UUID is 16 bytes.

Differential Revision: https://reviews.llvm.org/D152309
rdar://110346025
2023-06-07 14:32:41 -07:00
Mark de Wever
296d867287 [compiler-rt] Fixes Chromium Apple CI.
s/add_asm_sources/set/ at one place it was forgotten in D152102 as
reported by @paulkirth.
2023-06-07 21:24:05 +02:00
usama hameed
5a9498124d
[Sanitizers] Remove BuildId from sanitizers stacktrace on Darwin
On Darwin, we do not want to show the BuildId appended at the end of stack
frames in Sanitizers. The BuildId/UUID can be seen by using the
print_module_map=1 sanitizer option.

Differential Revision: https://reviews.llvm.org/D150298

rdar://108324403
2023-06-07 11:17:25 -07:00
Mark de Wever
42478d1473 [compiler-rt] Removes CMake work-arounds.
CMake older than 3.20.0 is no longer supported.
This removes work-arounds for no longer supported versions.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D152102
2023-06-07 17:42:28 +02:00
Justin Cady
a3a4369ea1 [ASAN] Fix validation size for dirent on FreeBSD
Typically the size required to represent a dirent is stored in `d_reclen`. But
this not always the case for FreeBSD (for example, when walking a directory
over NFS).

This leads to ASAN false positives for `scandir` and similar functions. Because
ASAN uses `d_reclen` for the range to validate, it can overrun when `d_reclen` is
incorrect (too large).

This change adds `__sanitizer_dirsiz` which fixes the dirent size calculation
for FreeBSD. Other platforms continue to use `d_reclen`.

Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D151583
2023-06-07 10:59:07 -04:00
Martin Storsjö
6853c49164 [compiler-rt] Do not redefine builtins in MinGW configs either
This fixes broken mingw builds since
0a71e25e2448ee471b1ebe74e910c5de9b9c82b4. Clang-cl style builds
were broken similarly, but were fixed in
caa2c1bacbd76c017ebbb4fd13861f0f66770299, with the comment
"Do not redefine builtins on Windows", even if the fix only affected
Clang-cl style builds.
2023-06-07 14:49:57 +03:00
Marco Elver
1cec9f8dc8 [sanitizer_common] Use interception macros for s390 __tls_get_addr declarations
NFC.
2023-06-07 13:09:43 +02:00