[PATCH 1/2] sparc64: Don't panic on user mode non-resumable errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>
---
 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 496fa92..3a0c153 100644
--- a/arch/sparc/kernel/traps_64.c
+++ b/arch/sparc/kernel/traps_64.c
@@ -2075,6 +2075,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.1.4

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [DCCP]     [Linux ARM Development]     [Linux]     [Photo]     [Yosemite Help]     [Linux ARM Kernel]     [Linux SCSI]     [Linux x86_64]     [Linux Hams]

  Powered by Linux