e8139f585a
This patch adds the necessary bionic code for the linker to protect global data using MTE. The implementation is described in the MemtagABI addendum to the AArch64 ELF ABI: https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst In summary, this patch includes: 1. When MTE globals is requested, the linker maps writable SHF_ALLOC sections as anonymous pages with PROT_MTE (copying the file contents into the anonymous mapping), rather than using a file-backed private mapping. This is required as file-based mappings are not necessarily backed by the kernel with tag-capable memory. For sections already mapped by the kernel when the linker is invoked via. PT_INTERP, we unmap the contents, remap a PROT_MTE+anonymous mapping in its place, and re-load the file contents from disk. 2. When MTE globals is requested, the linker tags areas of global memory (as defined in SHT_AARCH64_MEMTAG_GLOBALS_DYNAMIC) with random tags, but ensuring that adjacent globals are never tagged using the same memory tag (to provide detemrinistic overflow detection). 3. Changes to RELATIVE, ABS64, and GLOB_DAT relocations to load and store tags in the right places. This ensures that the address tags are materialized into the GOT entries as well. These changes are a functional no-op to existing binaries and/or non-MTE capable hardware. Bug: N/A Test: atest bionic-unit-tests CtsBionicTestCases --test-filter=*Memtag* Change-Id: Id7b1a925339b14949d5a8f607dd86928624bda0e |
||
---|---|---|
.. | ||
bionic | ||
scudo_platform_tls_slot.h |