Skip to content

Commit aaf461a

Browse files
iveceraanguy11
authored andcommitted
ice: Fix incorrect locking in ice_vc_process_vf_msg()
Usage of mutex_trylock() in ice_vc_process_vf_msg() is incorrect because message sent from VF is ignored and never processed. Use mutex_lock() instead to fix the issue. It is safe because this mutex is used to prevent races between VF related NDOs and handlers processing request messages from VF and these handlers are running in ice_service_task() context. Additionally move this mutex lock prior ice_vc_is_opcode_allowed() call to avoid potential races during allowlist access. Fixes: e6ba527 ("ice: Fix race conditions between virtchnl handling and VF ndo ops") Signed-off-by: Ivan Vecera <[email protected]> Tested-by: Konrad Jankowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent acb16b3 commit aaf461a

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3642,14 +3642,6 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event)
36423642
err = -EINVAL;
36433643
}
36443644

3645-
if (!ice_vc_is_opcode_allowed(vf, v_opcode)) {
3646-
ice_vc_send_msg_to_vf(vf, v_opcode,
3647-
VIRTCHNL_STATUS_ERR_NOT_SUPPORTED, NULL,
3648-
0);
3649-
ice_put_vf(vf);
3650-
return;
3651-
}
3652-
36533645
error_handler:
36543646
if (err) {
36553647
ice_vc_send_msg_to_vf(vf, v_opcode, VIRTCHNL_STATUS_ERR_PARAM,
@@ -3660,12 +3652,13 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event)
36603652
return;
36613653
}
36623654

3663-
/* VF is being configured in another context that triggers a VFR, so no
3664-
* need to process this message
3665-
*/
3666-
if (!mutex_trylock(&vf->cfg_lock)) {
3667-
dev_info(dev, "VF %u is being configured in another context that will trigger a VFR, so there is no need to handle this message\n",
3668-
vf->vf_id);
3655+
mutex_lock(&vf->cfg_lock);
3656+
3657+
if (!ice_vc_is_opcode_allowed(vf, v_opcode)) {
3658+
ice_vc_send_msg_to_vf(vf, v_opcode,
3659+
VIRTCHNL_STATUS_ERR_NOT_SUPPORTED, NULL,
3660+
0);
3661+
mutex_unlock(&vf->cfg_lock);
36693662
ice_put_vf(vf);
36703663
return;
36713664
}

0 commit comments

Comments
 (0)