Skip to content

Commit f7f242f

Browse files
heicarstMartin Schwidefsky
authored andcommitted
kprobes: introduce weak arch_check_ftrace_location() helper function
Introduce weak arch_check_ftrace_location() helper function which architectures can override in order to implement handling of kprobes on function tracer call sites on their own, without depending on common code or implementing the KPROBES_ON_FTRACE feature. Signed-off-by: Heiko Carstens <[email protected]> Acked-by: Masami Hiramatsu <[email protected]> Acked-by: Steven Rostedt <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent 3ac8e38 commit f7f242f

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

include/linux/kprobes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
335335
extern int arch_prepare_kprobe_ftrace(struct kprobe *p);
336336
#endif
337337

338+
int arch_check_ftrace_location(struct kprobe *p);
338339

339340
/* Get the kprobe at this addr (if any) - called with preemption disabled */
340341
struct kprobe *get_kprobe(void *addr);

kernel/kprobes.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,16 +1410,10 @@ static inline int check_kprobe_rereg(struct kprobe *p)
14101410
return ret;
14111411
}
14121412

1413-
static int check_kprobe_address_safe(struct kprobe *p,
1414-
struct module **probed_mod)
1413+
int __weak arch_check_ftrace_location(struct kprobe *p)
14151414
{
1416-
int ret = 0;
14171415
unsigned long ftrace_addr;
14181416

1419-
/*
1420-
* If the address is located on a ftrace nop, set the
1421-
* breakpoint to the following instruction.
1422-
*/
14231417
ftrace_addr = ftrace_location((unsigned long)p->addr);
14241418
if (ftrace_addr) {
14251419
#ifdef CONFIG_KPROBES_ON_FTRACE
@@ -1431,7 +1425,17 @@ static int check_kprobe_address_safe(struct kprobe *p,
14311425
return -EINVAL;
14321426
#endif
14331427
}
1428+
return 0;
1429+
}
14341430

1431+
static int check_kprobe_address_safe(struct kprobe *p,
1432+
struct module **probed_mod)
1433+
{
1434+
int ret;
1435+
1436+
ret = arch_check_ftrace_location(p);
1437+
if (ret)
1438+
return ret;
14351439
jump_label_lock();
14361440
preempt_disable();
14371441

0 commit comments

Comments
 (0)