mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 06:58:22 +00:00
signal: use usercopy
This commit is contained in:
+15
-6
@@ -1,6 +1,7 @@
|
|||||||
#include <kernel/scheduler.h>
|
#include <kernel/scheduler.h>
|
||||||
#include <arch/signal.h>
|
#include <arch/signal.h>
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
|
#include <kernel/usercopy.h>
|
||||||
|
|
||||||
#define ACTION_TERM 0
|
#define ACTION_TERM 0
|
||||||
#define ACTION_IGN 1
|
#define ACTION_IGN 1
|
||||||
@@ -373,17 +374,25 @@ bool signal_check(struct thread_t *thread, context_t *context, bool syscall, uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// configure stack frame
|
// configure stack frame
|
||||||
sigframe_t *sigframe = stack;
|
sigframe_t sigframe;
|
||||||
sigframe->restorer = action->restorer;
|
sigframe.restorer = action->restorer;
|
||||||
if (altstack) {
|
if (altstack) {
|
||||||
memcpy(&sigframe->oldstack, &thread->signals.stack, sizeof(stack_t));
|
memcpy(&sigframe.oldstack, &thread->signals.stack, sizeof(stack_t));
|
||||||
memset(&thread->signals.stack, 0, sizeof(stack_t));
|
memset(&thread->signals.stack, 0, sizeof(stack_t));
|
||||||
}
|
}
|
||||||
memcpy(&sigframe->oldmask, &thread->signals.mask, sizeof(sigset_t));
|
memcpy(&sigframe.oldmask, &thread->signals.mask, sizeof(sigset_t));
|
||||||
memcpy(&sigframe->context, context, sizeof(context_t));
|
memcpy(&sigframe.context, context, sizeof(context_t));
|
||||||
memcpy(&sigframe->extracontext, &thread->extracontext, sizeof(extracontext_t));
|
memcpy(&sigframe.extracontext, &thread->extracontext, sizeof(extracontext_t));
|
||||||
// TODO siginfo
|
// TODO siginfo
|
||||||
|
|
||||||
|
if (usercopy_touser(stack, &sigframe, sizeof(sigframe_t))) {
|
||||||
|
printf("signal: bad user stack\n");
|
||||||
|
THREAD_LEAVE(thread);
|
||||||
|
PROCESS_LEAVE(proc);
|
||||||
|
interrupt_set(true);
|
||||||
|
sched_terminateprogram(SIGSEGV);
|
||||||
|
}
|
||||||
|
|
||||||
// configure new thread signal mask
|
// configure new thread signal mask
|
||||||
if ((action->flags & SA_NODEFER) == 0)
|
if ((action->flags & SA_NODEFER) == 0)
|
||||||
SIGNAL_SETON(&thread->signals.mask, signal);
|
SIGNAL_SETON(&thread->signals.mask, signal);
|
||||||
|
|||||||
Reference in New Issue
Block a user