提交 89480801 编写于 作者: M Martin Schwidefsky 提交者: Martin Schwidefsky

[S390] kprobes: Fix the return address of multiple kretprobes

Analog to git commit 737480a0
fix the return address of subsequent kretprobes when multiple
kretprobes are set on the same function.
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
上级 adb45839
...@@ -349,6 +349,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p, ...@@ -349,6 +349,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
struct hlist_node *node, *tmp; struct hlist_node *node, *tmp;
unsigned long flags, orig_ret_address = 0; unsigned long flags, orig_ret_address = 0;
unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline; unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline;
kprobe_opcode_t *correct_ret_addr = NULL;
INIT_HLIST_HEAD(&empty_rp); INIT_HLIST_HEAD(&empty_rp);
kretprobe_hash_lock(current, &head, &flags); kretprobe_hash_lock(current, &head, &flags);
...@@ -371,10 +372,32 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p, ...@@ -371,10 +372,32 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
/* another task is sharing our hash bucket */ /* another task is sharing our hash bucket */
continue; continue;
if (ri->rp && ri->rp->handler) orig_ret_address = (unsigned long)ri->ret_addr;
ri->rp->handler(ri, regs);
if (orig_ret_address != trampoline_address)
/*
* This is the real return address. Any other
* instances associated with this task are for
* other calls deeper on the call stack
*/
break;
}
kretprobe_assert(ri, orig_ret_address, trampoline_address);
correct_ret_addr = ri->ret_addr;
hlist_for_each_entry_safe(ri, node, tmp, head, hlist) {
if (ri->task != current)
/* another task is sharing our hash bucket */
continue;
orig_ret_address = (unsigned long)ri->ret_addr; orig_ret_address = (unsigned long)ri->ret_addr;
if (ri->rp && ri->rp->handler) {
ri->ret_addr = correct_ret_addr;
ri->rp->handler(ri, regs);
}
recycle_rp_inst(ri, &empty_rp); recycle_rp_inst(ri, &empty_rp);
if (orig_ret_address != trampoline_address) { if (orig_ret_address != trampoline_address) {
...@@ -386,7 +409,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p, ...@@ -386,7 +409,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
break; break;
} }
} }
kretprobe_assert(ri, orig_ret_address, trampoline_address);
regs->psw.addr = orig_ret_address | PSW_ADDR_AMODE; regs->psw.addr = orig_ret_address | PSW_ADDR_AMODE;
reset_current_kprobe(); reset_current_kprobe();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册