From: Vyacheslav Cherkashin Date: Tue, 9 Apr 2013 10:10:45 +0000 (+0400) Subject: [IMPROVE] add entry_handler() in kretprobe X-Git-Tag: Tizen_SDK_2.3~561 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=057e8bff7763c4f622b27a3e0b701519dcffc466;p=kernel%2Fswap-modules.git [IMPROVE] add entry_handler() in kretprobe --- diff --git a/kprobe/arch/asm-arm/dbi_kprobes.c b/kprobe/arch/asm-arm/dbi_kprobes.c index 197bc1c..3acaf77 100644 --- a/kprobe/arch/asm-arm/dbi_kprobes.c +++ b/kprobe/arch/asm-arm/dbi_kprobes.c @@ -488,6 +488,11 @@ void arch_prepare_kretprobe(struct kretprobe *rp, struct pt_regs *regs) if ((ri = get_free_rp_inst(rp)) != NULL) { ri->rp = rp; ri->task = current; + + if (rp->entry_handler) { + rp->entry_handler(ri, regs, ri->rp->priv_arg); + } + ri->ret_addr = (kprobe_opcode_t *)regs->uregs[14]; ri->sp = (kprobe_opcode_t *)regs->ARM_sp; //uregs[13]; diff --git a/kprobe/dbi_kprobes.c b/kprobe/dbi_kprobes.c index 0fba5d5..fab4f28 100644 --- a/kprobe/dbi_kprobes.c +++ b/kprobe/dbi_kprobes.c @@ -613,6 +613,7 @@ int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs) spin_lock_irqsave(&kretprobe_lock, flags); if (!rp->disarm) arch_prepare_kretprobe(rp, regs); + spin_unlock_irqrestore(&kretprobe_lock, flags); DBPRINTF ("END\n"); return 0; @@ -645,7 +646,7 @@ int alloc_nodes_kretprobe(struct kretprobe *rp) } for (i = 0; i < alloc_nodes; i++) { - inst = kmalloc(sizeof(struct kretprobe_instance), GFP_ATOMIC); + inst = kmalloc(sizeof(inst) + rp->data_size, GFP_ATOMIC); if (inst == NULL) { free_rp_inst(rp); return -ENOMEM; @@ -689,7 +690,7 @@ int dbi_register_kretprobe(struct kretprobe *rp) INIT_HLIST_HEAD(&rp->used_instances); INIT_HLIST_HEAD(&rp->free_instances); for (i = 0; i < rp->maxactive; i++) { - inst = kmalloc(sizeof(struct kretprobe_instance), GFP_KERNEL); + inst = kmalloc(sizeof(*inst) + rp->data_size, GFP_KERNEL); if (inst == NULL) { free_rp_inst(rp); return -ENOMEM; diff --git a/kprobe/dbi_kprobes.h b/kprobe/dbi_kprobes.h index 44355e8..d193ede 100644 --- a/kprobe/dbi_kprobes.h +++ b/kprobe/dbi_kprobes.h @@ -186,10 +186,12 @@ struct kretprobe { struct kprobe kp; kretprobe_handler_t handler; + kretprobe_handler_t entry_handler; void *priv_arg; int maxactive; int nmissed; int disarm; + size_t data_size; struct hlist_head free_instances; struct hlist_head used_instances; }; @@ -203,6 +205,7 @@ struct kretprobe_instance kprobe_opcode_t *ret_addr; kprobe_opcode_t *sp; struct task_struct *task; + char data[0]; };