This is needed by x64 chromium sandbox for >= win8. Not doing anything but returning true is enough to make it work, though security won't be perfect.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45643 Signed-off-by: Fabian Maurer dark.shadow4@web.de --- ...api-ms-win-core-processthreads-l1-1-1.spec | 2 +- ...api-ms-win-core-processthreads-l1-1-2.spec | 2 +- dlls/kernel32/kernel32.spec | 1 + dlls/kernel32/process.c | 10 ++++++++++ dlls/kernelbase/kernelbase.spec | 2 +- include/winnt.h | 19 +++++++++++++++++++ 6 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec b/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec index ebbe55fe68..616fa63909 100644 --- a/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec +++ b/dlls/api-ms-win-core-processthreads-l1-1-1/api-ms-win-core-processthreads-l1-1-1.spec @@ -44,7 +44,7 @@ @ stdcall ResumeThread(long) kernel32.ResumeThread @ stdcall SetPriorityClass(long long) kernel32.SetPriorityClass @ stdcall SetProcessAffinityUpdateMode(long long) kernel32.SetProcessAffinityUpdateMode -@ stub SetProcessMitigationPolicy +@ stdcall SetProcessMitigationPolicy(long ptr long) kernel32.SetProcessMitigationPolicy @ stdcall SetProcessShutdownParameters(long long) kernel32.SetProcessShutdownParameters @ stdcall SetThreadContext(long ptr) kernel32.SetThreadContext @ stdcall SetThreadIdealProcessorEx(long ptr ptr) kernel32.SetThreadIdealProcessorEx diff --git a/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec b/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec index db94c2e5e7..8de6c5b66c 100644 --- a/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec +++ b/dlls/api-ms-win-core-processthreads-l1-1-2/api-ms-win-core-processthreads-l1-1-2.spec @@ -49,7 +49,7 @@ @ stdcall ResumeThread(long) kernel32.ResumeThread @ stdcall SetPriorityClass(long long) kernel32.SetPriorityClass @ stdcall SetProcessAffinityUpdateMode(long long) kernel32.SetProcessAffinityUpdateMode -@ stub SetProcessMitigationPolicy +@ stdcall SetProcessMitigationPolicy(long ptr long) kernel32.SetProcessMitigationPolicy @ stdcall SetProcessPriorityBoost(long long) kernel32.SetProcessPriorityBoost @ stdcall SetProcessShutdownParameters(long long) kernel32.SetProcessShutdownParameters @ stdcall SetThreadContext(long ptr) kernel32.SetThreadContext diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index 3060896daa..c53276c70a 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -1428,6 +1428,7 @@ @ stdcall SetProcessAffinityMask(long long) @ stdcall SetProcessAffinityUpdateMode(long long) @ stdcall SetProcessDEPPolicy(long) +@ stdcall SetProcessMitigationPolicy(long ptr long) # @ stub SetProcessPreferredUILanguages @ stdcall SetProcessPriorityBoost(long long) @ stdcall SetProcessShutdownParameters(long long) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 5aa245cf1a..320b7cfa55 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -4389,3 +4389,13 @@ BOOL WINAPI BaseFlushAppcompatCache(void) SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; } + +/********************************************************************** + * SetProcessMitigationPolicy (KERNEL32.@) + */ +BOOL WINAPI SetProcessMitigationPolicy(PROCESS_MITIGATION_POLICY migitation_policy, void *buffer, SIZE_T length) +{ + FIXME("(%d, %p, %lu): stub\n", migitation_policy, buffer, length); + + return TRUE; +} diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index cae825defd..5865ee7c48 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -1456,7 +1456,7 @@ # @ stub SetProcessDefaultCpuSets # @ stub SetProcessGroupAffinity # @ stub SetProcessInformation -# @ stub SetProcessMitigationPolicy +@ stdcall SetProcessMitigationPolicy(long ptr long) kernel32.SetProcessMitigationPolicy # @ stub SetProcessPreferredUILanguages @ stdcall SetProcessPriorityBoost(long long) kernel32.SetProcessPriorityBoost @ stdcall SetProcessShutdownParameters(long long) kernel32.SetProcessShutdownParameters diff --git a/include/winnt.h b/include/winnt.h index 7f822c4aec..e9e5989f24 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -6273,6 +6273,25 @@ typedef enum _RTL_UMS_SCHEDULER_REASON
typedef void (CALLBACK *PRTL_UMS_SCHEDULER_ENTRY_POINT)(RTL_UMS_SCHEDULER_REASON,ULONG_PTR,PVOID);
+typedef enum _PROCESS_MITIGATION_POLICY { + ProcessDEPPolicy, + ProcessASLRPolicy, + ProcessDynamicCodePolicy, + ProcessStrictHandleCheckPolicy, + ProcessSystemCallDisablePolicy, + ProcessMitigationOptionsMask, + ProcessExtensionPointDisablePolicy, + ProcessControlFlowGuardPolicy, + ProcessSignaturePolicy, + ProcessFontDisablePolicy, + ProcessImageLoadPolicy, + ProcessSystemCallFilterPolicy, + ProcessPayloadRestrictionPolicy, + ProcessChildProcessPolicy, + ProcessSideChannelIsolationPolicy, + MaxProcessMitigationPolicy +} PROCESS_MITIGATION_POLICY, *PPROCESS_MITIGATION_POLICY; + #ifdef __cplusplus } #endif
In RtlDestroyHeap critSection.DebugInfo->Spare[0] is always set to NULL, this will crash if we deleted the debug info already
Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/ntdll/heap.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 44d49bca99..9eed7e6baa 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -977,8 +977,6 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, LPVOID address, DWORD flags, NtDuplicateObject( NtCurrentProcess(), sem, NtCurrentProcess(), &sem, 0, 0, DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE ); heap->critSection.LockSemaphore = sem; - RtlFreeHeap( processHeap, 0, heap->critSection.DebugInfo ); - heap->critSection.DebugInfo = NULL; } }
Fabian Maurer dark.shadow4@web.de writes:
In RtlDestroyHeap critSection.DebugInfo->Spare[0] is always set to NULL, this will crash if we deleted the debug info already
Destroying a shared heap is not a good idea, where do you see that happening?
On Mittwoch, 15. August 2018 20:58:05 CEST Alexandre Julliard wrote:
Fabian Maurer dark.shadow4@web.de writes:
In RtlDestroyHeap critSection.DebugInfo->Spare[0] is always set to NULL, this will crash if we deleted the debug info already
Destroying a shared heap is not a good idea, where do you see that happening?
It's one of those borderline sane behaviors I see the chromium sandbox using. On Win10 they (for security reasons) sever the connection to csrss by closing the "ALPC Port". Then they close the shared heap to avoid problems.
https://github.com/chromium/chromium/blob/ 85a03bc295a24bcad455ceb311942bf9a5bc604e/sandbox/win/src/target_services.cc#L55
// Currently, this step requires closing a heap that this shared with csrss.exe. // Closing the ALPC Port handle to csrss.exe leaves this heap in an invalid // state. This causes problems if anyone enumerates the heap.
Regards, Fabian Maurer
Also see bug https://bugs.winehq.org/show_bug.cgi?id=45647,
chromium does in fact delete this shared csrss heap, and on win10 that works just fine. So I assume it should be possible on WINE too, no?
Regards, Fabian Maurer
Fabian Maurer dark.shadow4@web.de writes:
Also see bug https://bugs.winehq.org/show_bug.cgi?id=45647,
chromium does in fact delete this shared csrss heap, and on win10 that works just fine. So I assume it should be possible on WINE too, no?
We could implement deleting a shared heap, but since we don't have a csrss heap I'm not sure I see the point. To make chromium happy, creating a fake non-shared heap should be sufficient.
On Donnerstag, 16. August 2018 10:25:23 CEST Alexandre Julliard wrote:
Fabian Maurer dark.shadow4@web.de writes:
Also see bug https://bugs.winehq.org/show_bug.cgi?id=45647,
chromium does in fact delete this shared csrss heap, and on win10 that works just fine. So I assume it should be possible on WINE too, no?
We could implement deleting a shared heap, but since we don't have a csrss heap I'm not sure I see the point. To make chromium happy, creating a fake non-shared heap should be sufficient.
Ah, so the problem is only the shared part! If it's like that, then a non shared heap would be the solution.
Another issue: Chromium assumes the structure behind the HANDLE it gets, casting it to HEAP*. Now, wine heap doesn't have the same structure as Win10 heap, so that doesn't work. I implemented a fake Win10 heap to return on GetProcessHeaps, however, I somewhat doubt this is acceptable for wine. How would you advise to address this issue?
Regards, Fabian Maurer
Fabian Maurer dark.shadow4@web.de writes:
On Donnerstag, 16. August 2018 10:25:23 CEST Alexandre Julliard wrote:
Fabian Maurer dark.shadow4@web.de writes:
Also see bug https://bugs.winehq.org/show_bug.cgi?id=45647,
chromium does in fact delete this shared csrss heap, and on win10 that
works just fine. So I assume it should be possible on WINE too, no?
We could implement deleting a shared heap, but since we don't have a
csrss heap I'm not sure I see the point. To make chromium happy,
creating a fake non-shared heap should be sufficient.
Ah, so the problem is only the shared part! If it's like that, then a non shared heap would be the solution.
Another issue:
Chromium assumes the structure behind the HANDLE it gets, casting it to HEAP*.
Now, wine heap doesn't have the same structure as Win10 heap, so that doesn't work. I implemented a fake Win10 heap to return on GetProcessHeaps, however, I somewhat doubt this is acceptable for wine. How would you advise to address this issue?
You can adapt the existing structure, if tests demonstrate that this is reasonably constant across versions.
On Donnerstag, 16. August 2018 11:22:49 CEST Alexandre Julliard wrote:
You can adapt the existing structure, if tests demonstrate that this is reasonably constant across versions.
It's not, I ran a simple test on the testbot - and the structure seems to be different across a lot of version. There's at least a huge difference between win8/win10 and win7/XP. We'd need a different structure for a different windows version if we want to enable programs to work with it.
Regards, Fabian Maurer
This is needed by x64 chromium sandbox for >= win10.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45644 Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/kernel32/process.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 320b7cfa55..221822ef46 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -4216,8 +4216,17 @@ BOOL WINAPI UpdateProcThreadAttribute(struct _PROC_THREAD_ATTRIBUTE_LIST *list, } break;
+ case PROC_THREAD_ATTRIBUTE_CHILD_PROCESS_POLICY: + if (size != sizeof(DWORD) && size != sizeof(DWORD64)) + { + SetLastError(ERROR_BAD_LENGTH); + return FALSE; + } + break; + default: SetLastError(ERROR_NOT_SUPPORTED); + FIXME("Unhandled attribute number %lu\n", attr & PROC_THREAD_ATTRIBUTE_NUMBER); return FALSE; }
needed for x32 win7 chrome and chromium
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45648 Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/kernel32/process.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 221822ef46..1e23cf8bc1 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -4224,6 +4224,14 @@ BOOL WINAPI UpdateProcThreadAttribute(struct _PROC_THREAD_ATTRIBUTE_LIST *list, } break;
+ case PROC_THREAD_ATTRIBUTE_MIGITATION_POLICY: + if (size != sizeof(DWORD) && size != sizeof(DWORD64) && size != sizeof(DWORD64) * 2) + { + SetLastError(ERROR_BAD_LENGTH); + return FALSE; + } + break; + default: SetLastError(ERROR_NOT_SUPPORTED); FIXME("Unhandled attribute number %lu\n", attr & PROC_THREAD_ATTRIBUTE_NUMBER);
This is required by chromium x64 sandbox >=win8 chrome for some reason is not affected
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45646 Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/ntdll/misc.c | 9 +++++++++ dlls/ntdll/ntdll.spec | 1 + 2 files changed, 10 insertions(+)
diff --git a/dlls/ntdll/misc.c b/dlls/ntdll/misc.c index 7ccaa0ed7f..ca6029b847 100644 --- a/dlls/ntdll/misc.c +++ b/dlls/ntdll/misc.c @@ -492,3 +492,12 @@ void WINAPI DbgUiRemoteBreakin( void *arg ) { FIXME("stub\n"); } + +NTSTATUS WINAPI NtCreateLowBoxToken(HANDLE *token_handle, HANDLE existing_token_handle, ACCESS_MASK desired_access, + OBJECT_ATTRIBUTES *object_attributes, SID *package_sid, ULONG capability_count, + SID_AND_ATTRIBUTES *capabilities, ULONG handle_count, HANDLE *handle) +{ + /* We need to return a NULL handle since later it will be passed to CloseHandle and that must not fail */ + *token_handle = NULL; + return STATUS_SUCCESS; +} diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index d321c44d4f..003e4f9d00 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -142,6 +142,7 @@ @ stdcall NtCreateKey(ptr long ptr long ptr long ptr) @ stdcall NtCreateKeyTransacted(ptr long ptr long ptr long long ptr) @ stdcall NtCreateKeyedEvent(ptr long ptr long) +@ stdcall NtCreateLowBoxToken(ptr long long ptr ptr long ptr long ptr) @ stdcall NtCreateMailslotFile(ptr long ptr ptr long long long ptr) @ stdcall NtCreateMutant(ptr long ptr long) @ stdcall NtCreateNamedPipeFile(ptr long ptr ptr long long long long long long long long long ptr)