@@ -218,6 +218,7 @@ bool arch_kprobe_on_func_entry(unsigned long offset)
218218void 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 */
397398static 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}
470423NOKPROBE_SYMBOL (trampoline_probe_handler );
0 commit comments