diff options
author | Vlad Tsyrklevich <vlad@tsyrklevich.net> | 2018-08-21 17:29:01 +0000 |
---|---|---|
committer | Vlad Tsyrklevich <vlad@tsyrklevich.net> | 2018-08-21 17:29:01 +0000 |
commit | bf533e0469db4e619af75476744f05ae7f5a090b (patch) | |
tree | f8fbd4e18100818b3ee489359707d91a1ef05ce2 /lib/safestack | |
parent | 3c5a7c78153449f07919012e9092eed8be0a5cc5 (diff) | |
download | compiler-rt-bf533e0469db4e619af75476744f05ae7f5a090b.tar.gz |
SafeStack: Use correct unsafe stack sizes
Summary:
When deallocating thread stacks, we use one thread's unsafe stack size
to deallocate another thread's unsafe stack; however, the two sizes may
differ. Record an unsafe stack's size in the thread stack linked list.
Reviewers: pcc, eugenis
Reviewed By: eugenis
Subscribers: delcypher, llvm-commits, #sanitizers, kcc
Differential Revision: https://reviews.llvm.org/D51016
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@340308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/safestack')
-rw-r--r-- | lib/safestack/safestack.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/safestack/safestack.cc b/lib/safestack/safestack.cc index 920b89b5e..673f5fd30 100644 --- a/lib/safestack/safestack.cc +++ b/lib/safestack/safestack.cc @@ -152,6 +152,7 @@ static void *thread_start(void *arg) { struct thread_stack_ll { struct thread_stack_ll *next; void *stack_base; + size_t size; pid_t pid; tid_t tid; }; @@ -183,7 +184,7 @@ static void thread_cleanup_handler(void *_iter) { while (*stackp) { thread_stack_ll *stack = *stackp; if (stack->pid != pid || TgKill(stack->pid, stack->tid, 0) == -ESRCH) { - UnmapOrDie(stack->stack_base, unsafe_stack_size + unsafe_stack_guard); + UnmapOrDie(stack->stack_base, stack->size); *stackp = stack->next; free(stack); } else @@ -193,6 +194,7 @@ static void thread_cleanup_handler(void *_iter) { thread_stack_ll *cur_stack = (thread_stack_ll *)malloc(sizeof(thread_stack_ll)); cur_stack->stack_base = (char *)unsafe_stack_start - unsafe_stack_guard; + cur_stack->size = unsafe_stack_size + unsafe_stack_guard; cur_stack->pid = pid; cur_stack->tid = tid; |