@@ -204,6 +204,7 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
204204 struct pt_regs * regs )
205205{
206206 ri -> ret_addr = (kprobe_opcode_t * ) regs -> pr ;
207+ ri -> fp = NULL ;
207208
208209 /* Replace the return addr with trampoline addr */
209210 regs -> pr = (unsigned long )kretprobe_trampoline ;
@@ -302,62 +303,9 @@ static void __used kretprobe_trampoline_holder(void)
302303 */
303304int __kprobes trampoline_probe_handler (struct kprobe * p , struct pt_regs * regs )
304305{
305- struct kretprobe_instance * ri = NULL ;
306- struct hlist_head * head , empty_rp ;
307- struct hlist_node * tmp ;
308- unsigned long flags , orig_ret_address = 0 ;
309- unsigned long trampoline_address = (unsigned long )& kretprobe_trampoline ;
306+ regs -> pc = __kretprobe_trampoline_handler (regs , & kretprobe_trampoline , NULL );
310307
311- INIT_HLIST_HEAD (& empty_rp );
312- kretprobe_hash_lock (current , & head , & flags );
313-
314- /*
315- * It is possible to have multiple instances associated with a given
316- * task either because an multiple functions in the call path
317- * have a return probe installed on them, and/or more then one return
318- * return probe was registered for a target function.
319- *
320- * We can handle this because:
321- * - instances are always inserted at the head of the list
322- * - when multiple return probes are registered for the same
323- * function, the first instance's ret_addr will point to the
324- * real return address, and all the rest will point to
325- * kretprobe_trampoline
326- */
327- hlist_for_each_entry_safe (ri , tmp , head , hlist ) {
328- if (ri -> task != current )
329- /* another task is sharing our hash bucket */
330- continue ;
331-
332- if (ri -> rp && ri -> rp -> handler ) {
333- __this_cpu_write (current_kprobe , & ri -> rp -> kp );
334- ri -> rp -> handler (ri , regs );
335- __this_cpu_write (current_kprobe , NULL );
336- }
337-
338- orig_ret_address = (unsigned long )ri -> ret_addr ;
339- recycle_rp_inst (ri , & empty_rp );
340-
341- if (orig_ret_address != trampoline_address )
342- /*
343- * This is the real return address. Any other
344- * instances associated with this task are for
345- * other calls deeper on the call stack
346- */
347- break ;
348- }
349-
350- kretprobe_assert (ri , orig_ret_address , trampoline_address );
351-
352- regs -> pc = orig_ret_address ;
353- kretprobe_hash_unlock (current , & flags );
354-
355- hlist_for_each_entry_safe (ri , tmp , & empty_rp , hlist ) {
356- hlist_del (& ri -> hlist );
357- kfree (ri );
358- }
359-
360- return orig_ret_address ;
308+ return 1 ;
361309}
362310
363311static int __kprobes post_kprobe_handler (struct pt_regs * regs )
0 commit comments