Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752586AbaJDPaq (ORCPT ); Sat, 4 Oct 2014 11:30:46 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:54459 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750973AbaJDPao (ORCPT ); Sat, 4 Oct 2014 11:30:44 -0400 Message-ID: <1412436642.17245.37.camel@edumazet-glaptop2.roam.corp.google.com> Subject: Re: [RFC 1/1] net: fix rcu access on phonet_routes From: Eric Dumazet To: Fabian Frederick Cc: linux-kernel@vger.kernel.org, Josh Triplett , Remi Denis-Courmont , "David S. Miller" , netdev@vger.kernel.org Date: Sat, 04 Oct 2014 08:30:42 -0700 In-Reply-To: <1412416676-21698-1-git-send-email-fabf@skynet.be> References: <1412416676-21698-1-git-send-email-fabf@skynet.be> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2014-10-04 at 11:57 +0200, Fabian Frederick wrote: > -Add __rcu annotation on table to fix sparse warnings: > net/phonet/pn_dev.c:279:25: warning: incorrect type in assignment (different address spaces) > net/phonet/pn_dev.c:279:25: expected struct net_device * > net/phonet/pn_dev.c:279:25: got void [noderef] * > net/phonet/pn_dev.c:376:17: warning: incorrect type in assignment (different address spaces) > net/phonet/pn_dev.c:376:17: expected struct net_device *volatile > net/phonet/pn_dev.c:376:17: got struct net_device [noderef] * > net/phonet/pn_dev.c:392:17: warning: incorrect type in assignment (different address spaces) > net/phonet/pn_dev.c:392:17: expected struct net_device * > net/phonet/pn_dev.c:392:17: got void [noderef] * > > -Access table with rcu_dereference (fixes the following sparse errors): > net/phonet/pn_dev.c:278:25: error: incompatible types in comparison expression (different address spaces) > net/phonet/pn_dev.c:391:17: error: incompatible types in comparison expression (different address spaces) > > Signed-off-by: Fabian Frederick > --- > net/phonet/pn_dev.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c > index 56a6146..5c9c0b2f1 100644 > --- a/net/phonet/pn_dev.c > +++ b/net/phonet/pn_dev.c > @@ -36,7 +36,7 @@ > > struct phonet_routes { > struct mutex lock; > - struct net_device *table[64]; > + struct net_device __rcu *table[64]; > }; > > struct phonet_net { > @@ -275,7 +275,7 @@ static void phonet_route_autodel(struct net_device *dev) > bitmap_zero(deleted, 64); > mutex_lock(&pnn->routes.lock); > for (i = 0; i < 64; i++) > - if (dev == pnn->routes.table[i]) { > + if (rcu_dereference(pnn->routes.table[i]) == dev) { > RCU_INIT_POINTER(pnn->routes.table[i], NULL); > set_bit(i, deleted); > } > @@ -388,7 +388,7 @@ int phonet_route_del(struct net_device *dev, u8 daddr) > > daddr = daddr >> 2; > mutex_lock(&routes->lock); > - if (dev == routes->table[daddr]) > + if (rcu_dereference(routes->table[daddr]) == dev) > RCU_INIT_POINTER(routes->table[daddr], NULL); > else > dev = NULL; Hi Fabian Have you tested this running the kernel with following config options : CONFIG_LOCKDEP=y CONFIG_PROVE_RCU=y LOCKDEP should complain loudly, if not, we should file a bug ! Hint : Use rcu_access_pointer(), and check that LOCKDEP is happy with that. Thanks ! -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/