Merge "Check for mprotect result" into main am: 0b2996f144 am: fd88338ed7

Original change: https://android-review.googlesource.com/c/platform/bionic/+/2654229

Change-Id: I605232bc5ded5a385d68bd55c892231556317906
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Kelvin Zhang 2023-07-12 03:02:10 +00:00 committed by Automerger Merge Worker
commit bb9ceed708

View file

@ -137,7 +137,10 @@ static void __init_shadow_call_stack(pthread_internal_t* thread __unused) {
// Make the stack read-write, and store its address in the register we're using as the shadow
// stack pointer. This is deliberately the only place where the address is stored.
char* scs = scs_aligned_guard_region + scs_offset;
mprotect(scs, SCS_SIZE, PROT_READ | PROT_WRITE);
if (mprotect(scs, SCS_SIZE, PROT_READ | PROT_WRITE) == -1) {
async_safe_fatal("failed to mprotect() on shadow stack %p %d error %s", scs, SCS_SIZE,
strerror(errno));
}
#if defined(__aarch64__)
__asm__ __volatile__("mov x18, %0" ::"r"(scs));
#elif defined(__riscv)