[lkml]   [2006]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] Kprobes: Fix deadlock in function-return probes
From: Ananth N Mavinakayanahalli <>

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: Ananth N Mavinakayanahalli <>

kernel/kprobes.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6.16-rc1/kernel/kprobes.c
--- linux-2.6.16-rc1.orig/kernel/kprobes.c
+++ linux-2.6.16-rc1/kernel/kprobes.c
@@ -631,12 +631,12 @@ void __kprobes unregister_kretprobe(stru
/* No race here */
spin_lock_irqsave(&kretprobe_lock, flags);
- free_rp_inst(rp);
while ((ri = get_used_rp_inst(rp)) != NULL) {
ri->rp = NULL;
spin_unlock_irqrestore(&kretprobe_lock, flags);
+ free_rp_inst(rp);

static int __init init_kprobes(void)
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at
 \ /
  Last update: 2006-02-02 07:30    [from the cache]
©2003-2014 Jasper Spaans. hosted at Digital Ocean