Lines Matching +full:low +full:- +full:leakage
1 //===-- safestack.cpp -----------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
59 // For now, store it in a thread-local variable.
68 // relying on the system-enforced ASLR. The protection of the (safe) stack can
71 // 1) Protection via hardware segmentation on x86-32 and some x86-64
86 // leakage of the stack pointer can be prevented. Currently, libc can leak the
87 // stack pointer in several ways (e.g. in longjmp, signal handling, user-level
89 // in other low-level libraries, by either eliminating the escaping/dumping of
91 // encryption/PTR_MANGLE (XOR-ing the dumped stack pointer with another secret
110 // Per-thread unsafe stack information. It's not frequently accessed, so there
111 // it can be kept out of the tcb in normal thread-local variables.
119 MAP_PRIVATE | MAP_ANON, -1, 0); in unsafe_stack_alloc()
129 SFS_CHECK((((size_t)stack_ptr) & (kStackAlign - 1)) == 0); in unsafe_stack_setup()
140 /// Safe stack per-thread information passed to the thread_start function
155 void *(*start_routine)(void *) = tinfo->start_routine; in thread_start()
156 void *start_routine_arg = tinfo->start_routine_arg; in thread_start()
159 unsafe_stack_setup(tinfo->unsafe_stack_start, tinfo->unsafe_stack_size, in thread_start()
160 tinfo->unsafe_stack_guard); in thread_start()
162 // Make sure out thread-specific destructor will be called in thread_start()
182 /// Thread-specific data destructor. We want to free the unsafe stack only after
183 /// this thread is terminated. libc can call functions in safestack-instrumented
184 /// code (like free) after thread-specific data destructors have run.
203 if (stack->pid != pid || in thread_cleanup_handler()
204 (-1 == TgKill(stack->pid, stack->tid, 0) && errno == ESRCH)) { in thread_cleanup_handler()
205 Munmap(stack->stack_base, stack->size); in thread_cleanup_handler()
206 *stackp = stack->next; in thread_cleanup_handler()
209 stackp = &stack->next; in thread_cleanup_handler()
214 cur_stack->stack_base = (char *)unsafe_stack_start - unsafe_stack_guard; in thread_cleanup_handler()
215 cur_stack->size = unsafe_stack_size + unsafe_stack_guard; in thread_cleanup_handler()
216 cur_stack->pid = pid; in thread_cleanup_handler()
217 cur_stack->tid = tid; in thread_cleanup_handler()
223 cur_stack->next = temp_stacks; in thread_cleanup_handler()
270 (struct tinfo *)(((char *)addr) + size - sizeof(struct tinfo)); in INTERCEPTOR()
271 tinfo->start_routine = start_routine; in INTERCEPTOR()
272 tinfo->start_routine_arg = arg; in INTERCEPTOR()
273 tinfo->unsafe_stack_start = addr; in INTERCEPTOR()
274 tinfo->unsafe_stack_size = size; in INTERCEPTOR()
275 tinfo->unsafe_stack_guard = guard; in INTERCEPTOR()