diff options
-rw-r--r-- | arch/ia64/kernel/kprobes.c | 7 | ||||
-rw-r--r-- | arch/powerpc/kernel/kprobes.c | 11 | ||||
-rw-r--r-- | include/linux/kprobes.h | 1 | ||||
-rw-r--r-- | kernel/kprobes.c | 9 |
4 files changed, 24 insertions, 4 deletions
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c index 5bc46f151344..5dc98b5abcfb 100644 --- a/arch/ia64/kernel/kprobes.c +++ b/arch/ia64/kernel/kprobes.c | |||
@@ -936,10 +936,15 @@ static void ia64_get_bsp_cfm(struct unw_frame_info *info, void *arg) | |||
936 | return; | 936 | return; |
937 | } | 937 | } |
938 | 938 | ||
939 | unsigned long arch_deref_entry_point(void *entry) | ||
940 | { | ||
941 | return ((struct fnptr *)entry)->ip; | ||
942 | } | ||
943 | |||
939 | int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) | 944 | int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) |
940 | { | 945 | { |
941 | struct jprobe *jp = container_of(p, struct jprobe, kp); | 946 | struct jprobe *jp = container_of(p, struct jprobe, kp); |
942 | unsigned long addr = ((struct fnptr *)(jp->entry))->ip; | 947 | unsigned long addr = arch_deref_entry_point(jp->entry); |
943 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); | 948 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); |
944 | struct param_bsp_cfm pa; | 949 | struct param_bsp_cfm pa; |
945 | int bytes; | 950 | int bytes; |
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index 0c96611f02f4..440f5a87271f 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c | |||
@@ -492,6 +492,13 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self, | |||
492 | return ret; | 492 | return ret; |
493 | } | 493 | } |
494 | 494 | ||
495 | #ifdef CONFIG_PPC64 | ||
496 | unsigned long arch_deref_entry_point(void *entry) | ||
497 | { | ||
498 | return (unsigned long)(((func_descr_t *)entry)->entry); | ||
499 | } | ||
500 | #endif | ||
501 | |||
495 | int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) | 502 | int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) |
496 | { | 503 | { |
497 | struct jprobe *jp = container_of(p, struct jprobe, kp); | 504 | struct jprobe *jp = container_of(p, struct jprobe, kp); |
@@ -500,11 +507,9 @@ int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) | |||
500 | memcpy(&kcb->jprobe_saved_regs, regs, sizeof(struct pt_regs)); | 507 | memcpy(&kcb->jprobe_saved_regs, regs, sizeof(struct pt_regs)); |
501 | 508 | ||
502 | /* setup return addr to the jprobe handler routine */ | 509 | /* setup return addr to the jprobe handler routine */ |
510 | regs->nip = arch_deref_entry_point(jp->entry); | ||
503 | #ifdef CONFIG_PPC64 | 511 | #ifdef CONFIG_PPC64 |
504 | regs->nip = (unsigned long)(((func_descr_t *)jp->entry)->entry); | ||
505 | regs->gpr[2] = (unsigned long)(((func_descr_t *)jp->entry)->toc); | 512 | regs->gpr[2] = (unsigned long)(((func_descr_t *)jp->entry)->toc); |
506 | #else | ||
507 | regs->nip = (unsigned long)jp->entry; | ||
508 | #endif | 513 | #endif |
509 | 514 | ||
510 | return 1; | 515 | return 1; |
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index bd892850c94a..51464d12a4e5 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h | |||
@@ -214,6 +214,7 @@ int longjmp_break_handler(struct kprobe *, struct pt_regs *); | |||
214 | int register_jprobe(struct jprobe *p); | 214 | int register_jprobe(struct jprobe *p); |
215 | void unregister_jprobe(struct jprobe *p); | 215 | void unregister_jprobe(struct jprobe *p); |
216 | void jprobe_return(void); | 216 | void jprobe_return(void); |
217 | unsigned long arch_deref_entry_point(void *); | ||
217 | 218 | ||
218 | int register_kretprobe(struct kretprobe *rp); | 219 | int register_kretprobe(struct kretprobe *rp); |
219 | void unregister_kretprobe(struct kretprobe *rp); | 220 | void unregister_kretprobe(struct kretprobe *rp); |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 9e47d8c493f3..3e9f513a728d 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -675,9 +675,18 @@ static struct notifier_block kprobe_exceptions_nb = { | |||
675 | .priority = 0x7fffffff /* we need to be notified first */ | 675 | .priority = 0x7fffffff /* we need to be notified first */ |
676 | }; | 676 | }; |
677 | 677 | ||
678 | unsigned long __weak arch_deref_entry_point(void *entry) | ||
679 | { | ||
680 | return (unsigned long)entry; | ||
681 | } | ||
678 | 682 | ||
679 | int __kprobes register_jprobe(struct jprobe *jp) | 683 | int __kprobes register_jprobe(struct jprobe *jp) |
680 | { | 684 | { |
685 | unsigned long addr = arch_deref_entry_point(jp->entry); | ||
686 | |||
687 | if (!kernel_text_address(addr)) | ||
688 | return -EINVAL; | ||
689 | |||
681 | /* Todo: Verify probepoint is a function entry point */ | 690 | /* Todo: Verify probepoint is a function entry point */ |
682 | jp->kp.pre_handler = setjmp_pre_handler; | 691 | jp->kp.pre_handler = setjmp_pre_handler; |
683 | jp->kp.break_handler = longjmp_break_handler; | 692 | jp->kp.break_handler = longjmp_break_handler; |