]> git.baikalelectronics.ru Git - kernel.git/commit
macvlan: Fix use after free of struct macvlan_port.
authorEric W. Biederman <ebiederm@aristanetworks.com>
Tue, 22 Mar 2011 01:22:22 +0000 (18:22 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 22 Mar 2011 01:22:22 +0000 (18:22 -0700)
commitb2c877411df63d9eabc2b76ff17130427c2fc665
treec65c8f66d7818b4250d56ef489cb2b3125276403
parent98eb3b3b3a72fb243e35ac116908aea5c6857d1c
macvlan: Fix use after free of struct macvlan_port.

When the macvlan driver was extended to call unregisgter_netdevice_queue
in 8768b1fb99ab1f3350a4a0b3bd7f8eba861787f3, a use after free of struct
macvlan_port was introduced.  The code in dellink relied on unregister_netdevice
actually unregistering the net device so it would be safe to free macvlan_port.

Since unregister_netdevice_queue can just queue up the unregister instead of
performing the unregiser immediately we free the macvlan_port too soon and
then the code in macvlan_stop removes the macaddress for the set of macaddress
to listen for and uses memory that has already been freed.

To fix this add a reference count to track when it is safe to free the macvlan_port
and move the call of macvlan_port_destroy into macvlan_uninit which is guaranteed
to be called after the final macvlan_port_close.

Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/macvlan.c