Skip to content

Commit 25ce1dd

Browse files
Nicolas PitreRussell King
authored andcommitted
ARM kprobes: add the kprobes hook to the page fault handler
Signed-off-by: Nicolas Pitre <nico@marvell.com>
1 parent 24ba613 commit 25ce1dd

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

arch/arm/mm/fault.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/signal.h>
1313
#include <linux/mm.h>
1414
#include <linux/init.h>
15+
#include <linux/kprobes.h>
1516

1617
#include <asm/system.h>
1718
#include <asm/pgtable.h>
@@ -20,6 +21,29 @@
2021

2122
#include "fault.h"
2223

24+
25+
#ifdef CONFIG_KPROBES
26+
static inline int notify_page_fault(struct pt_regs *regs, unsigned int fsr)
27+
{
28+
int ret = 0;
29+
30+
if (!user_mode(regs)) {
31+
/* kprobe_running() needs smp_processor_id() */
32+
preempt_disable();
33+
if (kprobe_running() && kprobe_fault_handler(regs, fsr))
34+
ret = 1;
35+
preempt_enable();
36+
}
37+
38+
return ret;
39+
}
40+
#else
41+
static inline int notify_page_fault(struct pt_regs *regs, unsigned int fsr)
42+
{
43+
return 0;
44+
}
45+
#endif
46+
2347
/*
2448
* This is useful to dump out the page tables associated with
2549
* 'addr' in mm 'mm'.
@@ -222,6 +246,9 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
222246
struct mm_struct *mm;
223247
int fault, sig, code;
224248

249+
if (notify_page_fault(regs, fsr))
250+
return 0;
251+
225252
tsk = current;
226253
mm = tsk->mm;
227254

0 commit comments

Comments
 (0)