From 213aa8b2bc0baff985db79cd7ed6d4ceb95e18e5 Mon Sep 17 00:00:00 2001 From: Alexander Aksenov Date: Thu, 14 Feb 2013 20:27:46 +0400 Subject: [PATCH] Fix new sparce warnings in kprobe --- kprobe/arch/asm-x86/dbi_kprobes.c | 2 -- kprobe/arch/dbi_kprobes.c | 4 ---- kprobe/dbi_kprobes.c | 17 ++++++++--------- kprobe/dbi_kprobes_deps.h | 1 + kprobe/dbi_uprobes.c | 17 +++++++++-------- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/kprobe/arch/asm-x86/dbi_kprobes.c b/kprobe/arch/asm-x86/dbi_kprobes.c index 990e400..7f87eac 100644 --- a/kprobe/arch/asm-x86/dbi_kprobes.c +++ b/kprobe/arch/asm-x86/dbi_kprobes.c @@ -63,8 +63,6 @@ #define SUPRESS_BUG_MESSAGES -extern unsigned long exit_addr; - extern struct kprobe * per_cpu__current_kprobe; extern struct kprobe * per_cpu__current_kprobe; diff --git a/kprobe/arch/dbi_kprobes.c b/kprobe/arch/dbi_kprobes.c index c923035..3036c34 100644 --- a/kprobe/arch/dbi_kprobes.c +++ b/kprobe/arch/dbi_kprobes.c @@ -58,10 +58,6 @@ #include #include -extern unsigned long sched_addr; -extern unsigned long fork_addr; -extern unsigned long exit_addr; - extern struct hlist_head kprobe_insn_pages; extern struct hlist_head uprobe_insn_pages; diff --git a/kprobe/dbi_kprobes.c b/kprobe/dbi_kprobes.c index b98c81f..32abe12 100644 --- a/kprobe/dbi_kprobes.c +++ b/kprobe/dbi_kprobes.c @@ -68,9 +68,6 @@ #include #include -extern unsigned long sched_addr; -extern unsigned long fork_addr; -extern unsigned long exit_addr; extern struct hlist_head kprobe_insn_pages; DEFINE_PER_CPU (struct kprobe *, current_kprobe) = NULL; @@ -744,7 +741,8 @@ void dbi_unregister_kretprobe (struct kretprobe *rp) recycle_rp_inst(ri); else panic("%s (%d/%d): cannot disarm krp instance (%08lx)", - ri->task->comm, ri->task->tgid, ri->task->pid, rp->kp.addr); + ri->task->comm, ri->task->tgid, ri->task->pid, + (unsigned long)rp->kp.addr); } spin_unlock_irqrestore (&kretprobe_lock, flags); free_rp_inst (rp); @@ -792,12 +790,12 @@ static int dbi_disarm_krp_inst(struct kretprobe_instance *ri) if (!sp) { printk("---> %s (%d/%d) sp == NULL (%08lx)!!!!\n", ri->task->comm, ri->task->tgid, ri->task->pid, - ri->rp ? ri->rp->kp.addr: NULL); + (unsigned long)(ri->rp ? ri->rp->kp.addr: NULL)); return -EINVAL; } while (sp > ri->sp - RETPROBE_STACK_DEPTH) { - if (*sp == tramp) { + if ((unsigned long)*sp == (unsigned long)tramp) { found = sp; break; } @@ -807,13 +805,14 @@ static int dbi_disarm_krp_inst(struct kretprobe_instance *ri) if (found) { printk("---> %s (%d/%d): trampoline found at %08lx (%08lx /%+d) - %p\n", ri->task->comm, ri->task->tgid, ri->task->pid, - found, ri->sp, found - ri->sp, ri->rp ? ri->rp->kp.addr: NULL); - *found = ri->ret_addr; + (unsigned long)found, (unsigned long)ri->sp, found - ri->sp, + ri->rp ? ri->rp->kp.addr: NULL); + *found = (unsigned long)ri->ret_addr; retval = 0; } else { printk("---> %s (%d/%d): trampoline NOT found at sp = %08lx - %p\n", ri->task->comm, ri->task->tgid, ri->task->pid, - ri->sp, ri->rp ? ri->rp->kp.addr: NULL); + (unsigned long)ri->sp, ri->rp ? ri->rp->kp.addr: NULL); } return retval; diff --git a/kprobe/dbi_kprobes_deps.h b/kprobe/dbi_kprobes_deps.h index f6c2286..20f3606 100644 --- a/kprobe/dbi_kprobes_deps.h +++ b/kprobe/dbi_kprobes_deps.h @@ -92,6 +92,7 @@ int page_present (struct mm_struct *mm, unsigned long addr); extern unsigned long sched_addr; extern unsigned long fork_addr; +extern unsigned long exit_addr; DECLARE_MOD_DEP_WRAPPER (__flush_anon_page, \ diff --git a/kprobe/dbi_uprobes.c b/kprobe/dbi_uprobes.c index d13b990..3eebb7a 100644 --- a/kprobe/dbi_uprobes.c +++ b/kprobe/dbi_uprobes.c @@ -280,17 +280,17 @@ static int dbi_disarm_urp_inst(struct kretprobe_instance *ri) kprobe_opcode_t *buf[RETPROBE_STACK_DEPTH]; int i, retval; - retval = read_proc_vm_atomic(task, stack, buf, sizeof(buf)); + retval = read_proc_vm_atomic(task, (unsigned long)stack, buf, sizeof(buf)); if (retval != sizeof(buf)) { printk("---> %s (%d/%d): failed to read stack from %08lx", - task->comm, task->tgid, task->pid, stack); + task->comm, task->tgid, task->pid, (unsigned long)stack); retval = -EFAULT; goto out; } /* search the stack from the bottom */ for (i = RETPROBE_STACK_DEPTH - 1; i >= 0; i--) { - if (buf[i] = tramp) { + if (buf[i] == tramp) { found = stack + i; break; } @@ -299,19 +299,19 @@ static int dbi_disarm_urp_inst(struct kretprobe_instance *ri) if (found) { printk("---> %s (%d/%d): trampoline found at %08lx (%08lx /%+d) - %p\n", task->comm, task->tgid, task->pid, - found, ri->sp, found - ri->sp, ri->rp->kp.addr); - retval = write_proc_vm_atomic(task, found, &ri->ret_addr, + (unsigned long)found, (unsigned long)ri->sp, found - ri->sp, ri->rp->kp.addr); + retval = write_proc_vm_atomic(task, (unsigned long)found, &ri->ret_addr, sizeof(ri->ret_addr)); if (retval != sizeof(ri->ret_addr)) { printk("---> %s (%d/%d): failed to write value to %08lx", - task->comm, task->tgid, task->pid, found); + task->comm, task->tgid, task->pid, (unsigned long)found); retval = -EFAULT; } else { retval = 0; } } else { printk("---> %s (%d/%d): trampoline NOT found at sp = %08lx - %p\n", - task->comm, task->tgid, task->pid, ri->sp, ri->rp->kp.addr); + task->comm, task->tgid, task->pid, (unsigned long)ri->sp, ri->rp->kp.addr); retval = -ENOENT; } @@ -332,7 +332,8 @@ void dbi_unregister_uretprobe(struct task_struct *task, struct kretprobe *rp, in recycle_rp_inst(ri); else panic("%s (%d/%d): cannot disarm urp instance (%08lx)", - ri->task->comm, ri->task->tgid, ri->task->pid, rp->kp.addr); + ri->task->comm, ri->task->tgid, ri->task->pid, + (unsigned long)rp->kp.addr); } if (hlist_empty(&rp->used_instances) || not_rp2) { -- 2.7.4