ntdll-Builtin_Prot: Only handle read faults.

This commit is contained in:
Sebastian Lackner 2017-06-19 04:01:59 +02:00
parent 866e79688c
commit 0a16521c7e
6 changed files with 65 additions and 13 deletions

View File

@ -1,4 +1,4 @@
From 27834dc400a876c75de4dce156f25ce07ec3f78b Mon Sep 17 00:00:00 2001
From 06d43d3d4ee46e7e6f70b43cca3b10cf09a474a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 1 Jun 2017 06:04:53 +0200
Subject: ntdll: Fix holes in ELF mappings.
@ -10,14 +10,14 @@ Based on a patch by Andrew Wesie.
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 387379a5882..55c15690f70 100644
index 2889e8babc..a6c4ac480f 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1526,6 +1526,12 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack )
if (VIRTUAL_GetUnixProt( *vprot ) & PROT_READ) ret = STATUS_SUCCESS;
else update_shared_data = FALSE;
}
+ else if ((view->protect & VPROT_SYSTEM) && (VIRTUAL_GetUnixProt( *vprot ) & PROT_READ))
+ else if (!err && (view->protect & VPROT_SYSTEM) && (VIRTUAL_GetUnixProt( *vprot ) & PROT_READ))
+ {
+ /* ignore fault if page can be made readable */
+ if (VIRTUAL_SetProt( view, page, page_size, *vprot )) ret = STATUS_SUCCESS;
@ -27,7 +27,7 @@ index 387379a5882..55c15690f70 100644
{
VIRTUAL_SetProt( view, page, page_size, *vprot & ~VPROT_GUARD );
diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c
index e35a7b694cb..e7af5bc61cc 100644
index e35a7b694c..e7af5bc61c 100644
--- a/dlls/psapi/tests/psapi_main.c
+++ b/dlls/psapi/tests/psapi_main.c
@@ -152,6 +152,7 @@ static void test_EnumProcessModules(void)

View File

@ -1,2 +1,3 @@
Fixes: Fix holes in ELF mappings
Depends: ntdll-User_Shared_Data
Depends: ntdll-x86_64_ExceptionInformation

View File

@ -1,4 +1,4 @@
From 51f9291677535a3246a7727c1563fe62e9a5756e Mon Sep 17 00:00:00 2001
From e313cf4b443d63f2934062336472454224373e81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 5 May 2017 05:40:50 +0200
Subject: ntdll: Create thread to update user_shared_data time values when
@ -13,7 +13,7 @@ Subject: ntdll: Create thread to update user_shared_data time values when
5 files changed, 117 insertions(+), 9 deletions(-)
diff --git a/dlls/kernel32/cpu.c b/dlls/kernel32/cpu.c
index 2e0e79f8e8d..d53488c7652 100644
index 2e0e79f8e8..d53488c765 100644
--- a/dlls/kernel32/cpu.c
+++ b/dlls/kernel32/cpu.c
@@ -46,7 +46,7 @@
@ -35,7 +35,7 @@ index 2e0e79f8e8d..d53488c7652 100644
return FALSE;
}
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index f4e002a0609..ac1ab2d2099 100644
index f4e002a060..ac1ab2d209 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -3191,6 +3191,37 @@ static void start_process( void *arg )
@ -85,7 +85,7 @@ index f4e002a0609..ac1ab2d2099 100644
LdrQueryImageFileExecutionOptions( &peb->ProcessParameters->ImagePathName, globalflagW,
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 6e516123806..9d066d637c7 100644
index 6e51612380..9d066d637c 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -176,6 +176,9 @@ extern void VIRTUAL_SetForceExec( BOOL enable ) DECLSPEC_HIDDEN;
@ -99,7 +99,7 @@ index 6e516123806..9d066d637c7 100644
/* completion */
extern NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue,
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 9399fbcb5c6..cc65f3b48d6 100644
index 9399fbcb5c..cc65f3b48d 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -43,6 +43,7 @@
@ -208,7 +208,7 @@ index 9399fbcb5c6..cc65f3b48d6 100644
/* allocate and initialize the PEB */
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index ee9c8d0195d..387379a5882 100644
index ee9c8d0195..2889e8babc 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1497,6 +1497,7 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack )
@ -223,7 +223,7 @@ index ee9c8d0195d..387379a5882 100644
/* ignore fault if page is writable now */
if (VIRTUAL_GetUnixProt( *vprot ) & PROT_WRITE) ret = STATUS_SUCCESS;
}
+ else if (page == user_shared_data_external)
+ else if (!err && page == user_shared_data_external)
+ {
+ if (!(*vprot & VPROT_READ))
+ {

View File

@ -1,2 +1,3 @@
Fixes: [29168] Update user shared data at realtime
Depends: ntdll-Hide_Wine_Exports
Depends: ntdll-x86_64_ExceptionInformation

View File

@ -0,0 +1,25 @@
From 5b14b1326af51900975be9749fd2319643cde2d9 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 19 Jun 2017 03:55:14 +0200
Subject: ntdll: Set proper ExceptionInformation[0] for x86_64 exceptions.
---
dlls/ntdll/signal_x86_64.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index 86034c00a5..365e3799d4 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -2663,7 +2663,7 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext )
case TRAP_x86_PAGEFLT: /* Page fault */
rec->ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
rec->NumberParameters = 2;
- rec->ExceptionInformation[0] = (ERROR_sig(ucontext) & 2) != 0;
+ rec->ExceptionInformation[0] = (ERROR_sig(ucontext) >> 1) & 0x09;
rec->ExceptionInformation[1] = (ULONG_PTR)siginfo->si_addr;
break;
case TRAP_x86_ALIGNFLT: /* Alignment check exception */
--
2.13.1

View File

@ -285,6 +285,7 @@ patch_enable_all ()
enable_ntdll_Zero_mod_name="$1"
enable_ntdll__aulldvrm="$1"
enable_ntdll_call_thread_func_wrapper="$1"
enable_ntdll_x86_64_ExceptionInformation="$1"
enable_ntoskrnl_DriverTest="$1"
enable_ntoskrnl_Stubs="$1"
enable_nvapi_Stub_DLL="$1"
@ -1100,6 +1101,9 @@ patch_enable ()
ntdll-call_thread_func_wrapper)
enable_ntdll_call_thread_func_wrapper="$2"
;;
ntdll-x86_64_ExceptionInformation)
enable_ntdll_x86_64_ExceptionInformation="$2"
;;
ntoskrnl-DriverTest)
enable_ntoskrnl_DriverTest="$2"
;;
@ -2459,14 +2463,22 @@ if test "$enable_ntdll_Builtin_Prot" -eq 1; then
if test "$enable_ntdll_User_Shared_Data" -gt 1; then
abort "Patchset ntdll-User_Shared_Data disabled, but ntdll-Builtin_Prot depends on that."
fi
if test "$enable_ntdll_x86_64_ExceptionInformation" -gt 1; then
abort "Patchset ntdll-x86_64_ExceptionInformation disabled, but ntdll-Builtin_Prot depends on that."
fi
enable_ntdll_User_Shared_Data=1
enable_ntdll_x86_64_ExceptionInformation=1
fi
if test "$enable_ntdll_User_Shared_Data" -eq 1; then
if test "$enable_ntdll_Hide_Wine_Exports" -gt 1; then
abort "Patchset ntdll-Hide_Wine_Exports disabled, but ntdll-User_Shared_Data depends on that."
fi
if test "$enable_ntdll_x86_64_ExceptionInformation" -gt 1; then
abort "Patchset ntdll-x86_64_ExceptionInformation disabled, but ntdll-User_Shared_Data depends on that."
fi
enable_ntdll_Hide_Wine_Exports=1
enable_ntdll_x86_64_ExceptionInformation=1
fi
if test "$enable_ntdll_Hide_Wine_Exports" -eq 1; then
@ -5668,10 +5680,22 @@ if test "$enable_ntdll_Hide_Wine_Exports" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-x86_64_ExceptionInformation
# |
# | Modified files:
# | * dlls/ntdll/signal_x86_64.c
# |
if test "$enable_ntdll_x86_64_ExceptionInformation" -eq 1; then
patch_apply ntdll-x86_64_ExceptionInformation/0001-ntdll-Set-proper-ExceptionInformation-0-for-x86_64-e.patch
(
printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Set proper ExceptionInformation[0] for x86_64 exceptions.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-User_Shared_Data
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-Attach_Process_DLLs, ntdll-ThreadTime, ntdll-Hide_Wine_Exports
# | * ntdll-Attach_Process_DLLs, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, ntdll-x86_64_ExceptionInformation
# |
# | This patchset fixes the following Wine bugs:
# | * [#29168] Update user shared data at realtime
@ -5696,7 +5720,8 @@ fi
# Patchset ntdll-Builtin_Prot
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-Attach_Process_DLLs, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, ntdll-User_Shared_Data
# | * ntdll-Attach_Process_DLLs, ntdll-ThreadTime, ntdll-Hide_Wine_Exports, ntdll-x86_64_ExceptionInformation, ntdll-
# | User_Shared_Data
# |
# | Modified files:
# | * dlls/ntdll/virtual.c, dlls/psapi/tests/psapi_main.c