Skip to content

Commit 26a24a6

Browse files
mhiramatingomolnar
authored andcommitted
s390: 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/159870612453.1229682.15950927742606892302.stgit@devnote2
1 parent b6c5a58 commit 26a24a6

1 file changed

Lines changed: 2 additions & 77 deletions

File tree

arch/s390/kernel/kprobes.c

Lines changed: 2 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ NOKPROBE_SYMBOL(pop_kprobe);
228228
void arch_prepare_kretprobe(struct kretprobe_instance *ri, struct pt_regs *regs)
229229
{
230230
ri->ret_addr = (kprobe_opcode_t *) regs->gprs[14];
231+
ri->fp = NULL;
231232

232233
/* Replace the return addr with trampoline addr */
233234
regs->gprs[14] = (unsigned long) &kretprobe_trampoline;
@@ -331,83 +332,7 @@ static void __used kretprobe_trampoline_holder(void)
331332
*/
332333
static int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
333334
{
334-
struct kretprobe_instance *ri;
335-
struct hlist_head *head, empty_rp;
336-
struct hlist_node *tmp;
337-
unsigned long flags, orig_ret_address;
338-
unsigned long trampoline_address;
339-
kprobe_opcode_t *correct_ret_addr;
340-
341-
INIT_HLIST_HEAD(&empty_rp);
342-
kretprobe_hash_lock(current, &head, &flags);
343-
344-
/*
345-
* It is possible to have multiple instances associated with a given
346-
* task either because an multiple functions in the call path
347-
* have a return probe installed on them, and/or more than one return
348-
* return probe was registered for a target function.
349-
*
350-
* We can handle this because:
351-
* - instances are always inserted at the head of the list
352-
* - when multiple return probes are registered for the same
353-
* function, the first instance's ret_addr will point to the
354-
* real return address, and all the rest will point to
355-
* kretprobe_trampoline
356-
*/
357-
ri = NULL;
358-
orig_ret_address = 0;
359-
correct_ret_addr = NULL;
360-
trampoline_address = (unsigned long) &kretprobe_trampoline;
361-
hlist_for_each_entry_safe(ri, tmp, head, hlist) {
362-
if (ri->task != current)
363-
/* another task is sharing our hash bucket */
364-
continue;
365-
366-
orig_ret_address = (unsigned long) ri->ret_addr;
367-
368-
if (orig_ret_address != trampoline_address)
369-
/*
370-
* This is the real return address. Any other
371-
* instances associated with this task are for
372-
* other calls deeper on the call stack
373-
*/
374-
break;
375-
}
376-
377-
kretprobe_assert(ri, orig_ret_address, trampoline_address);
378-
379-
correct_ret_addr = ri->ret_addr;
380-
hlist_for_each_entry_safe(ri, tmp, head, hlist) {
381-
if (ri->task != current)
382-
/* another task is sharing our hash bucket */
383-
continue;
384-
385-
orig_ret_address = (unsigned long) ri->ret_addr;
386-
387-
if (ri->rp && ri->rp->handler) {
388-
ri->ret_addr = correct_ret_addr;
389-
ri->rp->handler(ri, regs);
390-
}
391-
392-
recycle_rp_inst(ri, &empty_rp);
393-
394-
if (orig_ret_address != trampoline_address)
395-
/*
396-
* This is the real return address. Any other
397-
* instances associated with this task are for
398-
* other calls deeper on the call stack
399-
*/
400-
break;
401-
}
402-
403-
regs->psw.addr = orig_ret_address;
404-
405-
kretprobe_hash_unlock(current, &flags);
406-
407-
hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
408-
hlist_del(&ri->hlist);
409-
kfree(ri);
410-
}
335+
regs->psw.addr = __kretprobe_trampoline_handler(regs, &kretprobe_trampoline, NULL);
411336
/*
412337
* By returning a non-zero value, we are telling
413338
* kprobe_handler() that we don't want the post_handler

0 commit comments

Comments
 (0)