diff options
-rw-r--r-- | arch/i386/kernel/kprobes.c | 3 | ||||
-rw-r--r-- | arch/ia64/kernel/kprobes.c | 3 | ||||
-rw-r--r-- | arch/powerpc/kernel/kprobes.c | 2 | ||||
-rw-r--r-- | arch/x86_64/kernel/kprobes.c | 2 | ||||
-rw-r--r-- | include/linux/kprobes.h | 10 |
5 files changed, 15 insertions, 5 deletions
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c index e00f75ecf1a..3fbef288c37 100644 --- a/arch/i386/kernel/kprobes.c +++ b/arch/i386/kernel/kprobes.c | |||
@@ -449,8 +449,7 @@ fastcall void *__kprobes trampoline_handler(struct pt_regs *regs) | |||
449 | break; | 449 | break; |
450 | } | 450 | } |
451 | 451 | ||
452 | BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address)); | 452 | kretprobe_assert(ri, orig_ret_address, trampoline_address); |
453 | |||
454 | spin_unlock_irqrestore(&kretprobe_lock, flags); | 453 | spin_unlock_irqrestore(&kretprobe_lock, flags); |
455 | 454 | ||
456 | hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { | 455 | hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { |
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c index 779fe00c902..353689edebd 100644 --- a/arch/ia64/kernel/kprobes.c +++ b/arch/ia64/kernel/kprobes.c | |||
@@ -444,7 +444,8 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs) | |||
444 | break; | 444 | break; |
445 | } | 445 | } |
446 | 446 | ||
447 | BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address)); | 447 | kretprobe_assert(ri, orig_ret_address, trampoline_address); |
448 | |||
448 | regs->cr_iip = orig_ret_address; | 449 | regs->cr_iip = orig_ret_address; |
449 | 450 | ||
450 | reset_current_kprobe(); | 451 | reset_current_kprobe(); |
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index 2a2c696dcc7..3d54ad7dd1f 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c | |||
@@ -336,7 +336,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs) | |||
336 | break; | 336 | break; |
337 | } | 337 | } |
338 | 338 | ||
339 | BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address)); | 339 | kretprobe_assert(ri, orig_ret_address, trampoline_address); |
340 | regs->nip = orig_ret_address; | 340 | regs->nip = orig_ret_address; |
341 | 341 | ||
342 | reset_current_kprobe(); | 342 | reset_current_kprobe(); |
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c index 90e7008cd89..5841ba5f479 100644 --- a/arch/x86_64/kernel/kprobes.c +++ b/arch/x86_64/kernel/kprobes.c | |||
@@ -447,7 +447,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs) | |||
447 | break; | 447 | break; |
448 | } | 448 | } |
449 | 449 | ||
450 | BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address)); | 450 | kretprobe_assert(ri, orig_ret_address, trampoline_address); |
451 | regs->rip = orig_ret_address; | 451 | regs->rip = orig_ret_address; |
452 | 452 | ||
453 | reset_current_kprobe(); | 453 | reset_current_kprobe(); |
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index f2646070037..850ee871e35 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h | |||
@@ -157,6 +157,16 @@ struct kretprobe_instance { | |||
157 | struct task_struct *task; | 157 | struct task_struct *task; |
158 | }; | 158 | }; |
159 | 159 | ||
160 | static inline void kretprobe_assert(struct kretprobe_instance *ri, | ||
161 | unsigned long orig_ret_address, unsigned long trampoline_address) | ||
162 | { | ||
163 | if (!orig_ret_address || (orig_ret_address == trampoline_address)) { | ||
164 | printk("kretprobe BUG!: Processing kretprobe %p @ %p\n", | ||
165 | ri->rp, ri->rp->kp.addr); | ||
166 | BUG(); | ||
167 | } | ||
168 | } | ||
169 | |||
160 | extern spinlock_t kretprobe_lock; | 170 | extern spinlock_t kretprobe_lock; |
161 | extern struct mutex kprobe_mutex; | 171 | extern struct mutex kprobe_mutex; |
162 | extern int arch_prepare_kprobe(struct kprobe *p); | 172 | extern int arch_prepare_kprobe(struct kprobe *p); |