aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhang, Yanmin <yanmin.zhang@intel.com>2005-09-30 14:59:20 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-30 15:41:20 -0400
commit2dd960d66bc12b6b206e63104636514e5da0ddb7 (patch)
tree07fc074809ad2028891201f10b0279d3280da5e6
parent32e7a04faa29f50f65e06d43a9029bb607743e76 (diff)
[PATCH] utilization of kprobe_mutex is incorrect on x86_64
The up()/down() orders are incorrect in arch/x86_64/kprobes.c file. kprobe_mutext is used to protect the free kprobe instruction slot list. arch_prepare_kprobe applies for a slot from the free list, and arch_remove_kprobe returns a slot to the free list. The incorrect up()/down() orders to operate on kprobe_mutex fail to protect the free list. If 2 threads try to get/return kprobe instruction slot at the same time, the free slot list might be broken, or a free slot might be applied by 2 threads. Signed-off-by: Zhang Yanmin <Yanmin.zhang@intel.com> Cc: Andi Kleen <ak@muc.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--arch/x86_64/kernel/kprobes.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index df08c43276a0..76a28b007be9 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -77,9 +77,9 @@ static inline int is_IF_modifier(kprobe_opcode_t *insn)
77int __kprobes arch_prepare_kprobe(struct kprobe *p) 77int __kprobes arch_prepare_kprobe(struct kprobe *p)
78{ 78{
79 /* insn: must be on special executable page on x86_64. */ 79 /* insn: must be on special executable page on x86_64. */
80 up(&kprobe_mutex);
81 p->ainsn.insn = get_insn_slot();
82 down(&kprobe_mutex); 80 down(&kprobe_mutex);
81 p->ainsn.insn = get_insn_slot();
82 up(&kprobe_mutex);
83 if (!p->ainsn.insn) { 83 if (!p->ainsn.insn) {
84 return -ENOMEM; 84 return -ENOMEM;
85 } 85 }
@@ -231,9 +231,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
231 231
232void __kprobes arch_remove_kprobe(struct kprobe *p) 232void __kprobes arch_remove_kprobe(struct kprobe *p)
233{ 233{
234 up(&kprobe_mutex);
235 free_insn_slot(p->ainsn.insn);
236 down(&kprobe_mutex); 234 down(&kprobe_mutex);
235 free_insn_slot(p->ainsn.insn);
236 up(&kprobe_mutex);
237} 237}
238 238
239static inline void save_previous_kprobe(void) 239static inline void save_previous_kprobe(void)