From patchwork Wed Sep 22 23:04:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 65473 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C413FB70D4 for ; Thu, 23 Sep 2010 09:04:36 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752487Ab0IVXEb (ORCPT ); Wed, 22 Sep 2010 19:04:31 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:62594 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751015Ab0IVXEb (ORCPT ); Wed, 22 Sep 2010 19:04:31 -0400 Received: by fxm12 with SMTP id 12so433242fxm.19 for ; Wed, 22 Sep 2010 16:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=UBWgvpnWJy/RMReVrPKhAqMiE1Ok1lUOyRwCE/wJRnQ=; b=CpR0p+MUwdi7l7MkhvC1SH1oUcc4Pj1+du4zMR8Ry13YPwVggk7enidpSRRrr262cK TfAd+2pD8hDpaxQSZfF8B+bQytXm5GkY1Kfb2mFOO/k+H8ILr25OdCNYmCzTYi+e2D5e aeWNHrKB4GiI1K6LYs2buCCa35quzwmnwZUZw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=oaLgAXGeHxDAiob6rsCpJTo0UPA9EoqAscFSr1OplEumLO7BKpqkVVwx3lTTEdLNFM 1nnE1B4DVTedMBUbh7UV4ri5cpb/WUKg4z5UsadgtoaiUrF/oouQw19DzrdP50uaRW8v g7t31EtwqRdgwQSs4ppJZjkeQhWWoGafT49Ds= Received: by 10.223.107.20 with SMTP id z20mr1094453fao.37.1285196669755; Wed, 22 Sep 2010 16:04:29 -0700 (PDT) Received: from [10.150.51.212] (gw0.net.jmsp.net [212.23.165.14]) by mx.google.com with ESMTPS id 2sm26637faz.38.2010.09.22.16.04.27 (version=SSLv3 cipher=RC4-MD5); Wed, 22 Sep 2010 16:04:28 -0700 (PDT) Subject: Re: Fw: rcu warning From: Eric Dumazet To: paulmck@linux.vnet.ibm.com Cc: akpm@linux-foundation.org, netdev@vger.kernel.org In-Reply-To: <20100922214438.GN2435@linux.vnet.ibm.com> References: <20100922214438.GN2435@linux.vnet.ibm.com> Date: Thu, 23 Sep 2010 01:04:25 +0200 Message-ID: <1285196665.2380.54.camel@edumazet-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Le mercredi 22 septembre 2010 à 14:44 -0700, Paul E. McKenney a écrit : > > Date: Wed, 22 Sep 2010 13:52:28 -0700 > > From: Andrew Morton > > To: "Paul E. McKenney" > > Subject: rcu warning > > X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.9; x86_64-pc-linux-gnu) > > > > [ 56.803750] > > [ 56.803752] =================================================== > > [ 56.804082] [ INFO: suspicious rcu_dereference_check() usage. ] > > [ 56.804249] --------------------------------------------------- > > [ 56.804421] include/linux/inetdevice.h:219 invoked rcu_dereference_check() without protection! > > [ 56.804708] > > [ 56.804709] other info that might help us debug this: > > [ 56.804710] > > [ 56.805183] > > [ 56.805184] rcu_scheduler_active = 1, debug_locks = 1 > > [ 56.805501] 3 locks held by kworker/0:1/0: > > [ 56.805664] #0: (&in_dev->mr_ifc_timer){+.-...}, at: [] run_timer_softirq+0xfd/0x226 > > [ 56.806126] #1: (&in_dev->mc_list_lock){++.-..}, at: [] igmp_ifc_timer_expire+0x2a/0x221 > > [ 56.806588] #2: (&(&im->lock)->rlock){+.-...}, at: [] igmp_ifc_timer_expire+0x155/0x221 > > [ 56.807043] > > [ 56.807044] stack backtrace: > > [ 56.807364] Pid: 0, comm: kworker/0:1 Not tainted 2.6.36-rc5-mm1 #1 > > [ 56.807561] Call Trace: > > [ 56.807723] [] lockdep_rcu_dereference+0x99/0xa2 > > [ 56.807948] [] __ip_route_output_key+0x34f/0xb19 > > [ 56.808120] [] ? __ip_route_output_key+0x33/0xb19 > > [ 56.814367] [] ip_route_output_flow+0x23/0x1ee > > [ 56.814536] [] ip_route_output_key+0xe/0x10 > > [ 56.814704] [] igmpv3_newpack+0x7f/0x1c2 > > [ 56.814873] [] add_grhead+0x2d/0x94 > > [ 56.815039] [] add_grec+0x34e/0x38c > > [ 56.815206] [] igmp_ifc_timer_expire+0x1b5/0x221 > > [ 56.815375] [] run_timer_softirq+0x17f/0x226 > > [ 56.815547] [] ? run_timer_softirq+0xfd/0x226 > > [ 56.815715] [] ? igmp_ifc_timer_expire+0x0/0x221 > > [ 56.815885] [] __do_softirq+0xa5/0x13a > > [ 56.816051] [] call_softirq+0x1c/0x28 > > [ 56.816219] [] do_softirq+0x38/0x82 > > [ 56.816385] [] irq_exit+0x47/0x49 > > [ 56.816553] [] smp_apic_timer_interrupt+0x88/0x96 > > [ 56.816722] [] apic_timer_interrupt+0x13/0x20 > > [ 56.816888] [] ? __atomic_notifier_call_chain+0x0/0x84 > > [ 56.817215] [] ? mwait_idle+0x65/0x71 > > [ 56.817382] [] ? mwait_idle+0x5b/0x71 > > [ 56.817549] [] cpu_idle+0x48/0x66 > > [ 56.817716] [] start_secondary+0x1b9/0x1bd > > [ 56.817883] [] ? start_secondary+0x0/0x1bd > > Hello, Eric, > > In linux/master, there is an rcu_read_lock_bh() in the call path, but > an rcu_dereference() instead of an rcu_dereference_bh(). Thoughts? > > (I have asked Andrew what kernel this is against -- I don't see the > rcu_read_lock() that I would expect to see in the lockdep output.) > > Thanx, Paul This seems strange include/linux/inetdevice.h:219 static inline struct in_device *__in_dev_get_rtnl(const struct net_device *dev) { return rcu_dereference_check(dev->ip_ptr, lockdep_rtnl_is_held()); } But I dont think RTNL can possibly be held at this point ??? Oh wait, this is line 2582 in net/ipv4/route.c It seems buggy and proud of it :) /* RACE: Check return value of inet_select_addr instead. */ if (__in_dev_get_rtnl(dev_out) == NULL) { This should be changed to if (rcu_dereference_raw(dev_out->ip_ptr) == NULL) { No ? In commit e5ed639913eea3e, Herbert mentioned a race so I suspect some more thinking is needed before applying the following patch Sorry its late here, I now need to sleep :) --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/route.c b/net/ipv4/route.c index e24d48d..8d08377 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2579,7 +2579,7 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp, goto out; /* RACE: Check return value of inet_select_addr instead. */ - if (__in_dev_get_rtnl(dev_out) == NULL) { + if (rcu_dereference_raw(dev_out->ip_ptr) == NULL) { dev_put(dev_out); goto out; /* Wrong error code */ }