mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58:22 +00:00
sigreturn: add bad behavior checks and mask flags
This commit is contained in:
@@ -11,11 +11,16 @@
|
||||
__attribute__((noreturn)) void syscall_sigreturn(context_t *context) {
|
||||
sigframe_t *sigframe = __builtin_alloca(ARCH_SIGFRAME_SIZE);
|
||||
int error = usercopy_fromuser(sigframe, (void *)CTX_SP(context), ARCH_SIGFRAME_SIZE);
|
||||
if (error || ARCH_CONTEXT_ISUSER(&sigframe->context) == false) {
|
||||
if (error || ARCH_CONTEXT_ISUSER(&sigframe->context) == false || !IS_USER_ADDRESS(CTX_IP(&sigframe->context))) {
|
||||
printf("syscall_sigreturn: bad return stack or bad return information\n");
|
||||
proc_terminate(SIGSEGV);
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
// CF PF AF ZF SF TF DF OF RF AC
|
||||
sigframe->context.rflags &= 0x50DD5;
|
||||
#endif
|
||||
|
||||
interrupt_set(false);
|
||||
signal_altstack(current_thread(), &sigframe->oldstack, NULL);
|
||||
signal_changemask(current_thread(), SIG_SETMASK, &sigframe->oldmask, NULL);
|
||||
|
||||
Reference in New Issue
Block a user