Skip to content

Commit e792ff8

Browse files
mhiramatingomolnar
authored andcommitted
ia64: kprobes: Use generic kretprobe trampoline handler
Use the generic kretprobe trampoline handler. Don't use framepointer verification. Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/159870606883.1229682.12331813108378725668.stgit@devnote2
1 parent 03c8a4a commit e792ff8

1 file changed

Lines changed: 2 additions & 75 deletions

File tree

‎arch/ia64/kernel/kprobes.c‎

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -396,83 +396,9 @@ static void kretprobe_trampoline(void)
396396
{
397397
}
398398

399-
/*
400-
* At this point the target function has been tricked into
401-
* returning into our trampoline. Lookup the associated instance
402-
* and then:
403-
* - call the handler function
404-
* - cleanup by marking the instance as unused
405-
* - long jump back to the original return address
406-
*/
407399
int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
408400
{
409-
struct kretprobe_instance *ri = NULL;
410-
struct hlist_head *head, empty_rp;
411-
struct hlist_node *tmp;
412-
unsigned long flags, orig_ret_address = 0;
413-
unsigned long trampoline_address =
414-
((struct fnptr *)kretprobe_trampoline)->ip;
415-
416-
INIT_HLIST_HEAD(&empty_rp);
417-
kretprobe_hash_lock(current, &head, &flags);
418-
419-
/*
420-
* It is possible to have multiple instances associated with a given
421-
* task either because an multiple functions in the call path
422-
* have a return probe installed on them, and/or more than one return
423-
* return probe was registered for a target function.
424-
*
425-
* We can handle this because:
426-
* - instances are always inserted at the head of the list
427-
* - when multiple return probes are registered for the same
428-
* function, the first instance's ret_addr will point to the
429-
* real return address, and all the rest will point to
430-
* kretprobe_trampoline
431-
*/
432-
hlist_for_each_entry_safe(ri, tmp, head, hlist) {
433-
if (ri->task != current)
434-
/* another task is sharing our hash bucket */
435-
continue;
436-
437-
orig_ret_address = (unsigned long)ri->ret_addr;
438-
if (orig_ret_address != trampoline_address)
439-
/*
440-
* This is the real return address. Any other
441-
* instances associated with this task are for
442-
* other calls deeper on the call stack
443-
*/
444-
break;
445-
}
446-
447-
regs->cr_iip = orig_ret_address;
448-
449-
hlist_for_each_entry_safe(ri, tmp, head, hlist) {
450-
if (ri->task != current)
451-
/* another task is sharing our hash bucket */
452-
continue;
453-
454-
if (ri->rp && ri->rp->handler)
455-
ri->rp->handler(ri, regs);
456-
457-
orig_ret_address = (unsigned long)ri->ret_addr;
458-
recycle_rp_inst(ri, &empty_rp);
459-
460-
if (orig_ret_address != trampoline_address)
461-
/*
462-
* This is the real return address. Any other
463-
* instances associated with this task are for
464-
* other calls deeper on the call stack
465-
*/
466-
break;
467-
}
468-
kretprobe_assert(ri, orig_ret_address, trampoline_address);
469-
470-
kretprobe_hash_unlock(current, &flags);
471-
472-
hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
473-
hlist_del(&ri->hlist);
474-
kfree(ri);
475-
}
401+
regs->cr_iip = __kretprobe_trampoline_handler(regs, kretprobe_trampoline, NULL);
476402
/*
477403
* By returning a non-zero value, we are telling
478404
* kprobe_handler() that we don't want the post_handler
@@ -485,6 +411,7 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
485411
struct pt_regs *regs)
486412
{
487413
ri->ret_addr = (kprobe_opcode_t *)regs->b0;
414+
ri->fp = NULL;
488415

489416
/* Replace the return addr with trampoline addr */
490417
regs->b0 = ((struct fnptr *)kretprobe_trampoline)->ip;

0 commit comments

Comments
 (0)