summaryrefslogtreecommitdiff
path: root/packaging/0021-Revert-ExecuteHandlerOnOriginalStack-handle-case-whe.patch
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/0021-Revert-ExecuteHandlerOnOriginalStack-handle-case-whe.patch')
-rw-r--r--packaging/0021-Revert-ExecuteHandlerOnOriginalStack-handle-case-whe.patch143
1 files changed, 143 insertions, 0 deletions
diff --git a/packaging/0021-Revert-ExecuteHandlerOnOriginalStack-handle-case-whe.patch b/packaging/0021-Revert-ExecuteHandlerOnOriginalStack-handle-case-whe.patch
new file mode 100644
index 0000000000..57e06008d2
--- /dev/null
+++ b/packaging/0021-Revert-ExecuteHandlerOnOriginalStack-handle-case-whe.patch
@@ -0,0 +1,143 @@
+From 911fcce99ad77f5bb18de8141a3b80f9f2823041 Mon Sep 17 00:00:00 2001
+From: Konstantin Baladurin <k.baladurin@partner.samsung.com>
+Date: Wed, 30 May 2018 19:23:03 +0300
+Subject: [PATCH 21/47] Revert "ExecuteHandlerOnOriginalStack: handle case when
+ it is called on original stack."
+
+This reverts commit a8465f60548ed4b10f13f5ace8ea99e07fc2aeba.
+---
+ src/pal/src/arch/amd64/signalhandlerhelper.cpp | 20 ++------------------
+ src/pal/src/arch/arm/signalhandlerhelper.cpp | 18 +-----------------
+ src/pal/src/arch/arm64/signalhandlerhelper.cpp | 19 +------------------
+ src/pal/src/arch/i386/signalhandlerhelper.cpp | 18 +-----------------
+ 4 files changed, 5 insertions(+), 70 deletions(-)
+
+diff --git a/src/pal/src/arch/amd64/signalhandlerhelper.cpp b/src/pal/src/arch/amd64/signalhandlerhelper.cpp
+index 803479c..8789f5a 100644
+--- a/src/pal/src/arch/amd64/signalhandlerhelper.cpp
++++ b/src/pal/src/arch/amd64/signalhandlerhelper.cpp
+@@ -27,23 +27,7 @@ Parameters :
+ void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context, SignalHandlerWorkerReturnPoint* returnPoint)
+ {
+ ucontext_t *ucontext = (ucontext_t *)context;
+- size_t faultSp;
+-
+- // check whether this function is called on alternate stack or not. In the second case we already
+- // on original stack and we should use faultSp from this frame otherwise stackframe of the caller
+- // function will be corrupted.
+- char fakeStackFrame[128 /* redzone */ + 16 /* aligment */ + 4 * sizeof(size_t) /* registers */];
+- stack_t oss;
+- int st = sigaltstack(NULL, &oss);
+- if ((st == 0) && ((oss.ss_flags == SS_DISABLE) ||
+- ((size_t)oss.ss_sp > (size_t)&faultSp) || (((size_t)oss.ss_sp + oss.ss_size) < (size_t)&faultSp)))
+- {
+- faultSp = (size_t)&fakeStackFrame[sizeof(fakeStackFrame)];
+- }
+- else
+- {
+- faultSp = (size_t)MCREG_Rsp(ucontext->uc_mcontext);
+- }
++ size_t faultSp = (size_t)MCREG_Rsp(ucontext->uc_mcontext);
+
+ _ASSERTE(IS_ALIGNED(faultSp, 8));
+
+@@ -74,7 +58,7 @@ void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context,
+ // We don't care about the other registers state since the stack unwinding restores
+ // them for the target frame directly from the signal context.
+ context2.Rsp = (size_t)sp;
+- context2.Rbx = (size_t)MCREG_Rsp(ucontext->uc_mcontext);
++ context2.Rbx = (size_t)faultSp;
+ context2.Rbp = (size_t)fp;
+ context2.Rip = (size_t)signal_handler_worker;
+ context2.Rdi = code;
+diff --git a/src/pal/src/arch/arm/signalhandlerhelper.cpp b/src/pal/src/arch/arm/signalhandlerhelper.cpp
+index fbf33e3..3936204 100644
+--- a/src/pal/src/arch/arm/signalhandlerhelper.cpp
++++ b/src/pal/src/arch/arm/signalhandlerhelper.cpp
+@@ -27,23 +27,7 @@ Parameters :
+ void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context, SignalHandlerWorkerReturnPoint* returnPoint)
+ {
+ ucontext_t *ucontext = (ucontext_t *)context;
+- size_t faultSp;
+-
+- // check whether this function is called on alternate stack or not. In the second case we already
+- // on original stack and we should use faultSp from this frame otherwise stackframe of the caller
+- // function will be corrupted.
+- char fakeStackFrame[8 /* redzone */ + 8 /* aligment */ + sizeof(ucontext->uc_mcontext) + 8 /* registers */];
+- stack_t oss;
+- int st = sigaltstack(NULL, &oss);
+- if ((st == 0) && ((oss.ss_flags == SS_DISABLE) ||
+- ((size_t)oss.ss_sp > (size_t)&faultSp) || (((size_t)oss.ss_sp + oss.ss_size) < (size_t)&faultSp)))
+- {
+- faultSp = (size_t)&fakeStackFrame[sizeof(fakeStackFrame)];
+- }
+- else
+- {
+- faultSp = (size_t)MCREG_Sp(ucontext->uc_mcontext);
+- }
++ size_t faultSp = (size_t)MCREG_Sp(ucontext->uc_mcontext);
+
+ _ASSERTE(IS_ALIGNED(faultSp, 4));
+
+diff --git a/src/pal/src/arch/arm64/signalhandlerhelper.cpp b/src/pal/src/arch/arm64/signalhandlerhelper.cpp
+index 958b8af..c35c629 100644
+--- a/src/pal/src/arch/arm64/signalhandlerhelper.cpp
++++ b/src/pal/src/arch/arm64/signalhandlerhelper.cpp
+@@ -27,24 +27,7 @@ Parameters :
+ void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context, SignalHandlerWorkerReturnPoint* returnPoint)
+ {
+ ucontext_t *ucontext = (ucontext_t *)context;
+- size_t faultSp;
+-
+- // check whether this function is called on alternate stack or not. In the second case we already
+- // on original stack and we should use faultSp from this frame otherwise stackframe of the caller
+- // function will be corrupted.
+- char fakeStackFrame[128 /* redzone */ + 16 /* aligment */ + 3 * sizeof(size_t) /* registers */];
+- stack_t oss;
+- int st = sigaltstack(NULL, &oss);
+- if ((st == 0) && ((oss.ss_flags == SS_DISABLE) ||
+- ((size_t)oss.ss_sp > (size_t)&faultSp) || (((size_t)oss.ss_sp + oss.ss_size) < (size_t)&faultSp)))
+- {
+- faultSp = (size_t)&fakeStackFrame[sizeof(fakeStackFrame)];
+- }
+- else
+- {
+- faultSp = (size_t)MCREG_Sp(ucontext->uc_mcontext);
+- }
+-
++ size_t faultSp = (size_t)MCREG_Sp(ucontext->uc_mcontext);
+ _ASSERTE(IS_ALIGNED(faultSp, 8));
+
+ size_t fakeFrameReturnAddress;
+diff --git a/src/pal/src/arch/i386/signalhandlerhelper.cpp b/src/pal/src/arch/i386/signalhandlerhelper.cpp
+index d534f96..a7d418a 100644
+--- a/src/pal/src/arch/i386/signalhandlerhelper.cpp
++++ b/src/pal/src/arch/i386/signalhandlerhelper.cpp
+@@ -27,23 +27,7 @@ Parameters :
+ void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context, SignalHandlerWorkerReturnPoint* returnPoint)
+ {
+ ucontext_t *ucontext = (ucontext_t *)context;
+- size_t faultSp;
+-
+- // check whether this function is called on alternate stack or not. In the second case we already
+- // on original stack and we should use faultSp from this frame otherwise stackframe of the caller
+- // function will be corrupted.
+- char fakeStackFrame[16 /* aligment */ + 10 * sizeof(size_t) /* registers */];
+- stack_t oss;
+- int st = sigaltstack(NULL, &oss);
+- if ((st == 0) && ((oss.ss_flags == SS_DISABLE) ||
+- ((size_t)oss.ss_sp > (size_t)&faultSp) || (((size_t)oss.ss_sp + oss.ss_size) < (size_t)&faultSp)))
+- {
+- faultSp = (size_t)&fakeStackFrame[sizeof(fakeStackFrame)];
+- }
+- else
+- {
+- faultSp = (size_t)MCREG_Esp(ucontext->uc_mcontext);
+- }
++ size_t faultSp = (size_t)MCREG_Esp(ucontext->uc_mcontext);
+
+ _ASSERTE(IS_ALIGNED(faultSp, 4));
+
+--
+2.7.4
+