From 217dd9c1e5c4459b493bb91a48af9b571355d154 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Fri, 6 Oct 2017 14:12:39 +0900 Subject: [PATCH] x86 set_signal: panic if interrupt came from kernel This makes debugging errors e.g. FPE from kernel much easier, we really shouldn't be taking a user level coredump blaming user in that case anyway --- arch/x86/kernel/syscall.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/syscall.c b/arch/x86/kernel/syscall.c index 6ac097cb..7b5d694b 100644 --- a/arch/x86/kernel/syscall.c +++ b/arch/x86/kernel/syscall.c @@ -1334,15 +1334,19 @@ set_signal(int sig, void *regs0, siginfo_t *info) struct x86_user_context *regs = regs0; struct thread *thread = cpu_local_var(current); - if(thread == NULL || thread->proc->pid == 0) + if (thread == NULL || thread->proc->pid == 0) return; - if((__sigmask(sig) & thread->sigmask.__val[0]) || - (regs->gpr.rsp & 0x8000000000000000)){ + if (!interrupt_from_user(regs)) { + ihk_mc_debug_show_interrupt_context(regs); + panic("panic: kernel mode signal"); + } + + if ((__sigmask(sig) & thread->sigmask.__val[0])) { coredump(thread, regs0); terminate(0, sig | 0x80); } - do_kill(thread, thread->proc->pid, thread->tid, sig, info, 0); + do_kill(thread, thread->proc->pid, thread->tid, sig, info, 0); } SYSCALL_DECLARE(mmap)