From 876024f44fde737fcf43e8b0cb8e75575e65d449 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Thu, 17 Jun 2021 10:06:41 +1000 Subject: [PATCH] Rebase against afd5550b07f6d55e56738f61d829085d6bc82888. --- ...t-the-critical-section-fast-path-on-.patch | 23 +++++---------- ...dll-Support-x86_64-syscall-emulation.patch | 28 +++++++++---------- patches/patchinstall.sh | 2 +- ...002-shell32-Implement-the-runas-verb.patch | 19 ++++++------- staging/upstream-commit | 2 +- 5 files changed, 32 insertions(+), 42 deletions(-) diff --git a/patches/ntdll-NtAlertThreadByThreadId/0009-ntdll-Reimplement-the-critical-section-fast-path-on-.patch b/patches/ntdll-NtAlertThreadByThreadId/0009-ntdll-Reimplement-the-critical-section-fast-path-on-.patch index 7ec7a71d..a81bf708 100644 --- a/patches/ntdll-NtAlertThreadByThreadId/0009-ntdll-Reimplement-the-critical-section-fast-path-on-.patch +++ b/patches/ntdll-NtAlertThreadByThreadId/0009-ntdll-Reimplement-the-critical-section-fast-path-on-.patch @@ -1,4 +1,4 @@ -From 7dccf4db15b800a7781fea24b357b5c804802993 Mon Sep 17 00:00:00 2001 +From acfa81780932de0b511e0454056ad82d1fcccc98 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 31 Aug 2020 23:38:09 -0500 Subject: [PATCH] ntdll: Reimplement the critical section fast path on top of @@ -10,8 +10,8 @@ Signed-off-by: Zebediah Figura dlls/ntdll/unix/loader.c | 3 - dlls/ntdll/unix/sync.c | 109 --------------------------------- dlls/ntdll/unix/unix_private.h | 3 - - dlls/ntdll/unixlib.h | 5 +- - 5 files changed, 24 insertions(+), 131 deletions(-) + dlls/ntdll/unixlib.h | 3 - + 5 files changed, 23 insertions(+), 130 deletions(-) diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c index c73fb09da47..6edf104c5e9 100644 @@ -83,7 +83,7 @@ index c73fb09da47..6edf104c5e9 100644 return ret; } diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c -index e9942c0ceeb..5abdc1dc545 100644 +index b51d726c5e4..063f48148d7 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1822,9 +1822,6 @@ static struct unix_funcs unix_funcs = @@ -217,10 +217,10 @@ index 5e49593fa4a..84f7c937be3 100644 /* Futex-based SRW lock implementation: diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h -index a721a29dc5a..c9793da8ec1 100644 +index 9b27dc7ee7d..7460387c4bb 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h -@@ -104,9 +104,6 @@ extern NTSTATUS (WINAPI *pKiUserExceptionDispatcher)(EXCEPTION_RECORD*,CONTEXT*) +@@ -95,9 +95,6 @@ extern NTSTATUS (WINAPI *pKiUserExceptionDispatcher)(EXCEPTION_RECORD*,CONTEXT*) extern void (WINAPI *pLdrInitializeThunk)(CONTEXT*,void**,ULONG_PTR,ULONG_PTR) DECLSPEC_HIDDEN; extern void (WINAPI *pRtlUserThreadStart)( PRTL_THREAD_START_ROUTINE entry, void *arg ) DECLSPEC_HIDDEN; extern void (WINAPI *p__wine_ctrl_routine)(void *) DECLSPEC_HIDDEN; @@ -231,18 +231,9 @@ index a721a29dc5a..c9793da8ec1 100644 extern NTSTATUS CDECL fast_RtlAcquireSRWLockExclusive( RTL_SRWLOCK *lock ) DECLSPEC_HIDDEN; extern NTSTATUS CDECL fast_RtlTryAcquireSRWLockShared( RTL_SRWLOCK *lock ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h -index f5462125874..ca668995562 100644 +index 10b0f57fbed..37a0e2da83c 100644 --- a/dlls/ntdll/unixlib.h +++ b/dlls/ntdll/unixlib.h -@@ -26,7 +26,7 @@ - struct _DISPATCHER_CONTEXT; - - /* increment this when you change the function table */ --#define NTDLL_UNIXLIB_VERSION 122 -+#define NTDLL_UNIXLIB_VERSION 123 - - struct unix_funcs - { @@ -40,9 +40,6 @@ struct unix_funcs LONGLONG (WINAPI *RtlGetSystemTimePrecise)(void); diff --git a/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch b/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch index 6d06577a..cca33479 100644 --- a/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch +++ b/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch @@ -1,4 +1,4 @@ -From 7744cca9f58990ee47b74f4fa967eb99f3dee862 Mon Sep 17 00:00:00 2001 +From 00b8fb5b21f01a3279c108fd15d587dc9b57c799 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 14 Jul 2020 15:00:34 +0300 Subject: [PATCH] ntdll: Support x86_64 syscall emulation. @@ -10,7 +10,7 @@ Subject: [PATCH] ntdll: Support x86_64 syscall emulation. 3 files changed, 120 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index 8c74532dabc..36d2295c1ca 100644 +index ade04399af0..3dabc0d33d1 100644 --- a/configure.ac +++ b/configure.ac @@ -477,6 +477,7 @@ AC_CHECK_HEADERS(\ @@ -22,7 +22,7 @@ index 8c74532dabc..36d2295c1ca 100644 linux/types.h \ linux/ucdrom.h \ diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c -index 4845d3dd5f4..9a80cafeadd 100644 +index c36699589d9..e8c3099ae14 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -28,6 +28,7 @@ @@ -47,7 +47,7 @@ index 4845d3dd5f4..9a80cafeadd 100644 #define NONAMELESSUNION #define NONAMELESSSTRUCT #include "ntstatus.h" -@@ -2075,6 +2083,114 @@ static inline DWORD is_privileged_instr( CONTEXT *context ) +@@ -2107,6 +2115,114 @@ static inline DWORD is_privileged_instr( CONTEXT *context ) return 0; } @@ -162,7 +162,7 @@ index 4845d3dd5f4..9a80cafeadd 100644 /*********************************************************************** * handle_interrupt -@@ -2560,6 +2676,7 @@ void signal_init_process(void) +@@ -2623,6 +2739,7 @@ void signal_init_process(void) if (sigaction( SIGSEGV, &sig_act, NULL ) == -1) goto error; if (sigaction( SIGILL, &sig_act, NULL ) == -1) goto error; if (sigaction( SIGBUS, &sig_act, NULL ) == -1) goto error; @@ -171,18 +171,18 @@ index 4845d3dd5f4..9a80cafeadd 100644 error: diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c -index f92c1b89c9c..13e1a3bb929 100644 +index a194ae50104..d5ef8fe2ba7 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c -@@ -1551,6 +1551,7 @@ static void output_syscall_dispatcher(void) - output( "\tjmp 5b\n" ); - break; - case CPU_x86_64: +@@ -1603,6 +1603,7 @@ static void output_syscall_dispatcher(void) + output( "\tleaq 0x28(%%rsp),%%rsi\n" ); /* first argument */ + output( "\tmovq %%rcx,%%rsp\n" ); + output( "\tmovq 0x00(%%rcx),%%rax\n" ); + output( "\tsubq $0xf000,%%rax\n" ); - output( "\tmovq %%gs:0x30,%%rcx\n" ); - output( "\tmovq 0x328(%%rcx),%%rcx\n" ); /* amd64_thread_data()->syscall_frame */ - output( "\tmovq %%rax,0x00(%%rcx)\n" ); -@@ -1940,7 +1941,7 @@ void output_syscalls( DLLSPEC *spec ) + output( "\tmovq 0x18(%%rcx),%%rdx\n" ); + output( "\tmovl %%eax,%%ebx\n" ); + output( "\tshrl $8,%%ebx\n" ); +@@ -1942,7 +1943,7 @@ void output_syscalls( DLLSPEC *spec ) * validate that instruction, we can just put a jmp there instead. */ output( "\t.byte 0x4c,0x8b,0xd1\n" ); /* movq %rcx,%r10 */ output( "\t.byte 0xb8\n" ); /* movl $i,%eax */ diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index d7aaf861..ef658028 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -51,7 +51,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "619bd1867ac650aa664327765a8ec7fbdeaa73d8" + echo "afd5550b07f6d55e56738f61d829085d6bc82888" } # Show version information diff --git a/patches/server-default_integrity/0002-shell32-Implement-the-runas-verb.patch b/patches/server-default_integrity/0002-shell32-Implement-the-runas-verb.patch index 832c6a9a..023ee603 100644 --- a/patches/server-default_integrity/0002-shell32-Implement-the-runas-verb.patch +++ b/patches/server-default_integrity/0002-shell32-Implement-the-runas-verb.patch @@ -1,4 +1,4 @@ -From 4fd79db7e859dfa62c1c00cffa3de53b25086346 Mon Sep 17 00:00:00 2001 +From 138645fb816f0b4fc9fe55f12ec20a4a6d5e2893 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 26 Feb 2021 22:31:19 -0600 Subject: [PATCH] shell32: Implement the "runas" verb. @@ -14,7 +14,7 @@ Signed-off-by: Zebediah Figura 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c -index ce0b8f6d2be..9da9a0c81da 100644 +index 49f7867ef7e..9a8bf4b5b52 100644 --- a/dlls/shell32/shlexec.c +++ b/dlls/shell32/shlexec.c @@ -305,6 +305,21 @@ static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR psz @@ -39,7 +39,7 @@ index ce0b8f6d2be..9da9a0c81da 100644 /************************************************************************* * SHELL_ExecuteW [Internal] * -@@ -312,6 +327,7 @@ static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR psz +@@ -312,12 +327,14 @@ static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR psz static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait, const SHELLEXECUTEINFOW *psei, LPSHELLEXECUTEINFOW psei_out) { @@ -47,30 +47,29 @@ index ce0b8f6d2be..9da9a0c81da 100644 STARTUPINFOW startup; PROCESS_INFORMATION info; UINT_PTR retval = SE_ERR_NOASSOC; -@@ -319,6 +335,7 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait, + UINT gcdret = 0; WCHAR curdir[MAX_PATH]; DWORD dwCreationFlags; - const WCHAR *lpDirectory = NULL; + HANDLE token = NULL; TRACE("Execute %s from directory %s\n", debugstr_w(lpCmd), debugstr_w(psei->lpDirectory)); -@@ -344,8 +361,12 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait, +@@ -339,8 +356,12 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait, dwCreationFlags = CREATE_UNICODE_ENVIRONMENT; if (!(psei->fMask & SEE_MASK_NO_CONSOLE)) dwCreationFlags |= CREATE_NEW_CONSOLE; - if (CreateProcessW(NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE, dwCreationFlags, env, -- lpDirectory, &startup, &info)) +- NULL, &startup, &info)) + + if (psei->lpVerb && !strcmpiW(psei->lpVerb, runasW)) + token = get_admin_token(); + + if (CreateProcessAsUserW(token, NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE, -+ dwCreationFlags, env, lpDirectory, &startup, &info)) ++ dwCreationFlags, env, NULL, &startup, &info)) { /* Give 30 seconds to the app to come up, if desired. Probably only needed when starting app immediately before making a DDE connection. */ -@@ -365,6 +386,8 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait, +@@ -360,6 +381,8 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait, retval = ERROR_BAD_FORMAT; } @@ -80,5 +79,5 @@ index ce0b8f6d2be..9da9a0c81da 100644 psei_out->hInstApp = (HINSTANCE)retval; -- -2.20.1 +2.30.2 diff --git a/staging/upstream-commit b/staging/upstream-commit index 6039c3b6..edf6820d 100644 --- a/staging/upstream-commit +++ b/staging/upstream-commit @@ -1 +1 @@ -619bd1867ac650aa664327765a8ec7fbdeaa73d8 +afd5550b07f6d55e56738f61d829085d6bc82888