Skip to contentSkip to conversation

i40e: fix potential calltrace i40e_sync_vsi_filters()

PATCH In review Andrii Staikov 2 participants 2 messages Aug 2, 2023 – Aug 4, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i40e: fix potential calltrace i40e_sync_vsi_filters()

Add defensive check for pf->vf != NULL before referencing pf->vf[].

Fixes c87c938f62d8 ("i40e: Add VF VLAN pruning")
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +3 -2
index 29ad1797adce..a86bfa3bba74 100644
@@ -2609,7 +2609,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
 			retval = i40e_correct_mac_vlan_filters
 				(vsi, &tmp_add_list, &tmp_del_list,
 				 vlan_filters);
-		else
+		else if (pf->vf)
 			retval = i40e_correct_vf_mac_vlan_filters
 				(vsi, &tmp_add_list, &tmp_del_list,
 				 vlan_filters, pf->vf[vsi->vf_id].trusted);
@@ -2782,7 +2782,8 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
 	}
 
 	/* if the VF is not trusted do not do promisc */
-	if ((vsi->type == I40E_VSI_SRIOV) && !pf->vf[vsi->vf_id].trusted) {
+	if (vsi->type == I40E_VSI_SRIOV && pf->vf &&
+	    !pf->vf[vsi->vf_id].trusted) {
 		clear_bit(__I40E_VSI_OVERFLOW_PROMISC, vsi->state);
 		goto out;
 	}
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
maintainer
#1 lore raw
Quoted 1 line · Andrii Staikov

Add defensive check for pf->vf != NULL before referencing pf->vf[].

Please add more info on how this can occur/Why are you adding this check? How was this found? An actual call trace, static analysis, code inspection, other? If a call trace, putting it here would be useful.

Quoted 21 lines
Fixes c87c938f62d8 ("i40e: Add VF VLAN pruning")
---
  drivers/net/ethernet/intel/i40e/i40e_main.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
index 29ad1797adce..a86bfa3bba74 100644
@@ -2609,7 +2609,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
  			retval = i40e_correct_mac_vlan_filters
  				(vsi, &tmp_add_list, &tmp_del_list,
  				 vlan_filters);
-		else
+		else if (pf->vf)
  			retval = i40e_correct_vf_mac_vlan_filters
  				(vsi, &tmp_add_list, &tmp_del_list,
  				 vlan_filters, pf->vf[vsi->vf_id].trusted);

drivers/net/ethernet/intel/i40e/i40e_main.c int i40e_sync_vsi_filters(struct i40e_vsi *vsi) · line 2789

Quoted 9 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +2 -1
@@ -2782,7 +2782,8 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
  	}
 
  	/* if the VF is not trusted do not do promisc */
-	if ((vsi->type == I40E_VSI_SRIOV) && !pf->vf[vsi->vf_id].trusted) {
+	if (vsi->type == I40E_VSI_SRIOV && pf->vf &&
+	    !pf->vf[vsi->vf_id].trusted) {
  		clear_bit(__I40E_VSI_OVERFLOW_PROMISC, vsi->state);
  		goto out;
  	}

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan