Thread (15 messages) 15 messages, 4 authors, 2021-08-25

Re: [PATCH 3/4] ARM: Support KFENCE for ARM

flat view

From: Kefeng Wang <hidden>
Date: 2021-08-25 14:31:50
Also in: lkml

On 2021/8/25 21:18, ownia wrote:
On 2021/8/25 17:21, Kefeng Wang wrote:
quoted
Add architecture specific implementation details for KFENCE and enable
KFENCE on ARM. In particular, this implements the required interface in
  <asm/kfence.h>.

KFENCE requires that attributes for pages from its memory pool can
individually be set. Therefore, force the kfence pool to be mapped
at page granularity.

Testing this patch using the testcases in kfence_test.c and all passed
with or without ARM_LPAE.

Signed-off-by: Kefeng Wang <redacted>
...
quoted
+#endif /* __ASM_ARM_KFENCE_H */
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index f7ab6dabe89f..9fa221ffa1b9 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -17,6 +17,7 @@
  #include <linux/sched/debug.h>
  #include <linux/highmem.h>
  #include <linux/perf_event.h>
+#include <linux/kfence.h>
  
  #include <asm/system_misc.h>
  #include <asm/system_info.h>
@@ -131,10 +132,14 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
  	/*
  	 * No handler, we'll have to terminate things with extreme prejudice.
  	 */
-	if (addr < PAGE_SIZE)
+	if (addr < PAGE_SIZE) {
  		msg = "NULL pointer dereference";
-	else
+	} else {
+		if (kfence_handle_page_fault(addr, is_write_fault(fsr), regs))
+			return;
+
  		msg = "paging request";
+	}
I think here should do some fixup to follow upstream mainline code.
Yes, the fixup is still there, as the cover-letter said,

NOTE:
The context of patch2/3 changes in arch/arm/mm/fault.c is based on link[1],
which make some refactor and cleanup about page fault.

...

[1]https://lore.kernel.org/linux-arm-kernel/20210610123556.171328-1-wangkefeng.wang@huawei.com/ (local)
quoted
  
  	die_kernel_fault(msg, mm, addr, fsr, regs);
  }
.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help