From f6100a00a484ee012b501e7bf65f89bb546365f8 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Wed, 21 Dec 2016 21:57:42 -0500 Subject: [PATCH] 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 --- arch/sparc/kernel/traps_64.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c index 012726850be0..813dedc848dd 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) { -- 2.49.0