Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] Close race between {un, }register_netdevice_notifier and pernet_operations
@ 2018-03-29 14:03 Kirill Tkhai
  2018-03-29 14:03 ` [PATCH net-next 1/3] xfrm: Register xfrm_dev_notifier in appropriate place Kirill Tkhai
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Kirill Tkhai @ 2018-03-29 14:03 UTC (permalink / raw)
  To: davem, steffen.klassert, herbert, davem, pablo, kadlec, fw,
	daniel, jakub.kicinski, ast, brouer, linux, john.fastabend,
	dsahern, netdev, ktkhai, netfilter-devel, coreteam

Hi,

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.

Thanks,
Kirill
---

Kirill Tkhai (3):
      xfrm: Register xfrm_dev_notifier in appropriate place
      netfilter: Rework xt_TEE netdevice notifier
      net: Close race between {un,}register_netdevice_notifier() and setup_net()/cleanup_net()


 include/net/xfrm.h     |    2 +
 net/core/dev.c         |    6 ++++
 net/netfilter/xt_TEE.c |   73 ++++++++++++++++++++++++++++++------------------
 net/xfrm/xfrm_device.c |    2 +
 net/xfrm/xfrm_policy.c |    3 +-
 5 files changed, 55 insertions(+), 31 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-03-30 15:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-29 14:03 [PATCH net-next 0/3] Close race between {un, }register_netdevice_notifier and pernet_operations Kirill Tkhai
2018-03-29 14:03 ` [PATCH net-next 1/3] xfrm: Register xfrm_dev_notifier in appropriate place Kirill Tkhai
2018-03-29 14:03 ` [PATCH net-next 2/3] netfilter: Rework xt_TEE netdevice notifier Kirill Tkhai
2018-03-30  9:47   ` Pablo Neira Ayuso
2018-03-29 14:03 ` [PATCH net-next 3/3] net: Close race between {un, }register_netdevice_notifier() and setup_net()/cleanup_net() Kirill Tkhai
2018-03-30 15:00 ` [PATCH net-next 0/3] Close race between {un, }register_netdevice_notifier and pernet_operations David Miller
2018-03-30 15:01   ` Kirill Tkhai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox