mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
net: reinstate rtnl in call_netdevice_notifiers()
Eric Biederman pointed out that not holding RTNL while calling
call_netdevice_notifiers() was racy.
This patch is a direct transcription his feedback
against commit 0115e8e30d (net: remove delay at device dismantle)
Thanks Eric !
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <therbert@google.com>
Cc: Mahesh Bandewar <maheshb@google.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Gao feng <gaofeng@cn.fujitsu.com>
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
0fa7fa98db
commit
748e2d9396
+7
-2
@@ -1466,8 +1466,7 @@ EXPORT_SYMBOL(unregister_netdevice_notifier);
|
||||
|
||||
int call_netdevice_notifiers(unsigned long val, struct net_device *dev)
|
||||
{
|
||||
if (val != NETDEV_UNREGISTER_FINAL)
|
||||
ASSERT_RTNL();
|
||||
ASSERT_RTNL();
|
||||
return raw_notifier_call_chain(&netdev_chain, val, dev);
|
||||
}
|
||||
EXPORT_SYMBOL(call_netdevice_notifiers);
|
||||
@@ -5782,7 +5781,11 @@ static void netdev_wait_allrefs(struct net_device *dev)
|
||||
|
||||
/* Rebroadcast unregister notification */
|
||||
call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
|
||||
|
||||
__rtnl_unlock();
|
||||
rcu_barrier();
|
||||
rtnl_lock();
|
||||
|
||||
call_netdevice_notifiers(NETDEV_UNREGISTER_FINAL, dev);
|
||||
if (test_bit(__LINK_STATE_LINKWATCH_PENDING,
|
||||
&dev->state)) {
|
||||
@@ -5855,7 +5858,9 @@ void netdev_run_todo(void)
|
||||
= list_first_entry(&list, struct net_device, todo_list);
|
||||
list_del(&dev->todo_list);
|
||||
|
||||
rtnl_lock();
|
||||
call_netdevice_notifiers(NETDEV_UNREGISTER_FINAL, dev);
|
||||
__rtnl_unlock();
|
||||
|
||||
if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) {
|
||||
pr_err("network todo '%s' but state %d\n",
|
||||
|
||||
Reference in New Issue
Block a user