From: Liam R. Howlett Date: Thu, 22 Dec 2016 02:57:42 +0000 (-0500) Subject: sparc64: Don't panic on user mode non-resumable errors X-Git-Tag: v4.1.12-92~1^2~23 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f6100a00a484ee012b501e7bf65f89bb546365f8;p=users%2Fjedix%2Flinux-maple.git sparc64: Don't panic on user mode non-resumable errors Send a SIGBUS to the offending process on all userspace non-resumable traps. This prevents userspace applications from creating a kernel panic. The siginfo will return the code BUS_ADRERR and a valid address if possible. orabug: 23054018 Signed-off-by: Liam R. Howlett Signed-off-by: Allen Pais --- diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c index 012726850be06..813dedc848dde 100644 --- a/arch/sparc/kernel/traps_64.c +++ b/arch/sparc/kernel/traps_64.c @@ -2076,6 +2076,27 @@ void sun4v_nonresum_error(struct pt_regs *regs, unsigned long offset) put_cpu(); + if (!(regs->tstate & TSTATE_PRIV)) { + /* DON'T PANIC. This error was from userspace. */ + siginfo_t info; + unsigned int insn; + + info.si_signo = SIGBUS; + info.si_code = BUS_ADRERR; + info.si_errno = 0; + info.si_trapno = 0; + info.si_addr = 0; + + if (!copy_from_user(&insn, (void __user *)regs->tpc, 4)) { + info.si_addr = (void __user *) + compute_effective_address(regs, insn, + (insn >> 25) & 0x1f); + } + + force_sig_info(SIGBUS, &info, current); + return; + } + #ifdef CONFIG_PCI /* Check for the special PCI poke sequence. */ if (pci_poke_in_progress && pci_poke_cpu == cpu) {