All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: netdev@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Thomas Graf <tgraf@suug.ch>
Subject: Re: netlink circular locking dependency
Date: Mon, 16 Jun 2008 23:34:18 +0200	[thread overview]
Message-ID: <20080616213417.GA14988@ami.dom.local> (raw)
In-Reply-To: <1213446954.17870.154.camel@violet.holtmann.net>

Marcel Holtmann wrote, On 06/14/2008 02:35 PM:
...
> =======================================================
> [ INFO: possible circular locking dependency detected ]
> 2.6.26-rc2 #5
> -------------------------------------------------------
> hcid/4136 is trying to acquire lock:
>  (genl_mutex){--..}, at: [<c0000000002ace4c>] .ctrl_dumpfamily+0x74/0x174
> 
> but task is already holding lock:
>  (nlk->cb_mutex){--..}, at: [<c0000000002a766c>] .netlink_dump+0x58/0x27c
> 
> which lock already depends on the new lock.
...

Hi,

IMHO it looks like a real lockup threat. Probably it needs something
better, but for now here is my simplistic patch proposal for testing.

Thanks,
Jarek P.

---

 net/netlink/genetlink.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index f5aa23c..bf939ba 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -32,6 +32,11 @@ static inline void genl_unlock(void)
 	mutex_unlock(&genl_mutex);
 }
 
+static inline int genl_trylock(void)
+{
+	return mutex_trylock(&genl_mutex);
+}
+
 #define GENL_FAM_TAB_SIZE	16
 #define GENL_FAM_TAB_MASK	(GENL_FAM_TAB_SIZE - 1)
 
@@ -603,8 +608,9 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
 	int chains_to_skip = cb->args[0];
 	int fams_to_skip = cb->args[1];
 
-	if (chains_to_skip != 0)
-		genl_lock();
+	/* genl_lock vs. cb_mutex inversion threatens here */
+	if (chains_to_skip != 0 && !genl_trylock())
+		return skb->len;
 
 	for (i = 0; i < GENL_FAM_TAB_SIZE; i++) {
 		if (i < chains_to_skip)

  reply	other threads:[~2008-06-16 21:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-14 12:35 netlink circular locking dependency Marcel Holtmann
2008-06-16 21:34 ` Jarek Poplawski [this message]
2008-06-16 21:48   ` Patrick McHardy
2008-06-17  1:45     ` Marcel Holtmann
2008-06-17 12:50       ` Patrick McHardy
2008-06-17 13:09         ` Jarek Poplawski
2008-06-17 13:07           ` Patrick McHardy
2008-06-17 13:24             ` Jarek Poplawski
2008-06-17 13:27               ` Patrick McHardy
2008-06-17 13:43                 ` Jarek Poplawski
2008-06-18  4:30                   ` David Miller
2008-06-18  6:15                     ` Jarek Poplawski
2008-06-18  8:52                     ` Patrick McHardy
2008-06-18  9:08                       ` David Miller
2008-06-18 11:38                         ` Marcel Holtmann
2008-06-18 11:42                           ` Patrick McHardy
2008-06-17 13:08           ` Thomas Graf
2008-06-17 13:19             ` Patrick McHardy
2008-06-17  8:49     ` Jarek Poplawski

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=20080616213417.GA14988@ami.dom.local \
    --to=jarkao2@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=mingo@elte.hu \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.