Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23052
b: refs/heads/master
c: 7a7d1cf
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Mar 23, 2006
1 parent 3630038 commit daba2f6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2c68ee754c40099c59828e59618a54726f76126a
refs/heads/master: 7a7d1cf95408863a657035701606b13644c9f55e
4 changes: 2 additions & 2 deletions trunk/arch/i386/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)

void __kprobes arch_remove_kprobe(struct kprobe *p)
{
down(&kprobe_mutex);
mutex_lock(&kprobe_mutex);
free_insn_slot(p->ainsn.insn);
up(&kprobe_mutex);
mutex_unlock(&kprobe_mutex);
}

static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/powerpc/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)

void __kprobes arch_remove_kprobe(struct kprobe *p)
{
down(&kprobe_mutex);
mutex_lock(&kprobe_mutex);
free_insn_slot(p->ainsn.insn);
up(&kprobe_mutex);
mutex_unlock(&kprobe_mutex);
}

static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/x86_64/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)

void __kprobes arch_remove_kprobe(struct kprobe *p)
{
down(&kprobe_mutex);
mutex_lock(&kprobe_mutex);
free_insn_slot(p->ainsn.insn);
up(&kprobe_mutex);
mutex_unlock(&kprobe_mutex);
}

static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
Expand Down
3 changes: 2 additions & 1 deletion trunk/include/linux/kprobes.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <linux/percpu.h>
#include <linux/spinlock.h>
#include <linux/rcupdate.h>
#include <linux/mutex.h>

#ifdef CONFIG_KPROBES
#include <asm/kprobes.h>
Expand Down Expand Up @@ -152,7 +153,7 @@ struct kretprobe_instance {
};

extern spinlock_t kretprobe_lock;
extern struct semaphore kprobe_mutex;
extern struct mutex kprobe_mutex;
extern int arch_prepare_kprobe(struct kprobe *p);
extern void arch_arm_kprobe(struct kprobe *p);
extern void arch_disarm_kprobe(struct kprobe *p);
Expand Down
14 changes: 7 additions & 7 deletions trunk/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE];
static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE];

DECLARE_MUTEX(kprobe_mutex); /* Protects kprobe_table */
DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */
DEFINE_SPINLOCK(kretprobe_lock); /* Protects kretprobe_inst_table */
static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL;

Expand Down Expand Up @@ -460,7 +460,7 @@ static int __kprobes __register_kprobe(struct kprobe *p,
}

p->nmissed = 0;
down(&kprobe_mutex);
mutex_lock(&kprobe_mutex);
old_p = get_kprobe(p->addr);
if (old_p) {
ret = register_aggr_kprobe(old_p, p);
Expand All @@ -477,7 +477,7 @@ static int __kprobes __register_kprobe(struct kprobe *p,
arch_arm_kprobe(p);

out:
up(&kprobe_mutex);
mutex_unlock(&kprobe_mutex);

if (ret && probed_mod)
module_put(probed_mod);
Expand All @@ -496,18 +496,18 @@ void __kprobes unregister_kprobe(struct kprobe *p)
struct kprobe *old_p, *list_p;
int cleanup_p;

down(&kprobe_mutex);
mutex_lock(&kprobe_mutex);
old_p = get_kprobe(p->addr);
if (unlikely(!old_p)) {
up(&kprobe_mutex);
mutex_unlock(&kprobe_mutex);
return;
}
if (p != old_p) {
list_for_each_entry_rcu(list_p, &old_p->list, list)
if (list_p == p)
/* kprobe p is a valid probe */
goto valid_p;
up(&kprobe_mutex);
mutex_unlock(&kprobe_mutex);
return;
}
valid_p:
Expand All @@ -523,7 +523,7 @@ void __kprobes unregister_kprobe(struct kprobe *p)
cleanup_p = 0;
}

up(&kprobe_mutex);
mutex_unlock(&kprobe_mutex);

synchronize_sched();
if (p->mod_refcounted &&
Expand Down

0 comments on commit daba2f6

Please sign in to comment.