From: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@osdl.org>,
Masami Hiramatsu <hiramatu@sdl.hitachi.co.jp>,
Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
Prasanna S Panchamukhi <prasanna@in.ibm.com>
Subject: [PATCH] Kprobes: Fix deadlock in function-return probes
Date: Thu, 2 Feb 2006 11:53:54 +0530 [thread overview]
Message-ID: <20060202062353.GA3279@in.ibm.com> (raw)
From: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
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 <ananth@in.ibm.com>
---
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
unregister_kprobe(&rp->kp);
/* No race here */
spin_lock_irqsave(&kretprobe_lock, flags);
- free_rp_inst(rp);
while ((ri = get_used_rp_inst(rp)) != NULL) {
ri->rp = NULL;
hlist_del(&ri->uflist);
}
spin_unlock_irqrestore(&kretprobe_lock, flags);
+ free_rp_inst(rp);
}
static int __init init_kprobes(void)
reply other threads:[~2006-02-02 6:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060202062353.GA3279@in.ibm.com \
--to=ananth@in.ibm.com \
--cc=akpm@osdl.org \
--cc=anil.s.keshavamurthy@intel.com \
--cc=hiramatu@sdl.hitachi.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=prasanna@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox