public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Ben Greear <greearb@candelatech.com>
Cc: David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org, gregkh@linuxfoundation.org,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: RCU lock bug in 3.0.21 (bisected to: 682cb56a, fix NULL dereferences in check_peer_redir)
Date: Tue, 27 Mar 2012 01:39:08 +0200	[thread overview]
Message-ID: <1332805148.3547.14.camel@edumazet-glaptop> (raw)
In-Reply-To: <4F70F688.6050108@candelatech.com>

On Mon, 2012-03-26 at 16:06 -0700, Ben Greear wrote:
> On 03/26/2012 02:53 PM, Ben Greear wrote:
> > On 03/26/2012 02:49 PM, David Miller wrote:
> >>
> >> Looks like all of those strange undiagnosable reported Dave Jones
> >> has been feeding us. Something in one part of the kernel leaves
> >> a lock held, and this shows up as a warning elsewhere.
> >
> > Every (initial) bug printout fingers ipv6 and the 'ip' tool on my system.
> 
> I added a patch to convert rcu_read_lock/unlock to macros so
> that I could automatically grab the call site (_THIS_IP_)
> and pass it into the lockdep framework instead of the (useless)
> _THIS_IP_ in the old rcu_read_lock method which at best seems to
> only indicate which module the issue relates to...

Hi Ben

Is this problem also appears with current tree ?
(This could be a problem with the backport, as it was full of
dependencies)

Also, if you use a patch to better track rcu_read_lock()/unlock(), you
could add new macros as well to track that a particular unlock() matches
one given lock(). (maybe returning the rcu_preempt_depth at
rcu_read_lock() time , but maybe a more absolute ref would be better)

So we could have a warning if an unlock() doesnt match the lock()

inet6_dump_fib () was already a suspect but we could not find why.

diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 5b27fbc..d1719e3 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -362,6 +362,7 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
 	struct hlist_node *node;
 	struct hlist_head *head;
 	int res = 0;
+	int depth;
 
 	s_h = cb->args[0];
 	s_e = cb->args[1];
@@ -390,7 +391,7 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
 	arg.net = net;
 	w->args = &arg;
 
-	rcu_read_lock();
+	depth = rcu_read_lock_return();
 	for (h = s_h; h < FIB6_TABLE_HASHSZ; h++, s_e = 0) {
 		e = 0;
 		head = &net->ipv6.fib_table_hash[h];
@@ -405,7 +406,7 @@ next:
 		}
 	}
 out:
-	rcu_read_unlock();
+	rcu_read_unlock_check(depth);
 	cb->args[1] = e;
 	cb->args[0] = h;
 

  parent reply	other threads:[~2012-03-26 23:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 21:43 RCU lock bug in 3.0.21 (bisected to: 682cb56a, fix NULL dereferences in check_peer_redir) Ben Greear
2012-03-26 21:49 ` David Miller
2012-03-26 21:53   ` Ben Greear
2012-03-26 23:06     ` Ben Greear
2012-03-26 23:11       ` David Miller
2012-03-26 23:39       ` Eric Dumazet [this message]
2012-03-26 23:46         ` Ben Greear
2012-03-26 23:53           ` Ben Greear
2012-03-27  0:07           ` Eric Dumazet
2012-03-27  5:11             ` Paul E. McKenney
2012-03-27  5:30               ` Ben Greear
2012-03-27 16:47                 ` Paul E. McKenney
2012-03-27 16:47         ` Ben Greear
2012-03-27 18:06           ` Eric Dumazet
2012-03-27 19:39           ` Eric Dumazet
2012-03-27 19:53             ` [PATCH] net: fix a potential rcu_read_lock() imbalance in rt6_fill_node() Eric Dumazet
2012-03-27 20:07               ` Ben Greear
2012-03-27 20:17               ` Ben Greear
2012-03-27 20:25                 ` Greg KH
2012-03-27 22:22               ` David Miller
2012-03-28  0:54                 ` John Fastabend
2012-03-28  1:27                   ` David Miller

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=1332805148.3547.14.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=greearb@candelatech.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@linux.vnet.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