break;
}
kretprobe_assert (ri, orig_ret_address, trampoline_address);
- //BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address));
- //E.G. Check this code in case of __switch_to function instrumentation -- currently this code generates dump in this case
- //if (trampoline_address != (unsigned long) &kretprobe_trampoline){
- //if (ri->rp2) BUG_ON (ri->rp2->kp.tgid == 0);
- //if (ri->rp) BUG_ON (ri->rp->kp.tgid == 0);
- //else if (ri->rp2) BUG_ON (ri->rp2->kp.tgid == 0);
- //}
regs->uregs[14] = orig_ret_address;
DBPRINTF ("regs->uregs[14] = 0x%lx\n", regs->uregs[14]);
}
}
- //TODO: test - enter function, delete us retprobe, exit function
- // for user space retprobes only - deferred deletion
-
- if (trampoline_address != (unsigned long) &kretprobe_trampoline)
- {
- // if we are not at the end of the list and current retprobe should be disarmed
- if (node && ri->rp2)
- {
- struct hlist_node *current_node = node;
- crp = ri->rp2;
- /*sprintf(die_msg, "deferred disarm p->addr = %p [%lx %lx %lx]\n",
- crp->kp.addr, *kaddrs[0], *kaddrs[1], *kaddrs[2]);
- DIE(die_msg, regs); */
- // look for other instances for the same retprobe
- hlist_for_each_entry_safe (ri, node, tmp, head, hlist)
- {
- /*
- * Trying to find another retprobe instance associated with
- * the same retprobe.
- */
- if (ri->rp2 == crp && node != current_node)
- break;
- }
-
- if (!node)
- {
- // if there are no more instances for this retprobe
- // delete retprobe
- struct kprobe *is_p = &crp->kp;
- DBPRINTF ("defered retprobe deletion p->addr = %p", crp->kp.addr);
- /*
- If there is no any retprobe instances of this retprobe
- we can free the resources related to the probe.
- */
- if (!(hlist_unhashed(&is_p->is_hlist_arm))) {
- hlist_del_rcu(&is_p->is_hlist_arm);
- }
- if (!(hlist_unhashed(&is_p->is_hlist_thumb))) {
- hlist_del_rcu(&is_p->is_hlist_thumb);
- }
-
- dbi_unregister_kprobe(&crp->kp, current);
- kfree (crp);
- }
- hlist_del(current_node);
- }
- }
-
if (kcb->kprobe_status == KPROBE_REENTER) {
restore_previous_kprobe(kcb);
} else {
if ((ri = get_free_rp_inst (rp)) != NULL)
{
ri->rp = rp;
- ri->rp2 = NULL;
ri->task = current;
ri->ret_addr = (kprobe_opcode_t *) regs->uregs[14];
ri->sp = (kprobe_opcode_t *)regs->ARM_sp; //uregs[13];
kretprobe_assert (ri, orig_ret_address, trampoline_address);
//BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address));
if (trampoline_address != (unsigned long) &kretprobe_trampoline){
- if (ri->rp2) BUG_ON (ri->rp2->kp.tgid == 0);
if (ri->rp) BUG_ON (ri->rp->kp.tgid == 0);
- else if (ri->rp2) BUG_ON (ri->rp2->kp.tgid == 0);
}
- if ((ri->rp && ri->rp->kp.tgid) || (ri->rp2 && ri->rp2->kp.tgid))
+ if (ri->rp && ri->rp->kp.tgid)
BUG_ON (trampoline_address == (unsigned long) &kretprobe_trampoline);
regs->regs[31] = orig_ret_address;
restore_previous_kprobe (kcb);
else
reset_current_kprobe ();
-
- //TODO: test - enter function, delete us retprobe, exit function
- // for user space retprobes only - deferred deletion
- if (trampoline_address != (unsigned long) &kretprobe_trampoline)
- {
- // if we are not at the end of the list and current retprobe should be disarmed
- if (node && ri->rp2)
- {
- crp = ri->rp2;
- /*sprintf(die_msg, "deferred disarm p->addr = %p [%lx %lx %lx]\n",
- crp->kp.addr, *kaddrs[0], *kaddrs[1], *kaddrs[2]);
- DIE(die_msg, regs); */
- // look for other instances for the same retprobe
- hlist_for_each_entry_continue (ri, node, hlist)
- {
- if (ri->task != current)
- continue; /* another task is sharing our hash bucket */
- if (ri->rp2 == crp) //if instance belong to the same retprobe
- break;
- }
- if (!node)
- { // if there are no more instances for this retprobe
- // delete retprobe
- DBPRINTF ("defered retprobe deletion p->addr = %p", crp->kp.addr);
- unregister_uprobe (&crp->kp, current, 1);
- kfree (crp);
- }
- }
- }
}
spin_unlock_irqrestore (&kretprobe_lock, flags);
if ((ri = get_free_rp_inst (rp)) != NULL)
{
ri->rp = rp;
- ri->rp2 = NULL;
ri->task = current;
ri->ret_addr = (kprobe_opcode_t *) regs->regs[31];
if (rp->kp.tgid)
kretprobe_assert (ri, orig_ret_address, trampoline_address);
//BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address));
if (trampoline_address != (unsigned long) &kretprobe_trampoline){
- if (ri->rp2) BUG_ON (ri->rp2->kp.tgid == 0);
if (ri->rp) BUG_ON (ri->rp->kp.tgid == 0);
- else if (ri->rp2) BUG_ON (ri->rp2->kp.tgid == 0);
}
- if ((ri->rp && ri->rp->kp.tgid) || (ri->rp2 && ri->rp2->kp.tgid))
+ if (ri->rp && ri->rp->kp.tgid)
BUG_ON (trampoline_address == (unsigned long) &kretprobe_trampoline);
if(p){ // X86 user space
restore_previous_kprobe (kcb);
else
reset_current_kprobe ();
-
- //TODO: test - enter function, delete us retprobe, exit function
- // for user space retprobes only - deferred deletion
- if (trampoline_address != (unsigned long) &kretprobe_trampoline)
- {
- // if we are not at the end of the list and current retprobe should be disarmed
- if (node && ri->rp2)
- {
- struct hlist_node *current_node = node;
- crp = ri->rp2;
- /*sprintf(die_msg, "deferred disarm p->addr = %p [%lx %lx %lx]\n",
- crp->kp.addr, *kaddrs[0], *kaddrs[1], *kaddrs[2]);
- DIE(die_msg, regs); */
- // look for other instances for the same retprobe
- hlist_for_each_entry_safe (ri, node, tmp, head, hlist)
- {
- /*
- * Trying to find another retprobe instance associated with
- * the same retprobe.
- */
- if (ri->rp2 == crp && node != current_node)
- break;
- }
- if (!node)
- { // if there are no more instances for this retprobe
- // delete retprobe
- DBPRINTF ("defered retprobe deletion p->addr = %p", crp->kp.addr);
- /*
- If there is no any retprobe instances of this retprobe
- we can free the resources related to the probe.
- */
- struct kprobe *is_p = &crp->kp;
- if (!(hlist_unhashed(&is_p->is_hlist))) {
- hlist_del_rcu(&is_p->is_hlist);
- }
- unregister_uprobe (&crp->kp, current, 1);
- kfree (crp);
- }
- hlist_del(current_node);
- }
- }
}
hlist_for_each_entry_safe (ri, node, tmp, &empty_rp, hlist)
if ((ri = get_free_rp_inst (rp)) != NULL)
{
ri->rp = rp;
- ri->rp2 = NULL;
ri->task = current;
ri->sp = (kprobe_opcode_t *)regs->EREG(sp);
/* put rp inst back onto the free list */
INIT_HLIST_NODE(&ri->uflist);
hlist_add_head(&ri->uflist, &ri->rp->free_instances);
- } else if (!ri->rp2) {
- /*
- * This is __switch_to retprobe instance. It has neither rp nor rp2.
- */
- hlist_del(&ri->hlist);
}
}
EXPORT_SYMBOL_GPL(recycle_rp_inst);
return -ENOMEM;
ri->rp = rp;
- ri->rp2 = NULL;
ri->task = task;
ri->sp = NULL;
set_task_trampoline(task, ri, (unsigned long)tramp);
struct kretprobe *rp;
kprobe_opcode_t *ret_addr;
kprobe_opcode_t *sp;
- struct kretprobe *rp2;
struct task_struct *task;
};