public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions•net>
To: Hugh Dickins <hughd@google•com>
Cc: Linus Torvalds <torvalds@linux-foundation•org>,
	Greg KH <gregkh@linuxfoundation•org>,
	"David S. Miller" <davem@davemloft•net>,
	"Otcheretianski, Andrei" <andrei.otcheretianski@intel•com>,
	"linux-kernel@vger•kernel.org" <linux-kernel@vger•kernel.org>,
	"netdev@vger•kernel.org" <netdev@vger•kernel.org>,
	"stable@vger•kernel.org" <stable@vger•kernel.org>,
	Pravin B Shelar <pshelar@nicira•com>, Thomas Graf <tgraf@suug•ch>
Subject: Re: 3.11-rc6 genetlink locking fix offends lockdep
Date: Mon, 19 Aug 2013 10:00:14 +0200	[thread overview]
Message-ID: <1376899214.14734.6.camel@jlt4.sipsolutions.net> (raw)
In-Reply-To: <alpine.LNX.2.00.1308182143370.906@eggly.anvils>


> 3.11-rc6's commit 58ad436fcf49 ("genetlink: fix family dump race")
> gives me the lockdep trace below at startup.

Hmm. Yes, I see now how this happens, not sure why I didn't run into it.

The problem is that genl_family_rcv_msg() is called with the genl_lock
held, and then calls netlink_dump_start() with it held, creating a
genl_lock->cb_mutex dependency, but obviously the dump continuation is
the other way around.

We could use the semaphore instead, I believe, but I don't really
understand the mutex vs. semaphore well enough to be sure that's
correct.

johannes


diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index f85f8a2..6cfa646 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -792,7 +792,7 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
 	bool need_locking = chains_to_skip || fams_to_skip;
 
 	if (need_locking)
-		genl_lock();
+		down_read(&cb_lock);
 
 	for (i = chains_to_skip; i < GENL_FAM_TAB_SIZE; i++) {
 		n = 0;
@@ -815,7 +815,7 @@ errout:
 	cb->args[1] = n;
 
 	if (need_locking)
-		genl_unlock();
+		up_read(&cb_lock);
 
 	return skb->len;
 }

  reply	other threads:[~2013-08-19  8:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-19  5:04 3.11-rc6 genetlink locking fix offends lockdep Hugh Dickins
2013-08-19  8:00 ` Johannes Berg [this message]
2013-08-19 11:00   ` Ding Tianhong
2013-08-19 11:22     ` Johannes Berg
2013-08-19 18:52       ` Hugh Dickins
2013-08-20  8:28         ` Johannes Berg
2013-08-20  9:04           ` Borislav Petkov
2013-08-20 15:49             ` Hugh Dickins
2013-08-20 19:02           ` Johannes Berg
2013-08-20 19:10             ` Johannes Berg

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=1376899214.14734.6.camel@jlt4.sipsolutions.net \
    --to=johannes@sipsolutions$(echo .)net \
    --cc=andrei.otcheretianski@intel$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=gregkh@linuxfoundation$(echo .)org \
    --cc=hughd@google$(echo .)com \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pshelar@nicira$(echo .)com \
    --cc=stable@vger$(echo .)kernel.org \
    --cc=tgraf@suug$(echo .)ch \
    --cc=torvalds@linux-foundation$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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