Re: [PATCH v3 2/2] ARM: mm: protect show_pte() in do_DataAbort() fallback path

From: Xie Yuanbin

Date: Fri Jun 26 2026 - 06:18:17 EST


On Fri, 26 Jun 2026 15:30:48 +0800, Qi Xi wrote:
> @@ -638,7 +638,10 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
> pr_alert("8<--- cut here ---\n");
> pr_alert("Unhandled fault: %s (0x%03x) at 0x%08lx\n",
> inf->name, fsr, addr);
> - show_pte(KERN_ALERT, current->mm, addr);
> + if (mmap_read_trylock(current->mm)) {
> + show_pte(KERN_ALERT, current->mm, addr);
> + mmap_read_unlock(current->mm);
> + }

For kernel faults, `current->mm` maybe NULL, and
`mmap_read_trylock(current->mm)` may cause a panic.
Also, interrupts may be disabled here.

I suggest that waiting for this patch to be merged first:
https://lore.kernel.org/20260625122612.43501-1-xieyuanbin1@xxxxxxxxxx
which make sure that interrupts are enabled here.
Then, something like:
```c
if (user_mode(regs))
mmap_read_lock(current->mm);
show_pte(KERN_ALERT, current->mm, addr);
if (user_mode(regs))
mmap_read_unlock(current->mm);
```