]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
i40e: fix validation of VF state in get resources
authorLukasz Czapnik <lukasz.czapnik@intel.com>
Mon, 29 Sep 2025 14:58:34 +0000 (10:58 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Oct 2025 11:35:47 +0000 (13:35 +0200)
[ Upstream commit 877b7e6ffc23766448236e8732254534c518ba42 ]

VF state I40E_VF_STATE_ACTIVE is not the only state in which
VF is actually active so it should not be used to determine
if a VF is allowed to obtain resources.

Use I40E_VF_STATE_RESOURCES_LOADED that is set only in
i40e_vc_get_vf_resources_msg() and cleared during reset.

Fixes: 61125b8be85d ("i40e: Fix failed opcode appearing if handling messages from VF")
Cc: stable@vger.kernel.org
Signed-off-by: Lukasz Czapnik <lukasz.czapnik@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
[ Adjust context ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h

index 09407ee0ed229058c34368452be0559c78ce0430..3ddb712b732d5a062e6c584349d5e40317ac0206 100644 (file)
@@ -1416,6 +1416,7 @@ static void i40e_trigger_vf_reset(struct i40e_vf *vf, bool flr)
         * functions that may still be running at this point.
         */
        clear_bit(I40E_VF_STATE_INIT, &vf->vf_states);
+       clear_bit(I40E_VF_STATE_RESOURCES_LOADED, &vf->vf_states);
 
        /* In the case of a VFLR, the HW has already reset the VF and we
         * just need to clean up, so don't hit the VFRTRIG register.
@@ -2082,7 +2083,10 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
        size_t len = 0;
        int ret;
 
-       if (!i40e_sync_vf_state(vf, I40E_VF_STATE_INIT)) {
+       i40e_sync_vf_state(vf, I40E_VF_STATE_INIT);
+
+       if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states) ||
+           test_bit(I40E_VF_STATE_RESOURCES_LOADED, &vf->vf_states)) {
                aq_ret = I40E_ERR_PARAM;
                goto err;
        }
@@ -2178,6 +2182,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
                                vf->default_lan_addr.addr);
        }
        set_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states);
+       set_bit(I40E_VF_STATE_RESOURCES_LOADED, &vf->vf_states);
 
 err:
        /* send the response back to the VF */
index 97e9c34d7c6cdcb953d685d13346b83435fc1821..3b841fbaffa67c23fed1c0a1d444c77b6ffdbc46 100644 (file)
@@ -39,7 +39,8 @@ enum i40e_vf_states {
        I40E_VF_STATE_MC_PROMISC,
        I40E_VF_STATE_UC_PROMISC,
        I40E_VF_STATE_PRE_ENABLE,
-       I40E_VF_STATE_RESETTING
+       I40E_VF_STATE_RESETTING,
+       I40E_VF_STATE_RESOURCES_LOADED,
 };
 
 /* VF capabilities */