Added patch to trigger stack overflow exception earlier on x86_64.

This commit is contained in:
Sebastian Lackner 2016-04-16 22:45:16 +02:00
parent 4b7dbb610b
commit d8d1cf2e35
3 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,29 @@
From a679044828d05cd420b1fb4a0dc43fb49da8d665 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 16 Apr 2016 22:29:12 +0200
Subject: ntdll: Trigger stack overflow exception earlier on x86_64.
The Cygwin/MSYS2 exception handler seems to exceed one page,
which breaks handling of stack faults.
---
dlls/ntdll/signal_x86_64.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index 94157bb..81d1758 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -2600,8 +2600,9 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext )
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)
+ if ((char *)siginfo->si_addr < (char *)NtCurrentTeb()->DeallocationStack + 3*4096)
{
+ virtual_handle_stack_fault( (char *)siginfo->si_addr - 4096 );
rec = setup_exception( sigcontext, raise_segv_exception );
rec->ExceptionCode = EXCEPTION_STACK_OVERFLOW;
}
--
2.7.1

View File

@ -0,0 +1 @@
Fixes: Trigger stack overflow exception earlier on x86_64

View File

@ -224,6 +224,7 @@ patch_enable_all ()
enable_ntdll_RtlIpStringToAddress_Tests="$1"
enable_ntdll_RtlQueryPackageIdentity="$1"
enable_ntdll_Serial_Port_Detection="$1"
enable_ntdll_Stack_Overflow="$1"
enable_ntdll_Status_Mapping="$1"
enable_ntdll_Syscall_Wrappers="$1"
enable_ntdll_SystemInterruptInformation="$1"
@ -846,6 +847,9 @@ patch_enable ()
ntdll-Serial_Port_Detection)
enable_ntdll_Serial_Port_Detection="$2"
;;
ntdll-Stack_Overflow)
enable_ntdll_Stack_Overflow="$2"
;;
ntdll-Status_Mapping)
enable_ntdll_Status_Mapping="$2"
;;
@ -5032,6 +5036,18 @@ if test "$enable_ntdll_Serial_Port_Detection" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-Stack_Overflow
# |
# | Modified files:
# | * dlls/ntdll/signal_x86_64.c
# |
if test "$enable_ntdll_Stack_Overflow" -eq 1; then
patch_apply ntdll-Stack_Overflow/0001-ntdll-Trigger-stack-overflow-exception-earlier-on-x8.patch
(
echo '+ { "Sebastian Lackner", "ntdll: Trigger stack overflow exception earlier on x86_64.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-Status_Mapping
# |
# | Modified files: