• Pavel Emelyanov's avatar
    bonding: Deadlock between bonding_store_bonds and bond_destroy_sysfs. · ae68c398
    Pavel Emelyanov authored
    The sysfs layer has an internal protection, that ensures, that
    all the process sitting inside ->sore/->show callback exits
    before the appropriate entry is unregistered (the calltraces
    are rather big, but I can provide them if required).
    
    On the other hand, bonding takes rtnl_lock in
    a) the bonding_store_bonds, i.e. in ->store callback,
    b) module exit before calling the sysfs unregister routines.
    
    Thus, the classical AB-BA deadlock may occur. To reproduce run
    # while :; do modprobe bonding; rmmod bonding; done
    and
    # while :; do echo '+bond%d' > /sys/class/net/bonding_masters ; done
    in parallel.
    
    The fix is to move the bond_destroy_sysfs out of the rtnl_lock,
    but _before_ bond_free_all to make sure no bonding devices exist
    after module unload.
    Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
    Acked-by: default avatarJay Vosburgh <fubar@us.ibm.com>
    Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
    ae68c398
bond_main.c 132 KB