aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64
diff options
context:
space:
mode:
authorbibo,mao <bibo.mao@intel.com>2006-10-02 05:17:35 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-02 10:57:16 -0400
commit99219a3fbc2dcf2eaa954f7b2ac27299fd7894cd (patch)
tree895abde156c9fbeea9c5a87cfaaa411d4ad175c6 /arch/x86_64
parentf2aa85a0ccd90110e76c6375535adc3ae358f971 (diff)
[PATCH] kretprobe spinlock deadlock patch
kprobe_flush_task() possibly calls kfree function during holding kretprobe_lock spinlock, if kfree function is probed by kretprobe that will incur spinlock deadlock. This patch moves kfree function out scope of kretprobe_lock. Signed-off-by: bibo, mao <bibo.mao@intel.com> Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/x86_64')
-rw-r--r--arch/x86_64/kernel/kprobes.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index d04f0ab2ff40..ac241567e682 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -405,11 +405,12 @@ no_kprobe:
405int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs) 405int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
406{ 406{
407 struct kretprobe_instance *ri = NULL; 407 struct kretprobe_instance *ri = NULL;
408 struct hlist_head *head; 408 struct hlist_head *head, empty_rp;
409 struct hlist_node *node, *tmp; 409 struct hlist_node *node, *tmp;
410 unsigned long flags, orig_ret_address = 0; 410 unsigned long flags, orig_ret_address = 0;
411 unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline; 411 unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline;
412 412
413 INIT_HLIST_HEAD(&empty_rp);
413 spin_lock_irqsave(&kretprobe_lock, flags); 414 spin_lock_irqsave(&kretprobe_lock, flags);
414 head = kretprobe_inst_table_head(current); 415 head = kretprobe_inst_table_head(current);
415 416
@@ -435,7 +436,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
435 ri->rp->handler(ri, regs); 436 ri->rp->handler(ri, regs);
436 437
437 orig_ret_address = (unsigned long)ri->ret_addr; 438 orig_ret_address = (unsigned long)ri->ret_addr;
438 recycle_rp_inst(ri); 439 recycle_rp_inst(ri, &empty_rp);
439 440
440 if (orig_ret_address != trampoline_address) 441 if (orig_ret_address != trampoline_address)
441 /* 442 /*
@@ -453,6 +454,10 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
453 spin_unlock_irqrestore(&kretprobe_lock, flags); 454 spin_unlock_irqrestore(&kretprobe_lock, flags);
454 preempt_enable_no_resched(); 455 preempt_enable_no_resched();
455 456
457 hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
458 hlist_del(&ri->hlist);
459 kfree(ri);
460 }
456 /* 461 /*
457 * By returning a non-zero value, we are telling 462 * By returning a non-zero value, we are telling
458 * kprobe_handler() that we don't want the post_handler 463 * kprobe_handler() that we don't want the post_handler