- memcpy(__current->fxstate, sig_ctx->prev_context.fxstate, 512);
- __current->intr_ctx = sig_ctx->prev_context.proc_regs;
- __current->flags &= ~PROC_FINPAUSE;
- __SIGCLEAR(__current->sig_inprogress, sig_ctx->sig_num);
+ __current->intr_ctx = sig_ctx->saved_ictx;
+
+ struct sigact* current = __current->sigctx.inprogress;
+ if (current) {
+ __current->sigctx.inprogress = current->prev;
+ current->prev = NULL;
+ } else {
+ __current->sigctx.inprogress = NULL;
+ }
+
+ if (proc_terminated(__current)) {
+ __current->exit_code |= PEXITSIG;
+ } else if (sigset_test(CORE, sig_ctx->sig_num)) {
+ signal_terminate(sig_ctx->sig_num);
+ }
+
+ ptr_t ictx = (ptr_t)__current->intr_ctx;
+
+ /*
+ Ensure our restored context is within kernel stack
+
+ This prevent user to forge their own context such that arbitrary code
+ can be executed as supervisor level
+ */
+ if (!within_kstack(ictx)) {
+ signal_terminate(SIGSEGV);
+ }
+