linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: print a fault message when attempting to write RO memory
@ 2017-02-16  1:54 Stephen Boyd
  2017-02-16 11:06 ` Mark Rutland
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Boyd @ 2017-02-16  1:54 UTC (permalink / raw)
  To: linux-arm-kernel

If a page is marked read only we should print out that fact,
instead of printing out that there was a page fault. Right now we
get a cryptic error message that something went wrong with an
unhandled fault, but we don't evaluate the esr to figure out that
it was a read/write permission fault.

Instead of seeing:

  Unable to handle kernel paging request at virtual address ffff000008e460d8
  pgd = ffff800003504000
  [ffff000008e460d8] *pgd=0000000083473003, *pud=0000000083503003, *pmd=0000000000000000
  Internal error: Oops: 9600004f [#1] PREEMPT SMP

we'll see:

  Internal error: Attempting to write read-only memory: 9600004f [#1] PREEMPT SMP

Cc: Laura Abbott <labbott@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
---
 arch/arm64/mm/fault.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 156169c6981b..752507fa80ec 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -331,6 +331,11 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 
 		if (!search_exception_tables(regs->pc))
 			die("Accessing user space memory outside uaccess.h routines", regs, esr);
+	} else if (is_permission_fault(esr, regs)) {
+		if (esr & ESR_ELx_WNR)
+			die("Attempting to write read-only memory", regs, esr);
+		else
+			die("Attempting to read unreadable memory", regs, esr);
 	}
 
 	/*
-- 
2.10.0.297.gf6727b0

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

end of thread, other threads:[~2017-02-16 19:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-16  1:54 [PATCH] arm64: print a fault message when attempting to write RO memory Stephen Boyd
2017-02-16 11:06 ` Mark Rutland
2017-02-16 11:16   ` Mark Rutland
2017-02-16 19:06   ` Stephen Boyd

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