diff options
-rw-r--r-- | arch/i386/kernel/kprobes.c | 4 | ||||
-rw-r--r-- | arch/powerpc/kernel/kprobes.c | 4 | ||||
-rw-r--r-- | arch/x86_64/kernel/kprobes.c | 4 | ||||
-rw-r--r-- | include/linux/kprobes.h | 3 | ||||
-rw-r--r-- | kernel/kprobes.c | 14 |
5 files changed, 15 insertions, 14 deletions
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c index 694a13997637..7a59050242a7 100644 --- a/arch/i386/kernel/kprobes.c +++ b/arch/i386/kernel/kprobes.c | |||
@@ -84,9 +84,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) | |||
84 | 84 | ||
85 | void __kprobes arch_remove_kprobe(struct kprobe *p) | 85 | void __kprobes arch_remove_kprobe(struct kprobe *p) |
86 | { | 86 | { |
87 | down(&kprobe_mutex); | 87 | mutex_lock(&kprobe_mutex); |
88 | free_insn_slot(p->ainsn.insn); | 88 | free_insn_slot(p->ainsn.insn); |
89 | up(&kprobe_mutex); | 89 | mutex_unlock(&kprobe_mutex); |
90 | } | 90 | } |
91 | 91 | ||
92 | static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) | 92 | static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) |
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index 258039fb3016..cb1fe5878e8b 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c | |||
@@ -81,9 +81,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) | |||
81 | 81 | ||
82 | void __kprobes arch_remove_kprobe(struct kprobe *p) | 82 | void __kprobes arch_remove_kprobe(struct kprobe *p) |
83 | { | 83 | { |
84 | down(&kprobe_mutex); | 84 | mutex_lock(&kprobe_mutex); |
85 | free_insn_slot(p->ainsn.insn); | 85 | free_insn_slot(p->ainsn.insn); |
86 | up(&kprobe_mutex); | 86 | mutex_unlock(&kprobe_mutex); |
87 | } | 87 | } |
88 | 88 | ||
89 | static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) | 89 | static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) |
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c index 8b866a8572cf..14f0ced613b6 100644 --- a/arch/x86_64/kernel/kprobes.c +++ b/arch/x86_64/kernel/kprobes.c | |||
@@ -222,9 +222,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) | |||
222 | 222 | ||
223 | void __kprobes arch_remove_kprobe(struct kprobe *p) | 223 | void __kprobes arch_remove_kprobe(struct kprobe *p) |
224 | { | 224 | { |
225 | down(&kprobe_mutex); | 225 | mutex_lock(&kprobe_mutex); |
226 | free_insn_slot(p->ainsn.insn); | 226 | free_insn_slot(p->ainsn.insn); |
227 | up(&kprobe_mutex); | 227 | mutex_unlock(&kprobe_mutex); |
228 | } | 228 | } |
229 | 229 | ||
230 | static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) | 230 | static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) |
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index 669756bc20a2..778adc0fa640 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/percpu.h> | 36 | #include <linux/percpu.h> |
37 | #include <linux/spinlock.h> | 37 | #include <linux/spinlock.h> |
38 | #include <linux/rcupdate.h> | 38 | #include <linux/rcupdate.h> |
39 | #include <linux/mutex.h> | ||
39 | 40 | ||
40 | #ifdef CONFIG_KPROBES | 41 | #ifdef CONFIG_KPROBES |
41 | #include <asm/kprobes.h> | 42 | #include <asm/kprobes.h> |
@@ -152,7 +153,7 @@ struct kretprobe_instance { | |||
152 | }; | 153 | }; |
153 | 154 | ||
154 | extern spinlock_t kretprobe_lock; | 155 | extern spinlock_t kretprobe_lock; |
155 | extern struct semaphore kprobe_mutex; | 156 | extern struct mutex kprobe_mutex; |
156 | extern int arch_prepare_kprobe(struct kprobe *p); | 157 | extern int arch_prepare_kprobe(struct kprobe *p); |
157 | extern void arch_arm_kprobe(struct kprobe *p); | 158 | extern void arch_arm_kprobe(struct kprobe *p); |
158 | extern void arch_disarm_kprobe(struct kprobe *p); | 159 | extern void arch_disarm_kprobe(struct kprobe *p); |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index fef1af8a73ce..1fb9f753ef60 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -48,7 +48,7 @@ | |||
48 | static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE]; | 48 | static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE]; |
49 | static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE]; | 49 | static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE]; |
50 | 50 | ||
51 | DECLARE_MUTEX(kprobe_mutex); /* Protects kprobe_table */ | 51 | DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */ |
52 | DEFINE_SPINLOCK(kretprobe_lock); /* Protects kretprobe_inst_table */ | 52 | DEFINE_SPINLOCK(kretprobe_lock); /* Protects kretprobe_inst_table */ |
53 | static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL; | 53 | static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL; |
54 | 54 | ||
@@ -460,7 +460,7 @@ static int __kprobes __register_kprobe(struct kprobe *p, | |||
460 | } | 460 | } |
461 | 461 | ||
462 | p->nmissed = 0; | 462 | p->nmissed = 0; |
463 | down(&kprobe_mutex); | 463 | mutex_lock(&kprobe_mutex); |
464 | old_p = get_kprobe(p->addr); | 464 | old_p = get_kprobe(p->addr); |
465 | if (old_p) { | 465 | if (old_p) { |
466 | ret = register_aggr_kprobe(old_p, p); | 466 | ret = register_aggr_kprobe(old_p, p); |
@@ -477,7 +477,7 @@ static int __kprobes __register_kprobe(struct kprobe *p, | |||
477 | arch_arm_kprobe(p); | 477 | arch_arm_kprobe(p); |
478 | 478 | ||
479 | out: | 479 | out: |
480 | up(&kprobe_mutex); | 480 | mutex_unlock(&kprobe_mutex); |
481 | 481 | ||
482 | if (ret && probed_mod) | 482 | if (ret && probed_mod) |
483 | module_put(probed_mod); | 483 | module_put(probed_mod); |
@@ -496,10 +496,10 @@ void __kprobes unregister_kprobe(struct kprobe *p) | |||
496 | struct kprobe *old_p, *list_p; | 496 | struct kprobe *old_p, *list_p; |
497 | int cleanup_p; | 497 | int cleanup_p; |
498 | 498 | ||
499 | down(&kprobe_mutex); | 499 | mutex_lock(&kprobe_mutex); |
500 | old_p = get_kprobe(p->addr); | 500 | old_p = get_kprobe(p->addr); |
501 | if (unlikely(!old_p)) { | 501 | if (unlikely(!old_p)) { |
502 | up(&kprobe_mutex); | 502 | mutex_unlock(&kprobe_mutex); |
503 | return; | 503 | return; |
504 | } | 504 | } |
505 | if (p != old_p) { | 505 | if (p != old_p) { |
@@ -507,7 +507,7 @@ void __kprobes unregister_kprobe(struct kprobe *p) | |||
507 | if (list_p == p) | 507 | if (list_p == p) |
508 | /* kprobe p is a valid probe */ | 508 | /* kprobe p is a valid probe */ |
509 | goto valid_p; | 509 | goto valid_p; |
510 | up(&kprobe_mutex); | 510 | mutex_unlock(&kprobe_mutex); |
511 | return; | 511 | return; |
512 | } | 512 | } |
513 | valid_p: | 513 | valid_p: |
@@ -523,7 +523,7 @@ valid_p: | |||
523 | cleanup_p = 0; | 523 | cleanup_p = 0; |
524 | } | 524 | } |
525 | 525 | ||
526 | up(&kprobe_mutex); | 526 | mutex_unlock(&kprobe_mutex); |
527 | 527 | ||
528 | synchronize_sched(); | 528 | synchronize_sched(); |
529 | if (p->mod_refcounted && | 529 | if (p->mod_refcounted && |