From fd678182efbc51ec5412568c2bb79ecb767428b8 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Tue, 12 Mar 2013 13:18:21 +0400 Subject: [PATCH] [REFACTOR] add parameter page_list in get_insn_slot() --- kprobe/arch/asm-arm/dbi_kprobes.c | 2 +- kprobe/dbi_insn_slots.c | 3 +-- kprobe/dbi_insn_slots.h | 2 +- uprobe/arch/asm-arm/swap_uprobes.c | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/kprobe/arch/asm-arm/dbi_kprobes.c b/kprobe/arch/asm-arm/dbi_kprobes.c index ac0690a..9fd3494 100644 --- a/kprobe/arch/asm-arm/dbi_kprobes.c +++ b/kprobe/arch/asm-arm/dbi_kprobes.c @@ -226,7 +226,7 @@ int arch_prepare_kprobe (struct kprobe *p) struct arch_specific_insn ainsn; /* insn: must be on special executable page on i386. */ - p->ainsn.insn = get_insn_slot (NULL, 0); + p->ainsn.insn = get_insn_slot(NULL, &kprobe_insn_pages, 0); if (!p->ainsn.insn) return -ENOMEM; diff --git a/kprobe/dbi_insn_slots.c b/kprobe/dbi_insn_slots.c index 88095bd..bb12871 100644 --- a/kprobe/dbi_insn_slots.c +++ b/kprobe/dbi_insn_slots.c @@ -262,12 +262,11 @@ static void kip_free(struct kprobe_insn_page * kip) * get_us_insn_slot() - Find a slot on an executable page for an instruction. * We allocate an executable page if there's no room on existing ones. */ -kprobe_opcode_t *get_insn_slot(struct task_struct *task, int atomic) +kprobe_opcode_t *get_insn_slot(struct task_struct *task, struct hlist_head *page_list, int atomic) { kprobe_opcode_t * free_slot; struct kprobe_insn_page *kip; struct hlist_node *pos; - struct hlist_head *page_list = task ? &uprobe_insn_pages : &kprobe_insn_pages; hlist_for_each_entry_rcu(kip, pos, page_list, hlist) { if (!task || (kip->task->tgid == task->tgid)) { diff --git a/kprobe/dbi_insn_slots.h b/kprobe/dbi_insn_slots.h index a18c520..b6113ca 100644 --- a/kprobe/dbi_insn_slots.h +++ b/kprobe/dbi_insn_slots.h @@ -51,7 +51,7 @@ #include "dbi_kprobes.h" -kprobe_opcode_t *get_insn_slot(struct task_struct *task, int atomic); +kprobe_opcode_t *get_insn_slot(struct task_struct *task, struct hlist_head *page_list, int atomic); void free_insn_slot(struct hlist_head *page_list, struct task_struct *task, kprobe_opcode_t *slot); extern struct hlist_head kprobe_insn_pages; diff --git a/uprobe/arch/asm-arm/swap_uprobes.c b/uprobe/arch/asm-arm/swap_uprobes.c index 2e39530..6a9ce9d 100644 --- a/uprobe/arch/asm-arm/swap_uprobes.c +++ b/uprobe/arch/asm-arm/swap_uprobes.c @@ -5,7 +5,7 @@ // FIXME: #include extern struct hlist_head uprobe_insn_pages; -kprobe_opcode_t *get_insn_slot(struct task_struct *task, int atomic); +kprobe_opcode_t *get_insn_slot(struct task_struct *task, struct hlist_head *page_list, int atomic); int arch_check_insn_arm(struct arch_specific_insn *ainsn); int prep_pc_dep_insn_execbuf(kprobe_opcode_t *insns, kprobe_opcode_t insn, int uregs); void free_insn_slot(struct hlist_head *page_list, struct task_struct *task, kprobe_opcode_t *slot); @@ -544,7 +544,7 @@ int arch_prepare_uprobe(struct kprobe *p, struct task_struct *task, int atomic) } p->opcode = insn[0]; - p->ainsn.insn_arm = get_insn_slot(task, atomic); + p->ainsn.insn_arm = get_insn_slot(task, &uprobe_insn_pages, atomic); if (!p->ainsn.insn_arm) { printk("Error in %s at %d: kprobe slot allocation error (arm)\n", __FILE__, __LINE__); return -ENOMEM; @@ -556,7 +556,7 @@ int arch_prepare_uprobe(struct kprobe *p, struct task_struct *task, int atomic) return -EFAULT; } - p->ainsn.insn_thumb = get_insn_slot(task, atomic); + p->ainsn.insn_thumb = get_insn_slot(task, &uprobe_insn_pages, atomic); if (!p->ainsn.insn_thumb) { printk("Error in %s at %d: kprobe slot allocation error (thumb)\n", __FILE__, __LINE__); return -ENOMEM; -- 2.7.4