diff options
Diffstat (limited to 'libc/bionic/pthread_create.cpp')
-rw-r--r-- | libc/bionic/pthread_create.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp index cc37f5a74..dbdb18058 100644 --- a/libc/bionic/pthread_create.cpp +++ b/libc/bionic/pthread_create.cpp @@ -71,6 +71,7 @@ void __init_alternate_signal_stack(pthread_internal_t* thread) { // Create and set an alternate signal stack. void* stack_base = mmap(NULL, SIGNAL_STACK_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); if (stack_base != MAP_FAILED) { + // Create a guard page to catch stack overflows in signal handlers. if (mprotect(stack_base, PAGE_SIZE, PROT_NONE) == -1) { munmap(stack_base, SIGNAL_STACK_SIZE); @@ -85,7 +86,7 @@ void __init_alternate_signal_stack(pthread_internal_t* thread) { // We can only use const static allocated string for mapped region name, as Android kernel // uses the string pointer directly when dumping /proc/pid/maps. - prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, stack_base, SIGNAL_STACK_SIZE, "thread signal stack"); + prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ss.ss_sp, ss.ss_size, "thread signal stack"); } } |