提交 278ff953 编写于 作者: A Ananth N Mavinakayanahalli 提交者: Linus Torvalds

[PATCH] Kprobes: Fix deadlock in function-return probes

When two function-return probes are inserted on kfree()[1] and the second
on say, sys_link()[2], and later [2] is unregistered, we have a deadlock as
kfree is called with the kretprobe_lock held and the function-return probe
on kfree will also try to grab the same lock.

However, we can move the kfree() during unregistration to outside the
spinlock as we are sure that no instances from the free list will be used
after synchronized_sched() returns during the unregistration process.
Thanks to Masami Hiramatsu for spotting this.
Signed-off-by: NAnanth N Mavinakayanahalli <ananth@in.ibm.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 e65cefe8
...@@ -631,12 +631,12 @@ void __kprobes unregister_kretprobe(struct kretprobe *rp) ...@@ -631,12 +631,12 @@ void __kprobes unregister_kretprobe(struct kretprobe *rp)
unregister_kprobe(&rp->kp); unregister_kprobe(&rp->kp);
/* No race here */ /* No race here */
spin_lock_irqsave(&kretprobe_lock, flags); spin_lock_irqsave(&kretprobe_lock, flags);
free_rp_inst(rp);
while ((ri = get_used_rp_inst(rp)) != NULL) { while ((ri = get_used_rp_inst(rp)) != NULL) {
ri->rp = NULL; ri->rp = NULL;
hlist_del(&ri->uflist); hlist_del(&ri->uflist);
} }
spin_unlock_irqrestore(&kretprobe_lock, flags); spin_unlock_irqrestore(&kretprobe_lock, flags);
free_rp_inst(rp);
} }
static int __init init_kprobes(void) static int __init init_kprobes(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册