Skip to content

Commit 87757a9

Browse files
Eric Dumazetdavem330
authored andcommitted
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 f87e6f4 ("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: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ba6de0f commit 87757a9

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

drivers/net/macvlan.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,6 @@ static int macvlan_device_event(struct notifier_block *unused,
10361036
list_for_each_entry_safe(vlan, next, &port->vlans, list)
10371037
vlan->dev->rtnl_link_ops->dellink(vlan->dev, &list_kill);
10381038
unregister_netdevice_many(&list_kill);
1039-
list_del(&list_kill);
10401039
break;
10411040
case NETDEV_PRE_TYPE_CHANGE:
10421041
/* Forbid underlaying device to change its type. */

net/core/dev.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6613,6 +6613,9 @@ EXPORT_SYMBOL(unregister_netdevice_queue);
66136613
/**
66146614
* unregister_netdevice_many - unregister many devices
66156615
* @head: list of devices
6616+
*
6617+
* Note: As most callers use a stack allocated list_head,
6618+
* we force a list_del() to make sure stack wont be corrupted later.
66166619
*/
66176620
void unregister_netdevice_many(struct list_head *head)
66186621
{
@@ -6622,6 +6625,7 @@ void unregister_netdevice_many(struct list_head *head)
66226625
rollback_registered_many(head);
66236626
list_for_each_entry(dev, head, unreg_list)
66246627
net_set_todo(dev);
6628+
list_del(head);
66256629
}
66266630
}
66276631
EXPORT_SYMBOL(unregister_netdevice_many);
@@ -7077,7 +7081,6 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list)
70777081
}
70787082
}
70797083
unregister_netdevice_many(&dev_kill_list);
7080-
list_del(&dev_kill_list);
70817084
rtnl_unlock();
70827085
}
70837086

net/core/rtnetlink.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,6 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh)
17441744

17451745
ops->dellink(dev, &list_kill);
17461746
unregister_netdevice_many(&list_kill);
1747-
list_del(&list_kill);
17481747
return 0;
17491748
}
17501749

net/mac80211/iface.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,6 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)
17581758
}
17591759
mutex_unlock(&local->iflist_mtx);
17601760
unregister_netdevice_many(&unreg_list);
1761-
list_del(&unreg_list);
17621761

17631762
list_for_each_entry_safe(sdata, tmp, &wdev_list, list) {
17641763
list_del(&sdata->list);

0 commit comments

Comments
 (0)