bonding: NULL pointer dereference and flag strip fixes
Subsystems (3)
v2 cover bonding: NULL pointer dereference and flag strip fixes
These 2 patches fix a NULL pointer dereference in the netdev event handling of the bond and flag that wasn't stripped on enslave failure.
v2: Fix comment style
Nikolay Aleksandrov (2):
bonding: fix netdev event NULL pointer dereference
bonding: IFF_BONDING is not stripped on enslave failure
drivers/net/bonding/bond_main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.1.4
PATCH v2 1/2 bonding: fix netdev event NULL pointer dereference
In commit 471cb5a33dcbd7c529684a2ac7ba4451414ee4a7 ("bonding: remove usage of dev->master") a bug was introduced which causes a NULL pointer dereference. If a bond device is in mode 6 (ALB) and a slave is added it will dereference a NULL pointer in bond_slave_netdev_event(). This is because in bond_enslave we have bond_alb_init_slave() which changes the MAC address of the slave and causes a NETDEV_CHANGEADDR. Then we have in bond_slave_netdev_event():
struct slave *slave = bond_slave_get_rtnl(slave_dev);
struct bonding *bond = slave->bond;bond_slave_get_rtnl() dereferences slave_dev->rx_handler_data which at that time is NULL since netdev_rx_handler_register() is called later.
This is fixed by checking if slave is NULL before dereferencing it.
v2: Comment style changed.
--- drivers/net/bonding/bond_main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/bonding/bond_main.c +11 -2
@@ -3168,11 +3168,20 @@ static int bond_slave_netdev_event(unsigned long event, struct net_device *slave_dev) {struct slave *slave =bond_slave_get_rtnl (slave_dev); -struct bonding *bond = slave->bond; -struct net_device *bond_dev = slave->bond->dev; +struct bonding *bond; +struct net_device *bond_dev;u32 old_speed;u8 old_duplex; +/* A netdev event can be generated while enslaving a device +* before netdev_rx_handler_register is called in which case +* slave will be NULL +*/ +if (!slave) +return NOTIFY_DONE ; + bond_dev = slave->bond->dev; + bond = slave->bond; +switch (event) {case NETDEV_UNREGISTER :if (bond->setup_by_slave)
Signature · 1 line
1.8.1.4
PATCH v2 2/2 bonding: IFF_BONDING is not stripped on enslave failure
In reply to Nikolay AleksandrovWhile enslaving a new device and after IFF_BONDING flag is set, in case of failure it is not stripped from the device's priv_flags while cleaning up, which could lead to other problems.
Cleaning at err_close because the flag is set after dev_open().
v2: no change
--- drivers/net/bonding/bond_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/bonding/bond_main.c +1 -0
@@ -1906,6 +1906,7 @@ err_detach:write_unlock_bh (&bond->lock); err_close: + slave_dev->priv_flags &= ~IFF_BONDING ;dev_close (slave_dev); err_unset_master:
Signature · 1 line
1.8.1.4
David Miller
maintainerFrom: Nikolay Aleksandrov <[email protected]>
Date: Thu, 11 Apr 2013 21:18:54 +0200
Quoted 8 lines
These 2 patches fix a NULL pointer dereference in the netdev event handling of the bond and flag that wasn't stripped on enslave failure.
v2: Fix comment style
Nikolay Aleksandrov (2):
bonding: fix netdev event NULL pointer dereference
bonding:IFF_BONDINGis not stripped on enslave failure
Both applied, thanks.