From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pablo Neira Ayuso Subject: Re: [PATCH nf-next 3/3] netfilter: replace list_head with single linked list Date: Mon, 11 Jul 2016 12:29:31 +0200 Message-ID: <20160711102931.GA18199@salvia> References: <1467321575-6107-1-git-send-email-aconole@bytheb.org> <1467321575-6107-4-git-send-email-aconole@bytheb.org> <20160708233038.GA2067@breakpoint.cc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Aaron Conole , netdev@vger.kernel.org, netfilter-devel@vger.kernel.org To: Florian Westphal Return-path: Received: from mail.us.es ([193.147.175.20]:50655 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758136AbcGKK3r (ORCPT ); Mon, 11 Jul 2016 06:29:47 -0400 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 69A4D17DB67 for ; Mon, 11 Jul 2016 12:29:44 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 4DD699EBD2 for ; Mon, 11 Jul 2016 12:29:44 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id E7DA49EBDC for ; Mon, 11 Jul 2016 12:29:38 +0200 (CEST) Content-Disposition: inline In-Reply-To: <20160708233038.GA2067@breakpoint.cc> Sender: netfilter-devel-owner@vger.kernel.org List-ID: On Sat, Jul 09, 2016 at 01:30:38AM +0200, Florian Westphal wrote: > Aaron Conole wrote: > > --- a/net/netfilter/core.c > > +++ b/net/netfilter/core > [..] > > +#define nf_entry_dereference(e) \ > > + rcu_dereference_protected(e, lockdep_is_held(&nf_hook_mutex)) > > > > -static struct list_head *nf_find_hook_list(struct net *net, > > - const struct nf_hook_ops *reg) > > +static struct nf_hook_entry *nf_find_hook_list(struct net *net, > > + const struct nf_hook_ops *reg) > > { > > - struct list_head *hook_list = NULL; > > + struct nf_hook_entry *hook_list = NULL; > > > > if (reg->pf != NFPROTO_NETDEV) > > - hook_list = &net->nf.hooks[reg->pf][reg->hooknum]; > > + hook_list = rcu_dereference(net->nf.hooks[reg->pf] > > + [reg->hooknum]); > > else if (reg->hooknum == NF_NETDEV_INGRESS) { > > #ifdef CONFIG_NETFILTER_INGRESS > > if (reg->dev && dev_net(reg->dev) == net) > > - hook_list = ®->dev->nf_hooks_ingress; > > + hook_list = > > + rcu_dereference(reg->dev->nf_hooks_ingress); > > Both of these should use nf_entry_dereference() to avoid the lockdep > splat reported by kbuild robot: > > net/netfilter/core.c:75 suspicious rcu_dereference_check() usage! > 2 locks held by swapper/1: > #0: (rtnl_mutex){+.+.+.}, at: [] rtnl_lock+0x17/0x20 > #1: (nf_hook_mutex){+.+...}, at: [] nf_register_net_hook+0xcb/0x240 Aaron, please, send a v2. I have a patchset that changes the footprint of the hook function as it was discussed during the last Netfilter Workshop that clashes with this. Thanks!