Commit Graph

16246 Commits

Author SHA1 Message Date
Aries Wu b3609c1ccc Successfully build crt0.o and libworkitem.a 2023-01-17 18:17:55 +08:00
Aries 6959b66022 Add CSRs and kernel metadata buffer offset constant definition ventus.h 2023-01-06 09:32:07 +08:00
Aries e8bf9c0f19 Add initial implementation of _start and OpenCL work-item functions. 2023-01-06 09:03:20 +08:00
Aries 407bd721a8 Update TODOs and add inst 'endprg' to end warp execution. 2023-01-04 11:06:46 +08:00
Aries 5fa7a91d5a Update the definition of Ventus stack pointers 2023-01-04 08:54:35 +08:00
Aries b6721f9fdd Correctly setup the address of stack pointers sp and tp 2023-01-03 17:12:17 +08:00
Aries fe59748e79 Add initial crt0 for Ventus OpenCL kernel. 2023-01-03 16:08:42 +08:00
Mitch Phillips c414bbefe4 Make -fsanitize=scudo use scudo_standalone. Delete check-scudo.
Leaves the implementation and tests files in-place for right now, but
deletes the ability to build the old sanitizer-common based scudo. This
has been on life-support for a long time, and the newer scudo_standalone
is much better supported and maintained.

Also patches up some GWP-ASan wording, primarily related to the fact
that -fsanitize=scudo now is scudo_standalone, and therefore the way to
reference the GWP-ASan options through the environment variable has
changed.

Future follow-up patches will delete the original scudo, and migrate all
its tests over to be part of the scudo_standalone test suite.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D138157
2022-12-02 11:29:41 -08:00
Ties Stuij aadec60ad9 [compiler-rt] support armv4t
The main thing that needed changing was excluding functionality that
isn't supported on armv4t. So excluding Arm specific builtin assembly files.

In the process some files were renamed and the source was annotated where
appropriate, so it's a bit easier to follow what group of files are meant for
what purpose.

Reviewed By: peter.smith, nickdesaulniers

Differential Revision: https://reviews.llvm.org/D138725
2022-12-01 21:24:53 +00:00
Kirill Stoimenov f7c7161137 [HWASAN] Modified __hwasan::Thread::unique_id_ to be u32 instead of u64.
This is needed for LSAN integration work. LSAN uses context to store thread_id << 32 + stack_id. In order to fit both we would need thread_id to be 32 bit.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D139060
2022-12-01 00:44:22 +00:00
Roy Sundahl ad6c8092dc
[asan][aarch64] Don't use 64 bit allocator for Apple ios family
The recent change (https://reviews.llvm.org/D137136) to unconditionally
choose the 64 bit allocator on aarch64 breaks Apple iOS family of devices
which purposely use a smaller address space than is used with macOS.

rdar://102527313

Reviewed By: thetruestblue, yln

Differential Revision: https://reviews.llvm.org/D139030
2022-11-30 13:16:59 -08:00
Shoaib Meenai 442c13f9ff [compiler-rt] Fix check-profile dependencies
It relies on InstrProfData.inc being in the compiler resource directory.

Reviewed By: ellis

Differential Revision: https://reviews.llvm.org/D138969
2022-11-30 11:14:38 -08:00
Thurston Dang b647d8f95d msan: update tests for new memory mappings on aarch64
D137666 changed the memory mappings for msan on aarch64.
This patch updates two more tests to match the new
mappings.

Differential Revision: https://reviews.llvm.org/D139033
2022-11-30 18:19:54 +00:00
Thurston Dang f5e2481b42 msan: update shadow constant in strlen_of_shadow test
strlen_of_shadow hardcodes the mem-to-shadow
constant. That constant was changed in D137666;
this CL updates the test accordingly.
(Other tests will be updated separately.)

Differential Revision: https://reviews.llvm.org/D139027
2022-11-30 17:41:16 +00:00
Gabor Buella e49a6c3d7f [MSAN] add interceptor for stpncpy
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D138386
2022-11-30 12:21:39 +01:00
Dmitry Vyukov 099997540f tsan: fix epoll_pwait2 interceptor
epoll_pwait2 is new and may not be present in libc and/or kernel.
Since we effectively add it to libc (as will be probed by the program
using dlsym or a weak function pointer) we need to handle the case
when it's not present in the actual libc.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D138929
2022-11-30 10:37:11 +01:00
Petr Hosek 12e20a446e [scudo] Do not consider releasing unallocated pages
We already know that there are no free blocks above Region->AllocatedUser.
This results in a smaller RegionPageMap and faster releaseFreeMemoryToOS.

Patch By: fabio-d
Differential Revision: https://reviews.llvm.org/D138794
2022-11-30 02:34:46 +00:00
Thurston Dang b726df1b3a [msan] Increase size of app/shadow/origin mappings on aarch64
msan's app memory mappings for aarch64 are constrained by
the MEM_TO_SHADOW constant to 64GB or less, and some app
memory mappings (in kMemoryLayout) are even smaller in
practice. This will lead to a crash with the error message
"MemorySanitizer can not mmap the shadow memory" if the
executable's memory mappings (e.g., libraries) extend
beyond msan's app memory mappings.

This patch makes the app/shadow/origin memory mappings
considerably larger, along with corresponding changes to
the MEM_TO_SHADOW and SHADOW_TO_ORIGIN constants.

Note that this deprecates compatibility with 39- and 42-bit
VMAs.

Differential Revision: https://reviews.llvm.org/D137666
2022-11-29 20:57:17 +00:00
Vitaly Buka 0d07922d92 [NFC][asan] Simplify parameters check 2022-11-29 10:56:17 -08:00
Vitaly Buka cc27860165 [NFC][asan] Cleanup comments
D132090 is too verbose.
Don't explain obvious.
Add simpler explanation of rounding reasoning.

Differential Revision: https://reviews.llvm.org/D138773
2022-11-29 10:56:17 -08:00
Vitaly Buka 2b026fedca [NFC][asan] Handle non-intersecting case early
Differential Revision: https://reviews.llvm.org/D138772
2022-11-29 10:56:17 -08:00
Vitaly Buka e1657e3229 [asan] Add unaligned double ended container support
Differential Revision: https://reviews.llvm.org/D138771
2022-11-29 10:56:17 -08:00
Roy Sundahl 87d0ff9117
[asan][test] Fix SED issues with macOS (BSD)
SED differs between GNU and BSD in handling semicolon and the use of
'\n' in regex patterns. For macOS we can't use these GNU extensions.

rdar://102686948

Differential Revision: https://reviews.llvm.org/D138824
2022-11-29 09:47:23 -08:00
Vitaly Buka ca3c58f0d1 [lsan] Add logs for debugging 2022-11-28 22:59:38 -08:00
Petr Hosek bec8a372fc [CMake] Use LLVM_TARGET_TRIPLE in runtimes
This variable is derived from LLVM_DEFAULT_TARGET_TRIPLE by default,
but using a separate variable allows additional normalization to be
performed if needed.

Differential Revision: https://reviews.llvm.org/D137451
2022-11-29 04:08:24 +00:00
Teresa Johnson 311801a017 Revert "[MemProf] Defer profile file setup until dump time"
This reverts commit ea1826ee57.

This change is breaking the ability of tests to override the profile
output file. Need to add a mechanism to do that before resubmitting.
2022-11-28 06:29:24 -08:00
Vitaly Buka bc0ae48382 [test][asan] Speedup the test 2022-11-27 23:44:29 -08:00
Vitaly Buka 4880a48ab2 [NFC][asan] Fix typo in names 2022-11-27 23:42:10 -08:00
Vitaly Buka cef078a89d [NFC][asan] Reimplement with FindBadAddress 2022-11-27 23:00:42 -08:00
Vitaly Buka 450ec77037 [NFC][asan] Move a few precondition checks 2022-11-27 23:00:42 -08:00
Vitaly Buka 204cd4e22c [test][asan] Double ended version of TestContainer 2022-11-27 15:26:24 -08:00
Vitaly Buka 8db7768ab8 [NFC][asan] Extract FixUnalignedStorage
And simplify slightly: adjust for unaligned container
only if aligned case poisons different bytes.
2022-11-27 15:26:24 -08:00
Vitaly Buka 4883c91a73 [NFC][asan] Extract kMaxRangeToCheck into a function 2022-11-27 15:26:24 -08:00
Vitaly Buka 09ec58c8d6 [test][asan] Simplify a few expressions 2022-11-27 15:26:24 -08:00
Vitaly Buka 8226ec0e4c [test][asan] Check find_bad_address test
For consistency with future TestDoubleEndedContainer, where calculation
of the expected bad address is complicated.
2022-11-27 15:26:23 -08:00
Vitaly Buka ad663be76f [test][asan] Deduplicate code 2022-11-27 15:26:23 -08:00
Vitaly Buka b6c5875146 [NFC][asan] Rename variables in __sanitizer_annotate_contiguous_container 2022-11-27 15:26:23 -08:00
Dmitry Vyukov fbcdf4a4fb tsan: intercept epoll_pwait2
It's a new syscall similar to epoll_pwait.
Add a similar interceptor for it and add synchronization
annotations in epoll_wait* syscall wrappers.
Testing this is problematic b/c it's not present in glibc
and the syscall itself may not be supported by the kernel.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D138574
2022-11-24 07:27:09 +01:00
Snehasish Kumar cf5c53727b [memprof] Fix RAII usage of SpinMutexLock, remove unused headers.
For the RAII lock usage we need to create a local var. There were some headers which clang-tidy identified as unused.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D138593
2022-11-23 19:16:13 +00:00
Hans Wennborg 907baeec49 Revert "Make -fsanitize=scudo use scudo_standalone. Delete check-scudo."
It broke the build, see comments on code review.

> Leaves the implementation and tests files in-place for right now, but
> deletes the ability to build the old sanitizer-common based scudo. This
> has been on life-support for a long time, and the newer scudo_standalone
> is much better supported and maintained.
>
> Also patches up some GWP-ASan wording, primarily related to the fact
> that -fsanitize=scudo now is scudo_standalone, and therefore the way to
> reference the GWP-ASan options through the environment variable has
> changed.
>
> Future follow-up patches will delete the original scudo, and migrate all
> its tests over to be part of the scudo_standalone test suite.
>
> Reviewed By: vitalybuka
>
> Differential Revision: https://reviews.llvm.org/D138157

This reverts commit ab1a5991fe.
2022-11-23 16:07:07 +01:00
Fangrui Song 06c74b5e73 Revert D138095 Use InernalAlloc in DemangleCXXABI
Broke 2/3 tests on macOS which seem to be related to
`free(demangled_name)` in DemangleCXXABI.
2022-11-22 16:29:24 -08:00
Mitch Phillips ab1a5991fe Make -fsanitize=scudo use scudo_standalone. Delete check-scudo.
Leaves the implementation and tests files in-place for right now, but
deletes the ability to build the old sanitizer-common based scudo. This
has been on life-support for a long time, and the newer scudo_standalone
is much better supported and maintained.

Also patches up some GWP-ASan wording, primarily related to the fact
that -fsanitize=scudo now is scudo_standalone, and therefore the way to
reference the GWP-ASan options through the environment variable has
changed.

Future follow-up patches will delete the original scudo, and migrate all
its tests over to be part of the scudo_standalone test suite.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D138157
2022-11-22 12:08:30 -08:00
Kirill Stoimenov a2ef44a5d6 [Sanitizer][NFC] Rearranged prototype definitions in lsan_common.h to group them by implementation file.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D138335
2022-11-22 17:23:56 +00:00
Youling Tang dcefbce281 [Sanitizer] Fix the implementation of internal_fstat on LoongArch
If `pathname` is an empty string and the AT_EMPTY_PATH flag is specified in `flags`,
statx `pathname` argument is of type `const char *restrict`, so it should be `""`
instead of `0`.

Reviewed By: SixWeining, xen0n, xry111, lixing-star

Differential Revision: https://reviews.llvm.org/D138414
2022-11-22 22:16:11 +08:00
Youling Tang ac84798570 [scudo] Add loongarch64 support for scudo
Enable scudo on LoongArch64 on both clang side and compiler-rt side.

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D138350
2022-11-22 22:02:31 +08:00
Vitaly Buka a27089101e [test][asan] Another try to fix Windows bot
Update pattern on Linux and Darwin for consistency.
2022-11-21 18:45:40 -08:00
Vitaly Buka 9d09982641 [test][asan] Replace tr with sed
tr is not available on Windows bot.
2022-11-21 17:52:39 -08:00
Vitaly Buka 793ff082da [test][asan] Try to fix Windows bot 2022-11-21 17:37:08 -08:00
Evgenii Stepanov 8add770417 Revert "[scudo] Detect double free when running with MTE."
Mysterious failures on the x86_64-linux-qemu, to be debugged.

This reverts commit 1dd54691b2.
2022-11-21 16:57:14 -08:00
Advenam Tacet 1c5ad6d2c0 [1a/3][ASan][compiler-rt] API for double ended containers
This revision is a part of a series of patches extending
AddressSanitizer C++ container overflow detection capabilities by adding
annotations, similar to those existing in std::vector, to std::string
and std::deque collections. These changes allow ASan to detect cases
when the instrumented program accesses memory which is internally
allocated by the collection but is still not in-use (accesses before or
after the stored elements for std::deque, or between the size and
capacity bounds for std::string).

The motivation for the research and those changes was a bug, found by
Trail of Bits, in a real code where an out-of-bounds read could happen
as two strings were compared via a std::equals function that took
iter1_begin, iter1_end, iter2_begin iterators (with a custom comparison
function). When object iter1 was longer than iter2, read out-of-bounds
on iter2 could happen. Container sanitization would detect it.

This revision adds a new compiler-rt ASan sanitization API function
sanitizer_annotate_double_ended_contiguous_container necessary to
sanitize/annotate double ended contiguous containers. Note that that
function annotates a single contiguous memory buffer (for example the
std::deque's internal chunk). Such containers have the beginning of
allocated memory block, beginning of the container in-use data, end of
the container's in-use data and the end of the allocated memory block.
This also adds a new API function to verify if a double ended contiguous
container is correctly annotated
(__sanitizer_verify_double_ended_contiguous_container).

Since we do not modify the ASan's shadow memory encoding values, the
capability of sanitizing/annotating a prefix of the internal contiguous
memory buffer is limited – up to SHADOW_GRANULARITY-1 bytes may not be
poisoned before the container's in-use data. This can cause false
negatives (situations when ASan will not detect memory corruption in
those areas).

On the other hand, API function interfaces are designed to work even if
this caveat would not exist. Therefore implementations using those
functions will poison every byte correctly, if only ASan (and
compiler-rt) is extended to support it. In other words, if ASan was
modified to support annotating/poisoning of objects lying on addresses
unaligned to SHADOW_GRANULARITY (so e.g. prefixes of those blocks),
which would require changing its shadow memory encoding, this would not
require any changes in the libcxx std::string/deque code which is added
in further commits of this patch series.

If you have any questions, please email:
advenam.tacet@trailofbits.com
disconnect3d@trailofbits.com

Differential Revision: https://reviews.llvm.org/D132090
2022-11-21 16:38:52 -08:00