Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH iwl-net v2] i40e: fix potential NULL pointer dereferencing of pf->vf i40e_sync_vsi_filters()
@ 2023-08-09 12:17 Andrii Staikov
  2023-08-10 21:31 ` Tony Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Andrii Staikov @ 2023-08-09 12:17 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: Aleksandr Loktionov, Andrii Staikov

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")
Signed-off-by: Andrii Staikov <andrii.staikov@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
v1 -> v2: Changed title and commit message.
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 29ad1797adce..a86bfa3bba74 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -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;
 	}
-- 
2.25.1

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Intel-wired-lan] [PATCH iwl-net v2] i40e: fix potential NULL pointer dereferencing of pf->vf i40e_sync_vsi_filters()
  2023-08-09 12:17 [Intel-wired-lan] [PATCH iwl-net v2] i40e: fix potential NULL pointer dereferencing of pf->vf i40e_sync_vsi_filters() Andrii Staikov
@ 2023-08-10 21:31 ` Tony Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Tony Nguyen @ 2023-08-10 21:31 UTC (permalink / raw)
  To: Andrii Staikov, intel-wired-lan; +Cc: Aleksandr Loktionov

On 8/9/2023 5:17 AM, Andrii Staikov wrote:
> Add  check for pf->vf not being NULL before dereferencing
      ^ two spaces here

> 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

> 
> Fixes: c87c938f62d8 ("i40e: Add VF VLAN pruning")
> Signed-off-by: Andrii Staikov <andrii.staikov@intel.com>
> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> v1 -> v2: Changed title and commit message.
> ---
>   drivers/net/ethernet/intel/i40e/i40e_main.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index 29ad1797adce..a86bfa3bba74 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -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;
>   	}
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-10 21:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 12:17 [Intel-wired-lan] [PATCH iwl-net v2] i40e: fix potential NULL pointer dereferencing of pf->vf i40e_sync_vsi_filters() Andrii Staikov
2023-08-10 21:31 ` Tony Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox