]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sparc64: Don't panic on user mode non-resumable errors
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 22 Dec 2016 02:57:42 +0000 (21:57 -0500)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 9 Mar 2017 03:30:05 +0000 (19:30 -0800)
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 <Liam.Howlett@Oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
arch/sparc/kernel/traps_64.c

index 012726850be06974c962ddce8f6d6b4af3b1ec53..813dedc848dde9f51c664b33aac52e1de9716d8f 100644 (file)
@@ -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) {