[PATCH] powerpc/mm: make NULL pointer deferences explicit on bad page faults.

From: Christophe Leroy
Date: Tue Oct 09 2018 - 01:23:49 EST


As several other arches including x86, this patch makes it explicit
that a bad page fault is a NULL pointer dereference when the fault
address is lower than PAGE_SIZE

Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxx>
---
arch/powerpc/mm/fault.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index d51cf5f4e45e..501a1eadb3e9 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -631,13 +631,16 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
switch (TRAP(regs)) {
case 0x300:
case 0x380:
- printk(KERN_ALERT "Unable to handle kernel paging request for "
- "data at address 0x%08lx\n", regs->dar);
+ pr_alert("Unable to handle kernel %s for data at address 0x%08lx\n",
+ regs->dar < PAGE_SIZE ? "NULL pointer dereference" :
+ "paging request",
+ regs->dar);
break;
case 0x400:
case 0x480:
- printk(KERN_ALERT "Unable to handle kernel paging request for "
- "instruction fetch\n");
+ pr_alert("Unable to handle kernel %s for instruction fetch\n",
+ regs->nip < PAGE_SIZE ? "NULL pointer dereference" :
+ "paging request");
break;
case 0x600:
printk(KERN_ALERT "Unable to handle kernel paging request for "
--
2.13.3