ntdll-Signal_Handler: Remove.

As of 684c272aa794 we disable the stack protector for all (non-PE) code.
This commit is contained in:
Zebediah Figura 2020-02-04 15:12:34 -06:00
parent ca1047528f
commit e55a3a3f43
3 changed files with 35 additions and 193 deletions

View File

@ -1,130 +0,0 @@
From b4d01c5332cd076e5e7f98842d5811d5f44c8a05 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 20 Aug 2017 17:22:20 +0200
Subject: [PATCH] ntdll: Avoid stack protector frame in signal handler
functions.
---
dlls/ntdll/signal_i386.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 1645c9c7d..751ba4264 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -96,6 +96,13 @@ typedef struct
BYTE Reserved4[96];
} XMM_SAVE_AREA32;
+#ifdef __GNUC__
+/* It is not valid to access %gs before init_handler has been called. */
+#define SIGNALFUNC __attribute__((__optimize__("-fno-stack-protector")))
+#else
+#define SIGNALFUNC
+#endif
+
/***********************************************************************
* signal context platform-specific definitions
*/
@@ -582,7 +589,7 @@ static inline int has_fpux(void)
*
* Get the current teb based on the stack pointer.
*/
-static inline TEB *get_current_teb(void)
+static inline TEB * SIGNALFUNC get_current_teb(void)
{
unsigned long esp;
__asm__("movl %%esp,%0" : "=g" (esp) );
@@ -820,7 +827,7 @@ __ASM_GLOBAL_FUNC( clear_alignment_flag,
* Handler initialization when the full context is not needed.
* Return the stack pointer to use for pushing the exception data.
*/
-static inline void *init_handler( const ucontext_t *sigcontext, WORD *fs, WORD *gs )
+static inline void * SIGNALFUNC init_handler( const ucontext_t *sigcontext, WORD *fs, WORD *gs )
{
TEB *teb = get_current_teb();
@@ -1842,7 +1849,7 @@ static struct stack_layout *setup_exception_record( ucontext_t *sigcontext, void
* sigcontext so that the return from the signal handler will call
* the raise function.
*/
-static struct stack_layout *setup_exception( ucontext_t *sigcontext )
+static struct stack_layout * SIGNALFUNC setup_exception( ucontext_t *sigcontext )
{
WORD fs, gs;
void *stack = init_handler( sigcontext, &fs, &gs );
@@ -1958,7 +1965,7 @@ static BOOL handle_interrupt( unsigned int interrupt, ucontext_t *sigcontext, st
* Handler for SIGSEGV and related errors. Used only during the initialization
* of the process to handle virtual faults.
*/
-static void segv_handler_early( int signal, siginfo_t *siginfo, void *sigcontext )
+static void SIGNALFUNC segv_handler_early( int signal, siginfo_t *siginfo, void *sigcontext )
{
WORD fs, gs;
ucontext_t *context = sigcontext;
@@ -1982,7 +1989,7 @@ static void segv_handler_early( int signal, siginfo_t *siginfo, void *sigcontext
*
* Handler for SIGSEGV and related errors.
*/
-static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext )
+static void SIGNALFUNC segv_handler( int signal, siginfo_t *siginfo, void *sigcontext )
{
WORD fs, gs;
struct stack_layout *stack;
@@ -2101,7 +2108,7 @@ done:
*
* Handler for SIGTRAP.
*/
-static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext )
+static void SIGNALFUNC trap_handler( int signal, siginfo_t *siginfo, void *sigcontext )
{
ucontext_t *context = sigcontext;
struct stack_layout *stack = setup_exception( context );
@@ -2143,7 +2150,7 @@ static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext )
*
* Handler for SIGFPE.
*/
-static void fpe_handler( int signal, siginfo_t *siginfo, void *sigcontext )
+static void SIGNALFUNC fpe_handler( int signal, siginfo_t *siginfo, void *sigcontext )
{
ucontext_t *context = sigcontext;
struct stack_layout *stack = setup_exception( context );
@@ -2191,7 +2198,7 @@ static void fpe_handler( int signal, siginfo_t *siginfo, void *sigcontext )
*
* FIXME: should not be calling external functions on the signal stack.
*/
-static void int_handler( int signal, siginfo_t *siginfo, void *sigcontext )
+static void SIGNALFUNC int_handler( int signal, siginfo_t *siginfo, void *sigcontext )
{
WORD fs, gs;
void *stack_ptr = init_handler( sigcontext, &fs, &gs );
@@ -2208,7 +2215,7 @@ static void int_handler( int signal, siginfo_t *siginfo, void *sigcontext )
*
* Handler for SIGABRT.
*/
-static void abrt_handler( int signal, siginfo_t *siginfo, void *sigcontext )
+static void SIGNALFUNC abrt_handler( int signal, siginfo_t *siginfo, void *sigcontext )
{
struct stack_layout *stack = setup_exception( sigcontext );
stack->rec.ExceptionCode = EXCEPTION_WINE_ASSERTION;
@@ -2222,7 +2229,7 @@ static void abrt_handler( int signal, siginfo_t *siginfo, void *sigcontext )
*
* Handler for SIGQUIT.
*/
-static void quit_handler( int signal, siginfo_t *siginfo, void *sigcontext )
+static void SIGNALFUNC quit_handler( int signal, siginfo_t *siginfo, void *sigcontext )
{
WORD fs, gs;
init_handler( sigcontext, &fs, &gs );
@@ -2235,7 +2242,7 @@ static void quit_handler( int signal, siginfo_t *siginfo, void *sigcontext )
*
* Handler for SIGUSR1, used to signal a thread that it got suspended.
*/
-static void usr1_handler( int signal, siginfo_t *siginfo, void *sigcontext )
+static void SIGNALFUNC usr1_handler( int signal, siginfo_t *siginfo, void *sigcontext )
{
CONTEXT context;
WORD fs, gs;
--
2.23.0

View File

@ -1 +0,0 @@
Depends: ntdll-WRITECOPY

View File

@ -208,7 +208,6 @@ patch_enable_all ()
enable_ntdll_RtlIpv4StringToAddress="$1"
enable_ntdll_RtlQueryPackageIdentity="$1"
enable_ntdll_Serial_Port_Detection="$1"
enable_ntdll_Signal_Handler="$1"
enable_ntdll_Status_Mapping="$1"
enable_ntdll_Syscall_Emulation="$1"
enable_ntdll_SystemExtendedProcessInformation="$1"
@ -745,9 +744,6 @@ patch_enable ()
ntdll-Serial_Port_Detection)
enable_ntdll_Serial_Port_Detection="$2"
;;
ntdll-Signal_Handler)
enable_ntdll_Signal_Handler="$2"
;;
ntdll-Status_Mapping)
enable_ntdll_Status_Mapping="$2"
;;
@ -1742,6 +1738,13 @@ if test "$enable_nvcuvid_CUDA_Video_Support" -eq 1; then
enable_nvapi_Stub_DLL=1
fi
if test "$enable_ntdll_WRITECOPY" -eq 1; then
if test "$enable_ntdll_User_Shared_Data" -gt 1; then
abort "Patchset ntdll-User_Shared_Data disabled, but ntdll-WRITECOPY depends on that."
fi
enable_ntdll_User_Shared_Data=1
fi
if test "$enable_ntdll_User_shared_data_fields" -eq 1; then
if test "$enable_wow64cpu_Wow64Transition" -gt 1; then
abort "Patchset wow64cpu-Wow64Transition disabled, but ntdll-User_shared_data_fields depends on that."
@ -1763,20 +1766,6 @@ if test "$enable_ntdll_Syscall_Emulation" -eq 1; then
enable_winebuild_Fake_Dlls=1
fi
if test "$enable_ntdll_Signal_Handler" -eq 1; then
if test "$enable_ntdll_WRITECOPY" -gt 1; then
abort "Patchset ntdll-WRITECOPY disabled, but ntdll-Signal_Handler depends on that."
fi
enable_ntdll_WRITECOPY=1
fi
if test "$enable_ntdll_WRITECOPY" -eq 1; then
if test "$enable_ntdll_User_Shared_Data" -gt 1; then
abort "Patchset ntdll-User_Shared_Data disabled, but ntdll-WRITECOPY depends on that."
fi
enable_ntdll_User_Shared_Data=1
fi
if test "$enable_ntdll_NtQueryEaFile" -eq 1; then
if test "$enable_ntdll_Junction_Points" -gt 1; then
abort "Patchset ntdll-Junction_Points disabled, but ntdll-NtQueryEaFile depends on that."
@ -5012,50 +5001,6 @@ if test "$enable_ntdll_Serial_Port_Detection" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-WRITECOPY
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime, ntdll-Hide_Wine_Exports,
# | ntdll-User_Shared_Data
# |
# | This patchset fixes the following Wine bugs:
# | * [#29384] Multiple applications expect correct handling of WRITECOPY memory protection (Voobly fails to launch Age of
# | Empires II, MSYS2)
# |
# | Modified files:
# | * dlls/advapi32/crypt.c, dlls/advapi32/tests/security.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/server.c,
# | dlls/ntdll/signal_arm.c, dlls/ntdll/signal_arm64.c, dlls/ntdll/signal_i386.c, dlls/ntdll/signal_powerpc.c,
# | dlls/ntdll/signal_x86_64.c, dlls/ntdll/thread.c, dlls/ntdll/virtual.c
# |
if test "$enable_ntdll_WRITECOPY" -eq 1; then
patch_apply ntdll-WRITECOPY/0001-ntdll-Trigger-write-watches-before-passing-userdata-.patch
patch_apply ntdll-WRITECOPY/0002-advapi-Trigger-write-watches-before-passing-userdata.patch
patch_apply ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch
patch_apply ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch
(
printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Trigger write watches before passing userdata pointer to wait_reply.", 1 },';
printf '%s\n' '+ { "Sebastian Lackner", "advapi: Trigger write watches before passing userdata pointer to read syscall.", 1 },';
printf '%s\n' '+ { "Michael Müller", "ntdll: Setup a temporary signal handler during process startup to handle page faults.", 2 },';
printf '%s\n' '+ { "Michael Müller", "ntdll: Properly handle PAGE_WRITECOPY protection.", 5 },';
) >> "$patchlist"
fi
# Patchset ntdll-Signal_Handler
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime, ntdll-Hide_Wine_Exports,
# | ntdll-User_Shared_Data, ntdll-WRITECOPY
# |
# | Modified files:
# | * dlls/ntdll/signal_i386.c
# |
if test "$enable_ntdll_Signal_Handler" -eq 1; then
patch_apply ntdll-Signal_Handler/0001-ntdll-Avoid-stack-protector-frame-in-signal-handler-.patch
(
printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Avoid stack protector frame in signal handler functions.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-Status_Mapping
# |
# | Modified files:
@ -5197,6 +5142,34 @@ if test "$enable_ntdll_User_shared_data_fields" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-WRITECOPY
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime, ntdll-Hide_Wine_Exports,
# | ntdll-User_Shared_Data
# |
# | This patchset fixes the following Wine bugs:
# | * [#29384] Multiple applications expect correct handling of WRITECOPY memory protection (Voobly fails to launch Age of
# | Empires II, MSYS2)
# |
# | Modified files:
# | * dlls/advapi32/crypt.c, dlls/advapi32/tests/security.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/server.c,
# | dlls/ntdll/signal_arm.c, dlls/ntdll/signal_arm64.c, dlls/ntdll/signal_i386.c, dlls/ntdll/signal_powerpc.c,
# | dlls/ntdll/signal_x86_64.c, dlls/ntdll/thread.c, dlls/ntdll/virtual.c
# |
if test "$enable_ntdll_WRITECOPY" -eq 1; then
patch_apply ntdll-WRITECOPY/0001-ntdll-Trigger-write-watches-before-passing-userdata-.patch
patch_apply ntdll-WRITECOPY/0002-advapi-Trigger-write-watches-before-passing-userdata.patch
patch_apply ntdll-WRITECOPY/0003-ntdll-Setup-a-temporary-signal-handler-during-proces.patch
patch_apply ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch
(
printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Trigger write watches before passing userdata pointer to wait_reply.", 1 },';
printf '%s\n' '+ { "Sebastian Lackner", "advapi: Trigger write watches before passing userdata pointer to read syscall.", 1 },';
printf '%s\n' '+ { "Michael Müller", "ntdll: Setup a temporary signal handler during process startup to handle page faults.", 2 },';
printf '%s\n' '+ { "Michael Müller", "ntdll: Properly handle PAGE_WRITECOPY protection.", 5 },';
) >> "$patchlist"
fi
# Patchset ntdll-Zero_mod_name
# |
# | Modified files: