linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hari.vyas@broadcom.com (Hari Vyas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: fix kernel panic on serror exception caused by user process
Date: Tue, 17 Jul 2018 15:01:21 +0530	[thread overview]
Message-ID: <1531819881-2931-2-git-send-email-hari.vyas@broadcom.com> (raw)
In-Reply-To: <1531819881-2931-1-git-send-email-hari.vyas@broadcom.com>

On executing simple user level "devmem 0x0" command, kernel panics.
As 0x0 address is mostly not matched to any valid memory so exception
is expected and raised which results in unconditional kernel panic
by serror handler.

This is happening after newly introduced serror handling framework
change which panics kernel on any any serror without checking
processor mode.`

Kernel panic is fixed by checking processor mode in serror handler.
On kernel mode, normal kernel panic action is taken and system halts.
On user mode, only user process is killed and further panic action is
not initiated.

Signed-off-by: Hari Vyas <hari.vyas@broadcom.com>
---
 arch/arm64/kernel/traps.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index d399d45..c7cbad7 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -729,6 +729,13 @@ bool arm64_is_fatal_ras_serror(struct pt_regs *regs, unsigned int esr)
 
 asmlinkage void do_serror(struct pt_regs *regs, unsigned int esr)
 {
+	if (user_mode(regs)) {
+		pr_crit("UserMode SError Exception on CPU%d, code 0x%08x %s\n",
+			smp_processor_id(), esr, esr_get_class_string(esr));
+		die("Oops - user mode ", regs, 0);
+		return;
+        }
+
 	nmi_enter();
 
 	/* non-RAS errors are not containable */
-- 
1.9.1

  reply	other threads:[~2018-07-17  9:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17  9:31 [PATCH] arm64: fix kernel panic on serror caused by user process Hari Vyas
2018-07-17  9:31 ` Hari Vyas [this message]
2018-07-17 10:06   ` [PATCH] arm64: fix kernel panic on serror exception " Mark Rutland
2018-07-17 11:32     ` Hari Vyas
2018-07-17 11:48       ` Mark Rutland
2018-07-17 13:40         ` Hari Vyas
2018-07-17 14:20           ` James Morse
2018-07-17 14:26           ` Robin Murphy
2018-07-17 14:45           ` Russell King - ARM Linux
2018-07-18  9:14             ` Hari Vyas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1531819881-2931-2-git-send-email-hari.vyas@broadcom.com \
    --to=hari.vyas@broadcom.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).