[PATCH 1/3] ARM: allow __do_kernel_fault() to report execution of memory faults
Xie Yuanbin
xieyuanbin1 at huawei.com
Mon Dec 8 20:02:23 PST 2025
On Mon, 08 Dec 2025 12:34:54 +0000, Russell King wrote:
> diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
> index 2bc828a1940c..f0884bf91dfa 100644
> --- a/arch/arm/mm/fault.c
> +++ b/arch/arm/mm/fault.c
> @@ -162,6 +162,8 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
> */
> if (addr < PAGE_SIZE) {
> msg = "NULL pointer dereference";
> + } else if (is_permission_fault(fsr) && fsr & FSR_LNX_PF) {
> + msg = "execution of memory";
> } else {
> if (is_translation_fault(fsr) &&
> kfence_handle_page_fault(addr, is_write_fault(fsr), regs))
This patch caused a compilation error, is_permission_fault() is not
defined. Fixed with:
```patch
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 6ba5a11cc..066408523 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -192,6 +192,21 @@ static void die_kernel_fault(const char *msg, struct mm_struct *mm,
make_task_dead(SIGKILL);
}
+static inline bool is_permission_fault(unsigned int fsr)
+{
+#ifdef CONFIG_MMU
+ int fs = fsr_fs(fsr);
+#ifdef CONFIG_ARM_LPAE
+ if ((fs & FS_MMU_NOLL_MASK) == FS_PERM_NOLL)
+ return true;
+#else
+ if (fs == FS_L1_PERM || fs == FS_L2_PERM)
+ return true;
+#endif
+#endif
+ return false;
+}
+
/*
* Oops. The kernel tried to access some page that wasn't present.
*/
@@ -305,19 +320,6 @@ void do_bad_area_user_fixup(unsigned long addr, unsigned int fsr,
#define VM_FAULT_BADMAP 0x010000
#define VM_FAULT_BADACCESS 0x020000
-static inline bool is_permission_fault(unsigned int fsr)
-{
- int fs = fsr_fs(fsr);
-#ifdef CONFIG_ARM_LPAE
- if ((fs & FS_MMU_NOLL_MASK) == FS_PERM_NOLL)
- return true;
-#else
- if (fs == FS_L1_PERM || fs == FS_L2_PERM)
- return true;
-#endif
- return false;
-}
-
static vm_fault_t __kprobes
__do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int flags,
unsigned long vma_flags, struct pt_regs *regs)
```
More information about the linux-arm-kernel
mailing list