• nikolay@redhat.com's avatar
    bonding: fix netdev event NULL pointer dereference · 6101391d
    nikolay@redhat.com authored
    In commit 471cb5a3 ("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.
    Signed-off-by: default avatarNikolay Aleksandrov <nikolay@redhat.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    6101391d
bond_main.c 131 KB