16177 Commits

Author SHA1 Message Date
Roy Sundahl
b2d9e08c44
[asan][darwin] This test is x86_64 specific, not non-ios in general.
This test was unsupported in iOS when a more accurate test is that the architecture is x86_64. This "fix" is first in a series of updates intended to get asan arm64 tests fully functional.

Reviewed By: thetruestblue, vitalybuka

Differential Revision: https://reviews.llvm.org/D138001
2022-11-15 11:25:54 -08:00
Petr Hosek
9c2700dfa5 [CMake][compiler-rt] Don't load LLVM config in the runtimes build
LLVM runtimes build already loads the LLVM config and sets all
appropriate variables, no need to do it again.

Differential Revision: https://reviews.llvm.org/D137870
2022-11-15 09:01:46 +00:00
Kuba Mracek
32bada2eda [lsan] Fix stack buffer overwrite in SuspendedThreadsListMac::GetRegistersAndSP
The call to the thread_get_state syscall (that fetches the register values for a thread) on arm64 is mistakenly claiming that the buffer to receive the register state is larger that its actual size on the stack -- the struct on the stack is arm_thread_state64_t, but the MACHINE_THREAD_STATE + MACHINE_THREAD_STATE_COUNT refer to the "unified arm state" struct (which is larger).

Fixes https://github.com/llvm/llvm-project/issues/58503.

Differential Revision: https://reviews.llvm.org/D137292
2022-11-12 10:17:52 -08:00
Lang Hames
e7707464a3 [ORC-RT][MachO] Unlock JDStatesMutex during push-initializers to avoid deadlock.
During __orc_rt_macho_jit_dlopen the ORC runtime will make a request to the JIT
to push any new initializers. Since this call may add new JD-state to the
runtime (and is expected to in general) we need to unlock the JDStatesMutex
during this operation (and similarly when running initializers and atexits, as
these may call trigger push-initializers recursively).

No testcase yet: I haven't been able to reproduce the deadlock when running
llvm-jitlink in in-process mode, and we don't support out-of-process mode in
regression tests yet.
2022-11-11 16:01:25 -08:00
XingLi
1e2c20fc13 [compiler-rt] Mark $t* as clobbered for Linux/LoongArch syscalls
Linux/LoongArch doesn't preserve temporary registers across syscalls,
so we have to explicitly mark them as clobbered to avoid trashing local variables.

Reviewed By: xry111, xen0n, tangyouling, SixWeining

Differential Revision: https://reviews.llvm.org/D137396
2022-11-11 21:24:07 +08:00
Timm Bäder
e1b88c8a09 [clang] Only use major version in resource dir
This causes unnecessary churn for downstreams.

For the full discussion, see https://discourse.llvm.org/t/should-we-continue-embed-the-full-llvm-version-in-lib-clang/62094

Differential Revision: https://reviews.llvm.org/D125860
2022-11-10 15:02:03 +01:00
Simon Pilgrim
261b3f71c0 [X86] Add missing Zen3 model subtypes
This patch adds support for detecting all current Zen/Zen3+ submodels

Based off a mixture of https://github.com/torvalds/linux/blob/master/drivers/hwmon/k10temp.c#L436 and InstLatx64 https://github.com/InstLatx64/InstLatx64/tree/master/AuthenticAMD CPUID dumps and confirmed by @GGanesh

Differential Revision: https://reviews.llvm.org/D137695
2022-11-10 10:36:09 +00:00
Youling Tang
3ba498d145 [fuzzer][test] Add #include <cstdint> for gcc-13
See https://gcc.gnu.org/gcc-13/porting_to.html#header-dep-changes.

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D137696
2022-11-10 13:44:11 +08:00
Youling Tang
8993f3eed6 [sanitizer] Add symbolizer support for loongarch64
Reviewed By: xry111

Differential Revision: https://reviews.llvm.org/D137383
2022-11-10 13:38:09 +08:00
Youling Tang
91bc4abfdb [sanitizer][test] Fix FastUnwindTest on LoongArch
Fixes the `FastUnwindTest` unit test for LoongArch.
This change is similar to RISCV D90574.

The following test cases pass after applying the patch:
```
$ ./runtimes/runtimes-bins/compiler-rt/lib/sanitizer_common/tests/Sanitizer-loongarch64-Test
...
[  FAILED  ] FastUnwindTest.Basic
[  FAILED  ] FastUnwindTest.FramePointerLoop
[  FAILED  ] FastUnwindTest.MisalignedFramePointer
[  FAILED  ] FastUnwindTest.FPBelowPrevFP
[  FAILED  ] FastUnwindTest.CloseToZeroFrame
```

Reviewed By: SixWeining, xen0n, MaskRay

Differential Revision: https://reviews.llvm.org/D137314
2022-11-10 13:35:52 +08:00
Youling Tang
14cd113e69 [sanitizer] Add the settings of Read and Write flags in SignalContext for LoongArch
The bit-30 in this `__flags` means the address error is due to memory load, and the
bit-31 means the address error is due to memory store. (see SC_ADDRERR_RD
and SC_ADDRERR_WR in kernel arch/loongarch/include/uapi/asm/sigcontext.h).

`illegal_write_test.cpp` and `illegal_read_test.cpp` have been tested and passed.

Reviewed By: SixWeining, xen0n, XiaodongLoong

Differential Revision: https://reviews.llvm.org/D137231
2022-11-10 13:34:22 +08:00
Youling Tang
eae8d93dc2 [sanitizer] Add GetMaxVirtualAddress() support for LoongArch
Add support for getting the maximum virtual address, LoongArch has multiple
address space layouts, the default maximum virtual address of the current
user space is 47 bits. (from TASK_SIZE in the kernel for loongarch64).

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D137219
2022-11-10 13:32:30 +08:00
Lang Hames
8fda8901e2 [ORC-RT] Add a SymbolStringPool class to the ORC runtime.
This is a counterpart to llvm::orc::SymbolStringPool. It holds uniqued,
ref-counted strings; and can be used to avoid redundant storage of strings,
and speed up comparison of strings held in the pool (these become pointer
comparisons).
2022-11-09 21:26:18 -08:00
Lang Hames
873584b6cb [ORC-RT][MachO] Add RecordSectionsTracker utility to track metadata sections.
Newly added sections can be processed by calling processNewSections. Calling
reset moves all sections back to the "new" state for reprocessing (expected to
be used by dlclose).
2022-11-09 21:26:17 -08:00
Tom Stellard
2f2b46502f cmake: Fix build with -DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON
This was broken by a11cd0d94ed3cabf0998a0289aead05da94c86eb.
2022-11-09 17:00:08 -08:00
Tom Stellard
a11cd0d94e Move googletest to the third-party directory
Rre-commit of 59052468c3e38cab15582cefbb5133fd4c2ffce5 with a typo
fix in compiler-rt/CMakeLists.txt
2022-11-09 15:28:08 -08:00
Leonard Chan
7612e58565 [compiler-rt][hwasan] Call __hwasan_library_loaded via
__sanitizer_library_loaded on Fuchsia

Differential Revision: https://reviews.llvm.org/D133806
2022-11-09 19:49:08 +00:00
Leonard Chan
40dffefa0e [compiler-rt][hwasan] Do not call InitLoadedGlobals in __hwasan_init
Fuchsia's libc provides a new hook (__sanitizer_module_loaded) which calls
hwasan_library_loaded in the startup path which will register globals in
loaded modules.

Differential Revision: https://reviews.llvm.org/D137676
2022-11-09 19:47:05 +00:00
Tom Stellard
8a084f68c8 Revert "Move googletest to the third-party directory"
This reverts commit 59052468c3e38cab15582cefbb5133fd4c2ffce5.

It looks like this patch breaks the build when compiler-rt is passed to
LLVM_ENABLE_PROJECTS instead of LLVM_ENABLE_RUNTIMES.
2022-11-09 11:34:59 -08:00
Tom Stellard
59052468c3 Move googletest to the third-party directory
This will help improve the project's layering, so that sub-projects
that don't actually need any llvm code can still use googletest
without having to reference code in the llvm directory.

This will also make it easier to consolidate and simplify the standalone
build configurations.

Reviewed By: stellaraccident, lattner, probinson, phosek

Differential Revision: https://reviews.llvm.org/D131919
2022-11-09 11:10:26 -08:00
Freddy Ye
84a18a260e [X86] Support -march=sierraforest, grandridge, graniterapids.
Reviewed By: skan, pengfei, MaskRay

Differential Revision: https://reviews.llvm.org/D137153
2022-11-09 16:56:03 +08:00
Vitaly Buka
def0823f1d [compiler-rt] Set CMP0114 policy for standalone build
Fixes sanitizer-x86_64-linux-qemu bot.
2022-11-08 23:00:47 -08:00
Adhemerval Zanella
9e956995db [clang][Headers] Do not define varargs macros for __need___va_list
The glibc uses the define to avoid namespace polution on headers
that requires variadic argument, where the inclusion of stdarg.h is
required to obtain the va_list definition.

For such cases only __gnuc_va_list is required.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D137268
2022-11-08 16:29:35 -03:00
YunQiang Su
674a17e9bb MIPS/compiler_rt: use synci to flush icache on r6
syscall makes it failed to build on mips64 for mipsel:
```
compiler-rt/lib/builtins/clear_cache.c:97:3: error:
call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  syscall(__NR_cacheflush, start, (end_int - start_int), BCACHE);
```

In this patch, we use `rdhwr` to get synci_step.
If synci_step is zero, it means that the hardware will maintain the coherence. We need to do nothing.
Then for r6+, `synci` is required to keep icache global.
So we can use `synci` to flush icache.
The ISA documents ask a `sync` and a `jr.hb` after `synci`.

For pre-r6, we can use cacheflush libc function, which is same on Linux and FreeBSD.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D135565
2022-11-07 17:43:41 -08:00
Sam James
32a2af44e1 [CMake] Fix -Wstrict-prototypes
Fixes warnings (or errors, if someone injects -Werror in their build system,
which happens in fact with some folks vendoring LLVM too) with Clang 16:
```
+/var/tmp/portage.notmp/portage/sys-devel/llvm-15.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: warning: a function declaration without a prototype
is deprecated in all versions of C [-Wstrict-prototypes]
-/var/tmp/portage.notmp/portage/sys-devel/llvm-14.0.4/work/llvm_build-abi_x86_64.amd64/CMakeFiles/CMakeTmp/src.c:3:9: error: a function declaration without a prototype is
deprecated in all versions of C [-Werror,-Wstrict-prototypes]
 int main() {return 0;}
         ^
          void
```

Differential Revision: https://reviews.llvm.org/D137503
2022-11-08 01:37:04 +00:00
Sean Cross
7c80e7a294 [builtins] Check __SIZEOF_INT128__ for CRT_HAS_128BIT
When building libstd on Rust for a riscv32 target, `compiler-rt` fails to build with the following error:

```
  running: "riscv-none-elf-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=rv32imac" "-mabi=ilp32" "-mcmodel=medany" "-fno-builtin" "-fvisibility=hidden" "-ffreestanding" "-fomit-frame-pointer" "-ffile-prefix-map=E:\\Code\\Xous\\rust-next\\src\\llvm-project\\compiler-rt=." "-DVISIBILITY_HIDDEN" "-o" "E:\\Code\\Xous\\rust-next\\target\\riscv32imac-unknown-xous-elf\\release\\build\\compiler_builtins-b0d7dd25c6999904\\out\\absvdi2.o" "-c" "E:\\Code\\Xous\\rust-next\\src\\llvm-project\\compiler-rt\\lib/builtins\\absvdi2.c"
  cargo:warning=In file included from E:\Code\Xous\rust-next\src\llvm-project\compiler-rt\lib/builtins\int_lib.h:99,
  cargo:warning=                 from E:\Code\Xous\rust-next\src\llvm-project\compiler-rt\lib/builtins\absvdi2.c:13:
  cargo:warning=E:\Code\Xous\rust-next\src\llvm-project\compiler-rt\lib/builtins\int_types.h:79:1: error: unable to emulate 'TI'
  cargo:warning=   79 | typedef int ti_int __attribute__((mode(TI)));
  cargo:warning=      | ^~~~~~~
  cargo:warning=E:\Code\Xous\rust-next\src\llvm-project\compiler-rt\lib/builtins\int_types.h:80:1: error: unable to emulate 'TI'
  cargo:warning=   80 | typedef unsigned tu_int __attribute__((mode(TI)));
  cargo:warning=      | ^~~~~~~
  exit code: 1
```

This is because 128-bit support is gated on the `__riscv` compiler macro which is valid for both rv32 and rv64. However, only rv64 has 128-bit support, so this fails when building for rv32.

Add a check for `__SIZEOF_INT128__` to ensure that 128-bit support is only enabled on targets that support it.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D137485
2022-11-06 19:02:08 -08:00
Fangrui Song
0f91ec243d [builtins] Canonicalize PowerPC detection macros to __powerpc__
The lowercase __ppc__ is not defined by Linux GCC, therefore it lures
users to write code which is not portable to GCC. Migrate to __powerpc__ in
preparation for undefining __ppc__. __powerpc__ is much more common than
__PPC__.
2022-11-06 17:34:04 -08:00
Xi Ruoyao
061426df57 [sanitizer] Fix vfork interception on loongarch64
Fix a brown paper bag error made by me in D129418.  I didn't set
ASAN_INTERCEPT_VFORK correctly for loongarch64, but created an all-zero
object for __interception::real_vfork.  This caused anything calling
vfork() to die instantly.

Fix this issue by setting ASAN_INTERCEPT_VFORK and remove the bad
all-zero definition.  Other ports have an all-zero common definition but
we don't need it at least for now.

And, enable ASAN vfork test for loongarch64 to prevent regression in the
future.

Differential Revision: https://reviews.llvm.org/D137160
2022-11-03 11:08:15 +08:00
Fangrui Song
1ada819c23 [asan] Default to -fsanitize-address-use-odr-indicator for non-Windows
This enables odr indicators on all platforms and private aliases on non-Windows.
Note that GCC also uses private aliases: this fixes bogus
`The following global variable is not properly aligned.` errors for interposed global variables

Fix https://github.com/google/sanitizers/issues/398
Fix https://github.com/google/sanitizers/issues/1017
Fix https://github.com/llvm/llvm-project/issues/36893 (we can restore D46665)

Global variables of non-hasExactDefinition() linkages (i.e.
linkonce/linkonce_odr/weak/weak_odr/common/external_weak) are not instrumented.
If an instrumented variable gets interposed to an uninstrumented variable due to
symbol interposition (e.g. in issue 36893, _ZTS1A in foo.so is resolved to _ZTS1A in
the executable), there may be a bogus error.

With private aliases, the register code will not resolve to a definition in
another module, and thus prevent the issue.

Cons: minor size increase. This is mainly due to extra `__odr_asan_gen_*` symbols.
(ELF) In addition, in relocatable files private aliases replace some relocations
referencing global symbols with .L symbols and may introduce some STT_SECTION symbols.

For lld, with -g0, the size increase is 0.07~0.09% for many configurations I
have tested: -O0, -O1, -O2, -O3, -O2 -ffunction-sections -fdata-sections
-Wl,--gc-sections. With -g1 or above, the size increase ratio will be even smaller.

This patch obsoletes D92078.

Don't migrate Windows for now: the static data member of a specialization
`std::num_put<char>::id` is a weak symbol, as well as its ODR indicator.
Unfortunately, link.exe (and lld without -lldmingw) generally doesn't support
duplicate weak definitions (weak symbols in different TUs likely pick different
defined external symbols and conflict).

Differential Revision: https://reviews.llvm.org/D137227
2022-11-02 19:21:33 -07:00
Kirill Stoimenov
a588cfe37e [Sanitizers] Modified __aarch64__ to use the 64 bit version of the allocator.
This change will switch SizeClassAllocator32 to SizeClassAllocator64 on ARM. This might potentially affect ARM platforms with 39-bit address space. This addresses [[ https://github.com/google/sanitizers/issues/703  | issues/703  ]], but unlike [[ https://reviews.llvm.org/D60243 | D60243 ]] it defaults to 64 bit allocator.

Reviewed By: vitalybuka, MaskRay

Differential Revision: https://reviews.llvm.org/D137136
2022-11-02 21:21:30 +00:00
Julian Lettner
ea82ddd070 [TSan] Adjust TSAN_RTL_CFLAGS before it gets copied
Add `COMPILER_RT_LIBDISPATCH_CFLAGS` to `TSAN_RTL_CFLAGS` before it gets
duplicated to `TSAN_RTL_DYNAMIC_CFLAGS` so both versions have the
necessary flags.

Reviewed By: wrotki, rsundahl

Differential Revision: https://reviews.llvm.org/D137183
2022-11-02 11:21:58 -07:00
Kirill Stoimenov
a8604f2254 [ASAN] Removed special case controlling allocator constants for __aarch64__.
This patch should land before D137136 to make sure that the leak sanitizer allocator works correctly. This patch is NFC without D137136.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D137265
2022-11-02 17:27:59 +00:00
Michał Górny
23c665371a [compiler-rt] Switch from llvm-config to find_package(LLVM)
Replace the use of the deprecated `llvm-config` tool with LLVM's CMake
files for detecting LLVM in standalone builds.

Differential Revision: https://reviews.llvm.org/D137024
2022-11-02 07:17:42 +01:00
Vitaly Buka
e02110e2ab Revert "[Sanitizers] Modified __aarch64__ to use the 64 bit version of the allocator."
We need to land asan_allocator.h patches first.

This reverts commit 75a8cdbc0659dc20746f31721cc48ef00c49f746.
2022-11-01 17:04:10 -07:00
Kirill Stoimenov
75a8cdbc06 [Sanitizers] Modified __aarch64__ to use the 64 bit version of the allocator.
This change will switch SizeClassAllocator32 to SizeClassAllocator64 on ARM. This might potentially affect ARM platforms with 39-bit address space. This addresses [[ https://github.com/google/sanitizers/issues/703  | issues/703  ]], but unlike [[ https://reviews.llvm.org/D60243 | D60243 ]] it defaults to 64 bit allocator.

Reviewed By: vitalybuka, MaskRay

Differential Revision: https://reviews.llvm.org/D137136
2022-11-01 20:48:42 +00:00
Roy Sundahl
37a25b48e1 [asan] Add missing __asan_set_shadow_0x() calls.
Add new calls introduced in https://reviews.llvm.org/D136197 to weak_symbols.txt.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D137178
2022-11-01 11:15:33 -07:00
Youling Tang
cb84df210a [sanitizer] Fix build error with current LoongArch Clang
Fix the following build failures:
```
In file included from /home/loongson/llvm-work/llvm-project/compiler-rt/lib/sanitizer_common/sanit>
llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_loongarch64.inc:27:23: error>
  register u64 a7 asm("a7") = nr;
                      ^
llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_loongarch64.inc:28:23: error>
  register u64 a0 asm("a0");                      ^
```

The non-prefix `$` syntax in inline assembly is not supported in clang
yet (it is supported by gcc), add prefix `$` to solve the problem.

Differential Revision: https://reviews.llvm.org/D137145
2022-11-01 20:48:53 +08:00
Youling Tang
867ff7c994 [asan][test] Fix build errors in loongarch64
- Add get_bits_for_arch for loongarch64 detection, fix the following error,
```
$ make check-asan
-- sanitizer_common tests on "Linux" will run against "asan"
CMake Error at test/asan/CMakeLists.txt:22 (message):
  Unknown target architecture: loongarch64
Call Stack (most recent call first):
  test/asan/CMakeLists.txt:49 (get_bits_for_arch)
```

- Do not use __builtin_longjmp, fix the following error,
```
llvm-project/compiler-rt/lib/asan/tests/asan_test.cpp:635:3: error: __builtin_longjmp is not supported for the current target
  __builtin_longjmp((void**)buf, 1);
```

Differential Revision: https://reviews.llvm.org/D137012
2022-11-01 20:21:56 +08:00
Youling Tang
5b27578fc5 [builtins][LoongArch] Port __clear_cache to LoongArch Linux
There are two failures in the current builtins,
Failed Tests (2):
  Builtins-loongarch64-linux :: clear_cache_test.c
  Builtins-loongarch64-linux :: enable_execute_stack_test.c

It is caused by __clear_cache not being implemented and triggering `abort`.

"__clear_cache" is implemented in the same way as "clear_cache" in gcc (
in gcc/config/loongarch/loongarch.md)

Differential Revision: https://reviews.llvm.org/D136921
2022-11-01 20:15:09 +08:00
Youling Tang
6e6704b0dc [compiler-rt][builtins] Support builtins for LoongArch
Initial builtins for LoongArch.
Add loongarch64 to ALL_CRT_SUPPORTED_ARCH list.
Support fe_getround and fe_raise_inexact in builtins.

Differential Revision: https://reviews.llvm.org/D136338
2022-11-01 20:09:32 +08:00
Michał Górny
a05810e8f2 Revert "[compiler-rt] Switch from llvm-config to find_package(LLVM)"
This reverts commit 37acf9bdd4686397a6d37000e8d3fe35f456a860.  It broke
a buildbot.
2022-11-01 05:49:50 +01:00
Michał Górny
37acf9bdd4 [compiler-rt] Switch from llvm-config to find_package(LLVM)
Replace the use of the deprecated `llvm-config` tool with LLVM's CMake
files for detecting LLVM in standalone builds.

Differential Revision: https://reviews.llvm.org/D137024
2022-11-01 04:19:31 +01:00
Patrick Walton
c5ea9b8a51 [test][asan] Make the printf-5.c test case actually emit a volatile memcpy.
The current test in printf-5.c appears to try to emit a volatile memcpy for the
format string, but it doesn't because the volatile qualifier is implicitly
casted away. Using a string literal instead preserves the volatile qualifier.

This is a follow-up to D137031 and is a prerequisite for D136822, which elides
memcpys in more instances and would otherwise break this test.

Differential Revision: https://reviews.llvm.org/D137042
2022-10-30 13:20:36 -07:00
Chia-hung Duan
9dc5b322d5 Revert "Revert "[scudo] Fix the calculating of memory group usage""
This reverts commit 69fe7abb393ba7d6ee9c8ff1429316845b5bad37.

Fixed the arguments order while calling batchGroupBase()

Differential Revision: https://reviews.llvm.org/D136995
2022-10-29 06:26:50 +00:00
Chia-hung Duan
69fe7abb39 Revert "[scudo] Fix the calculating of memory group usage"
This reverts commit 6130d67f70ad2e063b4407b6ee31c7db19464fee.
2022-10-28 22:15:50 +00:00
Chia-hung Duan
6130d67f70 [scudo] Fix the calculating of memory group usage
In SizeClassAllocator64, the boundary of a memory group may not align to
the region begin. Which means the begin addr of a memory group may
smaller than region begin. This leads to wrong judgement of memory group
usage.

Differential Revision: https://reviews.llvm.org/D136898
2022-10-28 20:29:17 +00:00
Chia-hung Duan
a1e325ce7c [scudo] Lazy initialize the PageMap while page releasing
We allocate the page map before knowing if there're groups can be
released. This may result in many redundant map()/unmap() operations if
there's no page to release.

Make the page map be lazy initialized.

Differential Revision: https://reviews.llvm.org/D136873
2022-10-28 20:29:17 +00:00
Advenam Tacet
dd1b7b797a [1b/3][ASan][compiler-rt] API for annotating objects memory
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 extends a compiler-rt ASan sanitization API function sanitizer_annotate_contiguous_container used to sanitize/annotate containers like std::vector to support different allocators and situations when granules are shared between objects. Those changes are necessary to support annotating objects' self memory (in contrast to annotating memory allocated by an object) like short std::basic_string (with short string optimization). That also allows use of non-standard memory allocators, as alignment requirement is no longer necessary.

This also updates an API function to verify if a double ended contiguous container is correctly annotated (__sanitizer_verify_contiguous_container).

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

Reviewed By: #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D132522
2022-10-27 23:29:43 -07:00
Wael Yehia
c8eb932ce6 [PGO] Simplify InstrProfilingRuntime.cpp
Differential Revision: https://reviews.llvm.org/D136192
2022-10-28 05:12:46 +00:00
Chia-hung Duan
4383aa0336 [scudo] Fix size of MaxNumCachedHint Trusty Config
Also add a test for TrustyConfig to ensure it'll be awared of any scudo
configuration change.

Differential Revision: https://reviews.llvm.org/D136732
2022-10-26 18:07:22 +00:00