Fix issue in ws2_32-WriteWatches patch which can cause exceptions on the signal stack.

This commit is contained in:
Sebastian Lackner
2015-01-03 21:16:10 +01:00
parent 90c12baba2
commit 4c95b9d483
11 changed files with 288 additions and 36 deletions

View File

@@ -1,4 +1,4 @@
From 482071f086b4e93d8bd9e1c57652478bfcd98ecf Mon Sep 17 00:00:00 2001
From e4f9424f025aebdbcd96a6f0eb2c39f479b4eda7 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 4 Oct 2014 02:35:44 +0200
Subject: ntdll: Trigger write watches before passing userdata pointer to
@@ -28,5 +28,5 @@ index aabda4f..4d5d4ba 100644
ret = send_request( req );
if (!ret) ret = wait_reply( req );
--
2.1.1
2.2.1

View File

@@ -1,4 +1,4 @@
From 1eeeb531c7e0188ecf7f39166dfe299fef2c7116 Mon Sep 17 00:00:00 2001
From adcf73538130589e5c4831ec5a8fdd37a6408824 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 4 Oct 2014 02:38:27 +0200
Subject: advapi: Trigger write watches before passing userdata pointer to read
@@ -23,5 +23,5 @@ index b2be5e3..50502b8 100644
close(dev_random);
return TRUE;
--
2.1.1
2.2.1

View File

@@ -1,4 +1,4 @@
From cbb34fc193e2b2236ef7fec301e6d34be39d92aa Mon Sep 17 00:00:00 2001
From 91cdcf5f955d3cbd7a22531054448dc01c171e66 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 4 Oct 2014 02:53:22 +0200
Subject: ntdll: Setup a temporary signal handler during process startup to
@@ -15,7 +15,7 @@ Subject: ntdll: Setup a temporary signal handler during process startup to
7 files changed, 73 insertions(+)
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 4370084..53e6b55 100644
index e56e78b..a33f7a0 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -67,6 +67,7 @@ extern NTSTATUS signal_alloc_thread( TEB **teb ) DECLSPEC_HIDDEN;
@@ -61,10 +61,10 @@ index 8c8f7af..483bc85 100644
/**********************************************************************
* __wine_enter_vm86 (NTDLL.@)
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 12aa5a4..d24e3bf 100644
index de55c31..49222f4 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -1949,6 +1949,30 @@ static void usr2_handler( int signal, siginfo_t *siginfo, void *sigcontext )
@@ -2035,6 +2035,30 @@ static void usr2_handler( int signal, siginfo_t *siginfo, void *sigcontext )
/**********************************************************************
@@ -95,7 +95,7 @@ index 12aa5a4..d24e3bf 100644
* segv_handler
*
* Handler for SIGSEGV and related errors.
@@ -2371,6 +2395,29 @@ void signal_init_process(void)
@@ -2457,6 +2481,29 @@ void signal_init_process(void)
exit(1);
}
@@ -172,5 +172,5 @@ index c8461b0..a2937c2 100644
/* reserve space for shared user data */
--
2.1.1
2.2.1

View File

@@ -1,18 +1,18 @@
From 0596c2b03fa72a5159fa5a9df3e909e925d6144f Mon Sep 17 00:00:00 2001
From 9e5ef34f4cbfb381528750caabd4ba6a3da439f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 4 Oct 2014 02:56:08 +0200
Subject: ntdll: Properly handle PAGE_WRITECOPY protection. (try 4)
Subject: ntdll: Properly handle PAGE_WRITECOPY protection. (try 5)
---
dlls/kernel32/tests/virtual.c | 12 ++----------
dlls/ntdll/virtual.c | 16 +++++++++++++---
2 files changed, 15 insertions(+), 13 deletions(-)
dlls/ntdll/virtual.c | 26 +++++++++++++++++++-------
2 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 73b753e..5797805 100644
index 75e91d5..3520546 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -2786,11 +2786,7 @@ todo_wine
@@ -2929,11 +2929,7 @@ todo_wine
SetLastError(0xdeadbeef);
ret = VirtualQuery(base, &info, sizeof(info));
ok(ret, "VirtualQuery failed %d\n", GetLastError());
@@ -25,7 +25,7 @@ index 73b753e..5797805 100644
}
}
else
@@ -2804,11 +2800,7 @@ todo_wine
@@ -2947,11 +2943,7 @@ todo_wine
SetLastError(0xdeadbeef);
ret = VirtualProtect(base, si.dwPageSize, PAGE_NOACCESS, &old_prot);
ok(ret, "%d: VirtualProtect error %d\n", i, GetLastError());
@@ -39,7 +39,7 @@ index 73b753e..5797805 100644
UnmapViewOfFile(base);
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 4c4c05d..d26fe26 100644
index 17792e1..36d8836 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -179,8 +179,13 @@ static int VIRTUAL_GetUnixProt( BYTE vprot )
@@ -78,6 +78,27 @@ index 4c4c05d..d26fe26 100644
/* ignore fault if page is writable now */
if (VIRTUAL_GetUnixProt( *vprot ) & PROT_WRITE) ret = STATUS_SUCCESS;
}
@@ -1748,14 +1758,16 @@ SIZE_T CDECL wine_uninterrupted_write_memory( void *addr, const void *buffer, SI
* handle guard pages here. */
if (!(VIRTUAL_GetUnixProt( *p ) & PROT_WRITE))
{
- if (!(view->protect & VPROT_WRITEWATCH))
- break;
-
- if (*p & VPROT_WRITEWATCH)
+ if ((view->protect & VPROT_WRITEWATCH) && (*p & VPROT_WRITEWATCH))
{
*p &= ~VPROT_WRITEWATCH;
VIRTUAL_SetProt( view, page, page_size, *p );
}
+ if (*p & VPROT_WRITECOPY)
+ {
+ *p = (*p & ~VPROT_WRITECOPY) | VPROT_WRITE;
+ VIRTUAL_SetProt( view, page, page_size, *p );
+ }
/* ignore fault if page is writable now */
if (!(VIRTUAL_GetUnixProt( *p ) & PROT_WRITE))
break;
--
2.1.2
2.2.1

View File

@@ -1,4 +1,4 @@
From 566ff0e978e59354160a1d2cdde79cb9e5ead244 Mon Sep 17 00:00:00 2001
From 3d29cd7c6feabae6c5ae5941f49c663b1fb78ab8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 4 Oct 2014 03:22:09 +0200
Subject: ntdll: Only enable true WRITECOPY protection when a special
@@ -9,7 +9,7 @@ Subject: ntdll: Only enable true WRITECOPY protection when a special
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index d26fe26..02e32fb 100644
index 36d8836..0c7ae29 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -166,6 +166,21 @@ static const char *VIRTUAL_GetProtStr( BYTE prot )
@@ -50,5 +50,5 @@ index d26fe26..02e32fb 100644
/* FIXME: Architecture needs implementation of signal_init_early. */
if (vprot & VPROT_WRITECOPY) prot |= PROT_WRITE | PROT_READ;
--
2.1.2
2.2.1

View File

@@ -1 +1,2 @@
Fixes: [29384] Voobly expects correct handling of WRITECOPY memory protection
Depends: ws2_32-WriteWatches