platform_bionic/libc/arch-arm64
Evgenii Stepanov 3031a7e45e memtag_stack: vfork and longjmp support.
With memtag_stack, each function is responsible for cleaning up
allocation tags for its stack frame. Allocation tags for anything below
SP must match the address tag in SP.

Both vfork and longjmp implement non-local control transfer which
abandons part of the stack without proper cleanup. Update allocation
tags:
* For longjmp, we know both source and destination values of SP.
* For vfork, save the value of SP before exit() or exec*() - the only
  valid ways of ending the child process according to POSIX - and reset
  tags from there to SP-in-parent.

This is not 100% solid and can be confused by a number of hopefully
uncommon conditions:
* Segmented stacks.
* Longjmp from sigaltstack into the main stack.
* Some kind of userspace thread implementation using longjmp (that's UB,
  longjmp can only return to the caller on the current stack).
* and other strange things.

This change adds a sanity limit on the size of the tag cleanup. Also,
this logic is only activated in the binaries that carry the
NT_MEMTAG_STACK note (set by -fsanitize=memtag-stack) which is meant as
a debugging configuration, is not compatible with pre-armv9 CPUs, and
should not be set on production code.

Bug: b/174878242
Test: fvp_mini with ToT LLVM (more test in a separate change)

Change-Id: Ibef8b2fc5a6ce85c8e562dead1019964d9f6b80b
2022-05-27 13:19:34 -07:00
..
bionic memtag_stack: vfork and longjmp support. 2022-05-27 13:19:34 -07:00
generic/bionic libc: Add Armv8.3-A PAuth and Armv8.5-A BTI compatibility to *.S 2020-09-04 11:29:12 +02:00
dynamic_function_dispatch.cpp Remove ANDROID_EXPERIMENTAL_MTE. 2021-01-11 10:55:51 -08:00
static_function_dispatch.S libc: Add Armv8.3-A PAuth and Armv8.5-A BTI compatibility to *.S 2020-09-04 11:29:12 +02:00