Sebastian Lackner : ntdll: Handle stack guard pages on x86_64.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Apr 15 10:00:24 CDT 2016


Module: wine
Branch: master
Commit: d25ae3ca25c177f659eb0cd54e3d171b048811f6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d25ae3ca25c177f659eb0cd54e3d171b048811f6

Author: Sebastian Lackner <sebastian at fds-team.de>
Date:   Fri Apr 15 10:52:17 2016 +0200

ntdll: Handle stack guard pages on x86_64.

Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/signal_x86_64.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index a79fd6e..ca3e6ca 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -2587,9 +2587,27 @@ static inline BOOL handle_interrupt( unsigned int interrupt, EXCEPTION_RECORD *r
  */
 static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext )
 {
-    EXCEPTION_RECORD *rec = setup_exception( sigcontext, raise_segv_exception );
+    EXCEPTION_RECORD *rec;
     ucontext_t *ucontext = sigcontext;
 
+    /* check for page fault inside the thread stack */
+    if (TRAP_sig(ucontext) == TRAP_x86_PAGEFLT &&
+        (char *)siginfo->si_addr >= (char *)NtCurrentTeb()->DeallocationStack &&
+        (char *)siginfo->si_addr < (char *)NtCurrentTeb()->Tib.StackBase &&
+        virtual_handle_stack_fault( siginfo->si_addr ))
+    {
+        /* check if this was the last guard page */
+        if ((char *)siginfo->si_addr < (char *)NtCurrentTeb()->DeallocationStack + 2*4096)
+        {
+            rec = setup_exception( sigcontext, raise_segv_exception );
+            rec->ExceptionCode = EXCEPTION_STACK_OVERFLOW;
+        }
+        return;
+    }
+
+    rec = setup_exception( sigcontext, raise_segv_exception );
+    if (rec->ExceptionCode == EXCEPTION_STACK_OVERFLOW) return;
+
     switch(TRAP_sig(ucontext))
     {
     case TRAP_x86_OFLOW:   /* Overflow exception */




More information about the wine-cvs mailing list