Skip to content

Commit d8c40b9

Browse files
walking-machineanguy11
authored andcommitted
ice: check ICE_VSI_DOWN under rtnl_lock when preparing for reset
Consider the following scenario: .ndo_bpf() | ice_prepare_for_reset() | ________________________|_______________________________________| rtnl_lock() | | ice_down() | | | test_bit(ICE_VSI_DOWN) - true | | ice_dis_vsi() returns | ice_up() | | | proceeds to rebuild a running VSI | .ndo_bpf() is not the only rtnl-locked callback that toggles the interface to apply new configuration. Another example is .set_channels(). To avoid the race condition above, act only after reading ICE_VSI_DOWN under rtnl_lock. Fixes: 0f9d502 ("ice: Refactor VSI allocation, deletion and rebuild flow") Reviewed-by: Wojciech Drewek <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Tested-by: Chandan Kumar Rout <[email protected]> Signed-off-by: Larysa Zaremba <[email protected]> Reviewed-by: Maciej Fijalkowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent f50c687 commit d8c40b9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,24 +2672,24 @@ int ice_ena_vsi(struct ice_vsi *vsi, bool locked)
26722672
*/
26732673
void ice_dis_vsi(struct ice_vsi *vsi, bool locked)
26742674
{
2675-
if (test_bit(ICE_VSI_DOWN, vsi->state))
2676-
return;
2675+
bool already_down = test_bit(ICE_VSI_DOWN, vsi->state);
26772676

26782677
set_bit(ICE_VSI_NEEDS_RESTART, vsi->state);
26792678

26802679
if (vsi->type == ICE_VSI_PF && vsi->netdev) {
26812680
if (netif_running(vsi->netdev)) {
26822681
if (!locked)
26832682
rtnl_lock();
2684-
2685-
ice_vsi_close(vsi);
2683+
already_down = test_bit(ICE_VSI_DOWN, vsi->state);
2684+
if (!already_down)
2685+
ice_vsi_close(vsi);
26862686

26872687
if (!locked)
26882688
rtnl_unlock();
2689-
} else {
2689+
} else if (!already_down) {
26902690
ice_vsi_close(vsi);
26912691
}
2692-
} else if (vsi->type == ICE_VSI_CTRL) {
2692+
} else if (vsi->type == ICE_VSI_CTRL && !already_down) {
26932693
ice_vsi_close(vsi);
26942694
}
26952695
}

0 commit comments

Comments
 (0)