linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] ARM: enable irq in translation/section permission fault handlers
@ 2019-02-15 20:05 Sebastian Andrzej Siewior
  2019-02-15 21:57 ` Bernd Edlinger
  2019-02-16 11:33 ` Russell King - ARM Linux admin
  0 siblings, 2 replies; 9+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-02-15 20:05 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Thomas Gleixner, Bernd Edlinger, Russell King, Arnd Bergmann, yadi.hu

From: "Yadi.hu" <yadi.hu@windriver.com>

Accessing a kernel address in user space causes a SIGSEGV which is sent
via
-> do_DataAbort
   -> do_sect_fault || do_translation_fault
      -> do_bad_area
         -> __do_user_fault
            -> force_sig_fault
Since commit

  02fe2845d6a83 ("ARM: entry: avoid enabling interrupts in prefetch/data abort handlers")

that path is carried out with disabled interrupts. Page/alignment fault
do enable interrupts but data abort has been left out.

On -RT the siglock is a sleeping spinlock and requires interrupts to be
enabled in order to acquire it.

Enable interrupts in the DataAbort handler if the parent context had
interrupts enabled. Move harden_branch_predictor() before interrupts are
enabled.

Reported-by: <Bernd Edlinger <bernd.edlinger@hotmail.de>
Signed-off-by: Yadi.hu <yadi.hu@windriver.com>
[bigeasy: rewrote patch description, reordered patch]
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
I though that the "interrupt enable part" has already been posted and
then Bernd complained about a warning from harden_branch_predictor() on
-RT so here it is.

 arch/arm/mm/fault.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 58f69fa07df95..da82967865836 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -161,8 +161,6 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
 		unsigned int fsr, unsigned int sig, int code,
 		struct pt_regs *regs)
 {
-	if (addr > TASK_SIZE)
-		harden_branch_predictor();
 
 #ifdef CONFIG_DEBUG_USER
 	if (((user_debug & UDBG_SEGV) && (sig == SIGSEGV)) ||
@@ -191,6 +189,11 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 	struct task_struct *tsk = current;
 	struct mm_struct *mm = tsk->active_mm;
 
+	if (addr > TASK_SIZE && user_mode(regs))
+		harden_branch_predictor();
+
+	if (interrupts_enabled(regs))
+		local_irq_enable();
 	/*
 	 * If we are in kernel mode at this point, we
 	 * have no context to handle this fault with.
-- 
2.20.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-02-21 14:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15 20:05 [RFC PATCH] ARM: enable irq in translation/section permission fault handlers Sebastian Andrzej Siewior
2019-02-15 21:57 ` Bernd Edlinger
2019-02-20 10:50   ` Sebastian Andrzej Siewior
2019-02-16 11:33 ` Russell King - ARM Linux admin
2019-02-20 11:00   ` Sebastian Andrzej Siewior
2019-02-21  8:06     ` Bernd Edlinger
2019-02-21  9:31       ` Bernd Edlinger
2019-02-21  9:57         ` Sebastian Andrzej Siewior
2019-02-21 14:03           ` Bernd Edlinger

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).