[PATCH v2 3/3] kernel/kprobes: Ensure that jprobe probepoints are at function entry
From: Naveen N. Rao
Date: Fri Jul 07 2017 - 13:08:13 EST
Similar to commit 90ec5e89e393c ("kretprobes: Ensure probe location is
at function entry"), ensure that the jprobe probepoint is at function
entry.
Signed-off-by: Naveen N. Rao <naveen.n.rao@xxxxxxxxxxxxxxxxxx>
---
kernel/kprobes.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index db3cd3e60bdd..a1606a4224e1 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1795,10 +1795,14 @@ int register_jprobe(struct jprobe *jp)
unsigned long addr, offset;
struct kprobe *kp = &jp->kp;
- /* Verify probepoint is a function entry point */
+ /*
+ * Verify probepoint as well as the jprobe handler are
+ * valid function entry points.
+ */
addr = arch_deref_entry_point(jp->entry);
- if (kallsyms_lookup_size_offset(addr, NULL, &offset) && offset == 0) {
+ if (kallsyms_lookup_size_offset(addr, NULL, &offset) && offset == 0 &&
+ kprobe_on_func_entry(kp->addr, kp->symbol_name, kp->offset)) {
kp->pre_handler = setjmp_pre_handler;
kp->break_handler = longjmp_break_handler;
return register_kprobe(kp);
--
2.13.2