[PATCH] arm64: print additional fault message when executing non-exec memory

From: Xiang Zheng
Date: Mon Oct 28 2019 - 05:09:18 EST


When attempting to executing non-executable memory, the fault message
shows:

Unable to handle kernel read from unreadable memory at virtual address
ffff802dac469000

This may confuse someone, so add a new fault message for instruction
abort.

Signed-off-by: Xiang Zheng <zhengxiang9@xxxxxxxxxx>
---
arch/arm64/mm/fault.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 9fc6db0bcbad..68bf4ec376d0 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -318,6 +318,8 @@ static void __do_kernel_fault(unsigned long addr, unsigned int esr,
if (is_el1_permission_fault(addr, esr, regs)) {
if (esr & ESR_ELx_WNR)
msg = "write to read-only memory";
+ else if (is_el1_instruction_abort(esr))
+ msg = "execute non-executable memory";
else
msg = "read from unreadable memory";
} else if (addr < PAGE_SIZE) {
--
2.19.1