Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <heiko.carstens@de.ibm.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Heiko Carstens and committed by
Martin Schwidefsky
f7f242ff 3ac8e380

+12 -7
+1
include/linux/kprobes.h
··· 335 335 extern int arch_prepare_kprobe_ftrace(struct kprobe *p); 336 336 #endif 337 337 338 + int arch_check_ftrace_location(struct kprobe *p); 338 339 339 340 /* Get the kprobe at this addr (if any) - called with preemption disabled */ 340 341 struct kprobe *get_kprobe(void *addr);
+11 -7
kernel/kprobes.c
··· 1410 1410 return ret; 1411 1411 } 1412 1412 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) 1415 1414 { 1416 - int ret = 0; 1417 1415 unsigned long ftrace_addr; 1418 1416 1419 - /* 1420 - * If the address is located on a ftrace nop, set the 1421 - * breakpoint to the following instruction. 1422 - */ 1423 1417 ftrace_addr = ftrace_location((unsigned long)p->addr); 1424 1418 if (ftrace_addr) { 1425 1419 #ifdef CONFIG_KPROBES_ON_FTRACE ··· 1425 1431 return -EINVAL; 1426 1432 #endif 1427 1433 } 1434 + return 0; 1435 + } 1428 1436 1437 + static int check_kprobe_address_safe(struct kprobe *p, 1438 + struct module **probed_mod) 1439 + { 1440 + int ret; 1441 + 1442 + ret = arch_check_ftrace_location(p); 1443 + if (ret) 1444 + return ret; 1429 1445 jump_label_lock(); 1430 1446 preempt_disable(); 1431 1447