Skip to contentSkip to conversation

i40e: fix potential NULL pointer dereferencing of pf->vf i40e_sync_vsi_filters()

PATCH Superseded Andrii Staikov 2 participants 2 messages Aug 9, 2023 – Aug 10, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i40e: fix potential NULL pointer dereferencing of pf->vf i40e_sync_vsi_filters()

Add check for pf->vf not being NULL before dereferencing pf->vf[vsi->vf_id] in updating VSI filter sync.
Add a similar check before dereferencing !pf->vf[vsi->vf_id].trusted in the condition for clearing promis mode bit.

Fixes c87c938f62d8 ("i40e: Add VF VLAN pruning")

---
v1 -> v2: Changed title and commit message.

---
 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 check for pf->vf not being NULL before dereferencing

^ two spaces here

Quoted 3 lines

pf->vf[vsi->vf_id] in updating VSI filter sync.
Add a similar check before dereferencing !pf->vf[vsi->vf_id].trusted in the condition for clearing promis mode bit.

s/promis/promisc

Quoted 24 lines
Fixes c87c938f62d8 ("i40e: Add VF VLAN pruning")

---
v1 -> v2: Changed title and commit message.

---
  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