Commit 87757a91 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: force a list_del() in unregister_netdevice_many()

unregister_netdevice_many() API is error prone and we had too
many bugs because of dangling LIST_HEAD on stacks.

See commit f87e6f47 ("net: dont leave active on stack LIST_HEAD")

In fact, instead of making sure no caller leaves an active list_head,
just force a list_del() in the callee. No one seems to need to access
the list after unregister_netdevice_many()
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ba6de0f5
...@@ -1036,7 +1036,6 @@ static int macvlan_device_event(struct notifier_block *unused, ...@@ -1036,7 +1036,6 @@ static int macvlan_device_event(struct notifier_block *unused,
list_for_each_entry_safe(vlan, next, &port->vlans, list) list_for_each_entry_safe(vlan, next, &port->vlans, list)
vlan->dev->rtnl_link_ops->dellink(vlan->dev, &list_kill); vlan->dev->rtnl_link_ops->dellink(vlan->dev, &list_kill);
unregister_netdevice_many(&list_kill); unregister_netdevice_many(&list_kill);
list_del(&list_kill);
break; break;
case NETDEV_PRE_TYPE_CHANGE: case NETDEV_PRE_TYPE_CHANGE:
/* Forbid underlaying device to change its type. */ /* Forbid underlaying device to change its type. */
......
...@@ -6613,6 +6613,9 @@ EXPORT_SYMBOL(unregister_netdevice_queue); ...@@ -6613,6 +6613,9 @@ EXPORT_SYMBOL(unregister_netdevice_queue);
/** /**
* unregister_netdevice_many - unregister many devices * unregister_netdevice_many - unregister many devices
* @head: list of devices * @head: list of devices
*
* Note: As most callers use a stack allocated list_head,
* we force a list_del() to make sure stack wont be corrupted later.
*/ */
void unregister_netdevice_many(struct list_head *head) void unregister_netdevice_many(struct list_head *head)
{ {
...@@ -6622,6 +6625,7 @@ void unregister_netdevice_many(struct list_head *head) ...@@ -6622,6 +6625,7 @@ void unregister_netdevice_many(struct list_head *head)
rollback_registered_many(head); rollback_registered_many(head);
list_for_each_entry(dev, head, unreg_list) list_for_each_entry(dev, head, unreg_list)
net_set_todo(dev); net_set_todo(dev);
list_del(head);
} }
} }
EXPORT_SYMBOL(unregister_netdevice_many); EXPORT_SYMBOL(unregister_netdevice_many);
...@@ -7077,7 +7081,6 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list) ...@@ -7077,7 +7081,6 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list)
} }
} }
unregister_netdevice_many(&dev_kill_list); unregister_netdevice_many(&dev_kill_list);
list_del(&dev_kill_list);
rtnl_unlock(); rtnl_unlock();
} }
......
...@@ -1744,7 +1744,6 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -1744,7 +1744,6 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh)
ops->dellink(dev, &list_kill); ops->dellink(dev, &list_kill);
unregister_netdevice_many(&list_kill); unregister_netdevice_many(&list_kill);
list_del(&list_kill);
return 0; return 0;
} }
......
...@@ -1758,7 +1758,6 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local) ...@@ -1758,7 +1758,6 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)
} }
mutex_unlock(&local->iflist_mtx); mutex_unlock(&local->iflist_mtx);
unregister_netdevice_many(&unreg_list); unregister_netdevice_many(&unreg_list);
list_del(&unreg_list);
list_for_each_entry_safe(sdata, tmp, &wdev_list, list) { list_for_each_entry_safe(sdata, tmp, &wdev_list, list) {
list_del(&sdata->list); list_del(&sdata->list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment