--- ./arch/i386/kernel/traps.c.cmov4 2016-03-09 13:45:36.000000000 +0900 +++ ./arch/i386/kernel/traps.c 2016-03-09 14:27:08.000000000 +0900 @@ -1223,12 +1223,53 @@ static int __init proc_emulated_ops_init } module_init(proc_emulated_ops_init); fastcall void __kprobes do_general_protection(struct pt_regs * regs, long error_code); #endif /* CONFIG_CPU_PROC_EMULATED_OPS */ +static inline const char *kbasename(const char *path) +{ + const char *tail = strrchr(path, '/'); + return tail ? tail + 1 : path; +} +/* + * Print the name of a VMA. + * ported from linux-3.10 + */ +void print_vma_addr(char *prefix, unsigned long ip) +{ + struct mm_struct *mm = current->mm; + struct vm_area_struct *vma; + + /* + * Do not print if we are in atomic + * contexts (in exception stacks, etc.): + */ + if (preempt_count()) + return; + + down_read(&mm->mmap_sem); + vma = find_vma(mm, ip); + if (vma && vma->vm_file) { + struct file *f = vma->vm_file; + char *buf = (char *)__get_free_page(GFP_KERNEL); + if (buf) { + char *p; + + p = d_path(f->f_dentry, f->f_vfsmnt, buf, PAGE_SIZE); + if (IS_ERR(p)) + p = "?"; + printk("%s%s[%lx+%lx]", prefix, kbasename(p), + vma->vm_start, + vma->vm_end - vma->vm_start); + free_page((unsigned long)buf); + } + } + up_read(&mm->mmap_sem); +} + /* [do_invalid_op] is called by exception 6 after an invalid opcode has been * encountered. It will decode the prefixes and the instruction code, to try * to emulate it, and will send a SIGILL or SIGSEGV to the process if not * possible. * REP/REPN prefixes are not supported anymore because it didn't make sense * to emulate instructions prefixed with such opcodes since no arch-specific @@ -1628,13 +1669,16 @@ fastcall void do_invalid_op(struct pt_re break; } /*while(1)*/ /* it's a case we can't handle. Unknown opcode or too many prefixes. */ invalid_opcode: #ifdef CONFIG_CPU_EMU486_DEBUG - printk(KERN_DEBUG "do_invalid_op() : invalid opcode detected @%p : %02x %02x %02x %02x %02x...\n", eip, eip[0], eip[1], eip[2], eip[3], eip[4]); + eip = (u8 *)regs->eip; /* reset */ + printk(KERN_NOTICE "do_invalid_op() : invalid opcode detected pid %d(%s) @%p : %02x %02x >%02x %02x %02x %02x %02x...", current->pid, current->comm, eip, eip[-2], eip[-1], eip[0], eip[1], eip[2], eip[3], eip[4]); + print_vma_addr(KERN_CONT " in ", regs->eip); + printk(KERN_CONT "\n"); #endif current->thread.error_code = error_code; current->thread.trap_no = 6; if (notify_die(DIE_TRAP, "invalid operand", regs, error_code, 6, SIGILL) == NOTIFY_STOP) return;