[PATCH] D52091: [winasan] Unpoison the stack in NtTerminateThread
David Major via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 20 08:01:06 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT342652: [winasan] Unpoison the stack in NtTerminateThread (authored by dmajor, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D52091?vs=165483&id=166295#toc
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D52091
Files:
lib/asan/asan_win.cc
Index: lib/asan/asan_win.cc
===================================================================
--- lib/asan/asan_win.cc
+++ lib/asan/asan_win.cc
@@ -154,14 +154,24 @@
asan_thread_start, t, thr_flags, tid);
}
+INTERCEPTOR_WINAPI(void, NtTerminateThread, void *rcx) {
+ // Unpoison the terminating thread's stack because the memory may be re-used.
+ NT_TIB *tib = (NT_TIB *)NtCurrentTeb();
+ uptr stackSize = (uptr)tib->StackBase - (uptr)tib->StackLimit;
+ __asan_unpoison_memory_region(tib->StackLimit, stackSize);
+ return REAL(NtTerminateThread(rcx));
+}
+
// }}}
namespace __asan {
void InitializePlatformInterceptors() {
ASAN_INTERCEPT_FUNC(CreateThread);
ASAN_INTERCEPT_FUNC(SetUnhandledExceptionFilter);
-
+ CHECK(::__interception::OverrideFunction("NtTerminateThread",
+ (uptr)WRAP(NtTerminateThread),
+ (uptr *)&REAL(NtTerminateThread)));
#ifdef _WIN64
ASAN_INTERCEPT_FUNC(__C_specific_handler);
#else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52091.166295.patch
Type: text/x-patch
Size: 1050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180920/33ccef0a/attachment.bin>
More information about the llvm-commits
mailing list