All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: check __ex_table in do_bad()
@ 2019-11-07  7:45 ` Lvqiang
  0 siblings, 0 replies; 10+ messages in thread
From: Lvqiang @ 2019-11-07  7:45 UTC (permalink / raw)
  To: linux, ebiederm, dave.hansen, anshuman.khandual, akpm,
	Lvqiang.Huang, f.fainelli, will, tglx, linux-arm-kernel,
	linux-kernel


We got many crashs in for_each_frame+0x18 arch/arm/lib/backtrace.S
    1003: ldr r2, [sv_pc, #-4]

The backtrace is
    dump_backtrace
    show_stack
    sched_show_task
    show_state_filter
    sysrq_handle_showstate_blocked
    __handle_sysrq
    write_sysrq_trigger
    proc_reg_write
    __vfs_write
    vfs_write
    sys_write

Related Kernel config
    CONFIG_CPU_SW_DOMAIN_PAN=y
    # CONFIG_ARM_UNWIND is not set
    CONFIG_FRAME_POINTER=y

The task A was dumping the stack of an UN task B. However, the task B
scheduled to run on another CPU, which cause it stack content changed.
Then, task A may hit a page domain fault and die().
    [520.661314] Unhandled fault: page domain fault (0x01b) at 0x32848c02

The addr 0x32848c02 is a valid user-space address.
    PAGE DIRECTORY: d1854000
      PGD: d1854ca0 => bb21e835
      PMD: d1854ca0 => bb21e835
      PTE: bb21e120 => afffa79f

With CONFIG_CPU_SW_DOMAIN_PAN=y, a page domain fault occurred.
    { do_bad, SIGSEGV, SEGV_ACCERR, "page domain fault"},

Without check the __ex_table entry, do_bad() just return fault and die().
    .pushsection __ex_table,"a"
    .long	1003b, 1006b

This patch try __ex_table in do_bad(), the same as in __do_kernel_fault().

Signed-off-by: Lvqiang <Lvqiang.Huang@unisoc.com>
---
 arch/arm/mm/fault.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index bd0f482..22f45df 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -487,11 +487,14 @@ static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
 #endif /* CONFIG_ARM_LPAE */
 
 /*
- * This abort handler always returns "fault".
+ * Checks __ex_table before returns "fault".
  */
 static int
 do_bad(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 {
+	if (fixup_exception(regs))
+		return 0;
+
 	return 1;
 }
 
-- 
1.7.9.5



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

end of thread, other threads:[~2019-11-08  2:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07  7:45 [PATCH] ARM: check __ex_table in do_bad() Lvqiang
2019-11-07  7:45 ` Lvqiang
2019-11-07  9:24 ` Russell King - ARM Linux admin
2019-11-07  9:24   ` Russell King - ARM Linux admin
2019-11-07 15:30   ` 黄吕强 (Lvqiang Huang)
2019-11-07 15:30     ` 黄吕强 (Lvqiang Huang)
2019-11-07 17:22   ` 黄吕强 (Lvqiang Huang)
2019-11-07 17:22     ` 黄吕强 (Lvqiang Huang)
2019-11-08  2:16     ` 黄吕强 (Lvqiang Huang)
2019-11-08  2:16       ` 黄吕强 (Lvqiang Huang)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.