]> git.baikalelectronics.ru Git - kernel.git/commit
bridge: fix use-after-free in br_cleanup_bridges()
authorPatrick McHardy <kaber@trash.net>
Thu, 3 Jul 2008 10:53:42 +0000 (03:53 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Jul 2008 10:53:42 +0000 (03:53 -0700)
commit3b4c1c5e74c9f1569e9b0f220dc677b5e35f02f1
treed6cb28dab25eada6f2963d23afd284d0b899bab5
parentf2bb5a9f3da0950bc5d1ec1be25021d176b3ce12
bridge: fix use-after-free in br_cleanup_bridges()

Unregistering a bridge device may cause virtual devices stacked on the
bridge, like vlan or macvlan devices, to be unregistered as well.
br_cleanup_bridges() uses for_each_netdev_safe() to iterate over all
devices during cleanup. This is not enough however, if one of the
additionally unregistered devices is next in the list to the bridge
device, it will get freed as well and the iteration continues on
the freed element.

Restart iteration after each bridge device removal from the beginning to
fix this, similar to what rtnl_link_unregister() does.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_if.c