Skip to content

Commit b6c5a58

Browse files
mhiramatingomolnar
authored andcommitted
powerpc: 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/159870610825.1229682.2090635992093223399.stgit@devnote2
1 parent 16ff6f7 commit b6c5a58

1 file changed

Lines changed: 3 additions & 50 deletions

File tree

arch/powerpc/kernel/kprobes.c

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ bool arch_kprobe_on_func_entry(unsigned long offset)
218218
void arch_prepare_kretprobe(struct kretprobe_instance *ri, struct pt_regs *regs)
219219
{
220220
ri->ret_addr = (kprobe_opcode_t *)regs->link;
221+
ri->fp = NULL;
221222

222223
/* Replace the return addr with trampoline addr */
223224
regs->link = (unsigned long)kretprobe_trampoline;
@@ -396,50 +397,9 @@ asm(".global kretprobe_trampoline\n"
396397
*/
397398
static int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
398399
{
399-
struct kretprobe_instance *ri = NULL;
400-
struct hlist_head *head, empty_rp;
401-
struct hlist_node *tmp;
402-
unsigned long flags, orig_ret_address = 0;
403-
unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline;
404-
405-
INIT_HLIST_HEAD(&empty_rp);
406-
kretprobe_hash_lock(current, &head, &flags);
407-
408-
/*
409-
* It is possible to have multiple instances associated with a given
410-
* task either because an multiple functions in the call path
411-
* have a return probe installed on them, and/or more than one return
412-
* return probe was registered for a target function.
413-
*
414-
* We can handle this because:
415-
* - instances are always inserted at the head of the list
416-
* - when multiple return probes are registered for the same
417-
* function, the first instance's ret_addr will point to the
418-
* real return address, and all the rest will point to
419-
* kretprobe_trampoline
420-
*/
421-
hlist_for_each_entry_safe(ri, tmp, head, hlist) {
422-
if (ri->task != current)
423-
/* another task is sharing our hash bucket */
424-
continue;
425-
426-
if (ri->rp && ri->rp->handler)
427-
ri->rp->handler(ri, regs);
428-
429-
orig_ret_address = (unsigned long)ri->ret_addr;
430-
recycle_rp_inst(ri, &empty_rp);
431-
432-
if (orig_ret_address != trampoline_address)
433-
/*
434-
* This is the real return address. Any other
435-
* instances associated with this task are for
436-
* other calls deeper on the call stack
437-
*/
438-
break;
439-
}
440-
441-
kretprobe_assert(ri, orig_ret_address, trampoline_address);
400+
unsigned long orig_ret_address;
442401

402+
orig_ret_address = __kretprobe_trampoline_handler(regs, &kretprobe_trampoline, NULL);
443403
/*
444404
* We get here through one of two paths:
445405
* 1. by taking a trap -> kprobe_handler() -> here
@@ -458,13 +418,6 @@ static int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
458418
regs->nip = orig_ret_address - 4;
459419
regs->link = orig_ret_address;
460420

461-
kretprobe_hash_unlock(current, &flags);
462-
463-
hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
464-
hlist_del(&ri->hlist);
465-
kfree(ri);
466-
}
467-
468421
return 0;
469422
}
470423
NOKPROBE_SYMBOL(trampoline_probe_handler);

0 commit comments

Comments
 (0)