[PATCH] ntdll: Fix arm64 call_user_exception_dispatcher with kernel stack for syscalls

Martin Storsjo martin at martin.st
Sun Jul 25 15:33:05 CDT 2021


Don't call KiUserExceptionDispatcher directly on the stack pointer
stored in the CONTEXT, but use the one stored in syscall_frame
(which includes the stack allocation in e.g. RtlRaiseException).

This fixes unwinding test cases that worked before
08c4419a49655801cba2b71ea327534ff7fd4278.

Signed-off-by: Martin Storsjo <martin at martin.st>
---
 dlls/ntdll/unix/signal_arm64.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/dlls/ntdll/unix/signal_arm64.c b/dlls/ntdll/unix/signal_arm64.c
index 1e4f493bc97..0ce6206aa9d 100644
--- a/dlls/ntdll/unix/signal_arm64.c
+++ b/dlls/ntdll/unix/signal_arm64.c
@@ -705,12 +705,18 @@ void call_raise_user_exception_dispatcher(void)
 NTSTATUS call_user_exception_dispatcher( EXCEPTION_RECORD *rec, CONTEXT *context )
 {
     struct syscall_frame *frame = arm64_thread_data()->syscall_frame;
+    ULONG64 fp = frame->fp;
+    ULONG64 lr = frame->lr;
+    ULONG64 sp = frame->sp;
     NTSTATUS status = NtSetContextThread( GetCurrentThread(), context );
 
     if (status) return status;
     frame->x[0] = (ULONG64)rec;
     frame->x[1] = (ULONG64)context;
     frame->pc   = (ULONG64)pKiUserExceptionDispatcher;
+    frame->fp   = fp;
+    frame->lr   = lr;
+    frame->sp   = sp;
     frame->restore_flags |= CONTEXT_INTEGER | CONTEXT_CONTROL;
     return status;
 }
-- 
2.25.1




More information about the wine-devel mailing list