From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH net-next 0/3] Close race between {un, }register_netdevice_notifier and pernet_operations Date: Fri, 30 Mar 2018 11:00:12 -0400 (EDT) Message-ID: <20180330.110012.2226179718404929635.davem@davemloft.net> References: <152233127015.1654.2122693690388452589.stgit@localhost.localdomain> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au, pablo@netfilter.org, kadlec@blackhole.kfki.hu, fw@strlen.de, daniel@iogearbox.net, jakub.kicinski@netronome.com, ast@kernel.org, brouer@redhat.com, linux@rasmusvillemoes.dk, john.fastabend@gmail.com, dsahern@gmail.com, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org To: ktkhai@virtuozzo.com Return-path: Received: from shards.monkeyblade.net ([184.105.139.130]:60206 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751215AbeC3PQu (ORCPT ); Fri, 30 Mar 2018 11:16:50 -0400 In-Reply-To: <152233127015.1654.2122693690388452589.stgit@localhost.localdomain> Sender: netdev-owner@vger.kernel.org List-ID: From: Kirill Tkhai Date: Thu, 29 Mar 2018 17:03:15 +0300 > the problem is {,un}register_netdevice_notifier() do not take > pernet_ops_rwsem, and they don't see network namespaces, being > initialized in setup_net() and cleanup_net(), since at this > time net is not hashed to net_namespace_list. > > This may lead to imbalance, when a notifier is called at time of > setup_net()/net is alive, but it's not called at time of cleanup_net(), > for the devices, hashed to the net, and vise versa. See (3/3) for > the scheme of imbalance. > > This patchset fixes the problem by acquiring pernet_ops_rwsem > at the time of {,un}register_netdevice_notifier() (3/3). > (1-2/3) are preparations in xfrm and netfilter subsystems. > > The problem was introduced a long ago, but backporting won't be easy, > since every previous kernel version may have changes in netdevice > notifiers, and they all need review and testing. Otherwise, there > may be more pernet_operations, which register or unregister > netdevice notifiers, and that leads to deadlock (which is was fixed > in 1-2/3). This patchset is for net-next. I am applying this series and skipping the rwsem revert. Thanks Kirill.