llvm-project/compiler-rt
Peter Collingbourne 3f71ce8589 scudo: Support memory tagging in the secondary allocator.
This patch enhances the secondary allocator to be able to detect buffer
overflow, and (on hardware supporting memory tagging) use-after-free
and buffer underflow.

Use-after-free detection is implemented by setting memory page
protection to PROT_NONE on free. Because this must be done immediately
rather than after the memory has been quarantined, we no longer use the
combined allocator quarantine for secondary allocations. Instead, a
quarantine has been added to the secondary allocator cache.

Buffer overflow detection is implemented by aligning the allocation
to the right of the writable pages, so that any overflows will
spill into the guard page to the right of the allocation, which
will have PROT_NONE page protection. Because this would require the
secondary allocator to produce a header at the correct position,
the responsibility for ensuring chunk alignment has been moved to
the secondary allocator.

Buffer underflow detection has been implemented on hardware supporting
memory tagging by tagging the memory region between the start of the
mapping and the start of the allocation with a non-zero tag. Due to
the cost of pre-tagging secondary allocations and the memory bandwidth
cost of tagged accesses, the allocation itself uses a tag of 0 and
only the first four pages have memory tagging enabled.

This is a reland of commit 7a0da88943 which was reverted in commit
9678b07e42. This reland includes the following changes:

- Fix the calculation of BlockSize which led to incorrect statistics
  returned by mallinfo().
- Add -Wno-pedantic to silence GCC warning.
- Optionally add some slack at the end of secondary allocations to help
  work around buggy applications that read off the end of their
  allocation.

Differential Revision: https://reviews.llvm.org/D93731
2021-03-08 14:39:33 -08:00
..
cmake [CMake] Rename RUNTIMES_BUILD to LLVM_RUNTIMES_BUILD 2021-03-03 10:58:51 -08:00
docs
include [dfsan] Add utils to get and print origin paths and some test cases 2021-03-06 00:11:35 +00:00
lib scudo: Support memory tagging in the secondary allocator. 2021-03-08 14:39:33 -08:00
test [sanitizers] Fix interception of GLibc regexec 2021-03-08 10:53:55 +00:00
tools [GWP-ASan] Add inbuilt options parser. 2021-01-15 12:57:05 -08:00
unittests [Scudo] [GWP-ASan] Add GWP-ASan to Scudo Standalone. 2019-12-13 09:09:41 -08:00
utils [compiler-rt] [netbsd] Update generate_netbsd_syscalls.awk 2020-09-10 20:16:17 +02:00
www [Branch-Rename] Fix some links 2021-02-01 16:43:21 +05:30
.clang-tidy [NFC][compiler-rt] Refine .clang-tidy checks 2020-09-05 15:42:15 -07:00
.gitignore
CMakeLists.txt [CMake] Rename RUNTIMES_BUILD to LLVM_RUNTIMES_BUILD 2021-03-03 10:58:51 -08:00
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
README.txt

README.txt

Compiler-RT
================================

This directory and its subdirectories contain source code for the compiler
support routines.

Compiler-RT is open source software. You may freely distribute it under the
terms of the license agreement found in LICENSE.txt.

================================