Skip to contentSkip to conversation

i40e: Fix VF MAC filter removal

PATCH In review Ivan Vecera 5 participants 6 messages Mar 13, 2024 – Mar 28, 2024

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

PATCH 1/1 i40e: Fix VF MAC filter removal

Commit 73d9629e1c8c ("i40e: Do not allow untrusted VF to remove administratively set MAC") fixed an issue where untrusted VF was allowed to remove its own MAC address although this was assigned administratively from PF. Unfortunately the introduced check is wrong because it causes that MAC filters for other MAC addresses including multi-cast ones are not removed.

<snip>

	if (ether_addr_equal(addr, vf->default_lan_addr.addr) &&
	    i40e_can_vf_change_mac(vf))
		was_unimac_deleted = true;
	else
		continue;

	if (i40e_del_mac_filter(vsi, al->list[i].addr)) {
	...

</snip>

The else path with continue effectively skips any MAC filter removal except one for primary MAC addr when VF is allowed to do so. Fix the check condition so the continue is only done for primary MAC address.

Fixes 73d9629e1c8c ("i40e: Do not allow untrusted VF to remove administratively set MAC")
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +6 -5
index b34c71770887..10267a300770 100644
@@ -3143,11 +3143,12 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
 		/* Allow to delete VF primary MAC only if it was not set
 		 * administratively by PF or if VF is trusted.
 		 */
-		if (ether_addr_equal(addr, vf->default_lan_addr.addr) &&
-		    i40e_can_vf_change_mac(vf))
-			was_unimac_deleted = true;
-		else
-			continue;
+		if (ether_addr_equal(addr, vf->default_lan_addr.addr)) {
+			if (i40e_can_vf_change_mac(vf))
+				was_unimac_deleted = true;
+			else
+				continue;
+		}
 
 		if (i40e_del_mac_filter(vsi, al->list[i].addr)) {
 			ret = -EINVAL;
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 52 lines · Ivan Vecera

Commit 73d9629e1c8c ("i40e: Do not allow untrusted VF to remove administratively set MAC") fixed an issue where untrusted VF was allowed to remove its own MAC address although this was assigned administratively from PF. Unfortunately the introduced check is wrong because it causes that MAC filters for other MAC addresses including multi-cast ones are not removed.

<snip>

        if (ether_addr_equal(addr, vf->default_lan_addr.addr) &&
            i40e_can_vf_change_mac(vf))
                was_unimac_deleted = true;
        else
                continue;

        if (i40e_del_mac_filter(vsi, al->list[i].addr)) {
        ...

</snip>

The else path with continue effectively skips any MAC filter removal except one for primary MAC addr when VF is allowed to do so. Fix the check condition so the continue is only done for primary MAC address.

Fixes 73d9629e1c8c ("i40e: Do not allow untrusted VF to remove administratively set MAC")
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +6 -6
index b34c71770887..10267a300770 100644
@@ -3143,11 +3143,12 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
                /* Allow to delete VF primary MAC only if it was not set
                 * administratively by PF or if VF is trusted.
                 */
-               if (ether_addr_equal(addr, vf->default_lan_addr.addr) &&
-                   i40e_can_vf_change_mac(vf))
-                       was_unimac_deleted = true;
-               else
-                       continue;
+               if (ether_addr_equal(addr, vf->default_lan_addr.addr)) {
+                       if (i40e_can_vf_change_mac(vf))
+                               was_unimac_deleted = true;
+                       else
+                               continue;
+               }
 
                if (i40e_del_mac_filter(vsi, al->list[i].addr)) {
                        ret = -EINVAL;
--
Quoted 1 line

2.43.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to Ivan Vecera
Quoted 41 lines · Ivan Vecera

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Commit 73d9629e1c8c ("i40e: Do not allow untrusted VF to remove administratively set MAC") fixed an issue where untrusted VF was allowed to remove its own MAC address although this was assigned administratively from PF. Unfortunately the introduced check is wrong because it causes that MAC filters for other MAC addresses including multi-cast ones are not removed.

<snip>

         if (ether_addr_equal(addr, vf->default_lan_addr.addr) &&
             i40e_can_vf_change_mac(vf))
                 was_unimac_deleted = true;
         else
                 continue;

         if (i40e_del_mac_filter(vsi, al->list[i].addr)) {
         ...

</snip>

The else path with continue effectively skips any MAC filter removal except one for primary MAC addr when VF is allowed to do so. Fix the check condition so the continue is only done for primary MAC address.

Fixes 73d9629e1c8c ("i40e: Do not allow untrusted VF to remove administratively set MAC")
---
  drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +0 -1
index b34c71770887..10267a300770 100644
@@ -3143,11 +3143,12 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
                 /* Allow to delete VF primary MAC only if it was not set
                  * administratively by PF or if VF is trusted.
                  */
-               if (ether_addr_equal(addr, vf->default_lan_addr.addr) &&

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg) · line 3151

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +6 -4
-                   i40e_can_vf_change_mac(vf))
-                       was_unimac_deleted = true;
-               else
-                       continue;
+               if (ether_addr_equal(addr, vf->default_lan_addr.addr)) {
+                       if (i40e_can_vf_change_mac(vf))
+                               was_unimac_deleted = true;
+                       else
+                               continue;
+               }

Seems okay to me.

Quoted 7 lines
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +0 -1
                 if (i40e_del_mac_filter(vsi, al->list[i].addr)) {
                         ret = -EINVAL;
--

2.43.0

#3 lore raw
Quoted 71 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Brett Creeley
Sent: Thursday, March 14, 2024 4:54 PM
To: ivecera <[email protected]>; [email protected]
Cc: moderated list:INTEL ETHERNET DRIVERS <intel-wired- [email protected]>; open list <[email protected]>; Loktionov, Aleksandr <[email protected]>; Eric Dumazet <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; David S. Miller <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net] i40e: Fix VF MAC filter removal

Quoted 1 line · Ivan Vecera

Caution: This message originated from an External Source. Use proper

caution when opening attachments, clicking links, or responding.

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c static int i40e_vc_del_mac_addr_msg(struct

Quoted 38 lines

Commit 73d9629e1c8c ("i40e: Do not allow untrusted VF to remove administratively set MAC") fixed an issue where untrusted VF was allowed to remove its own MAC address although this was assigned administratively from PF. Unfortunately the introduced check is wrong because it causes that MAC filters for other MAC addresses including multi-cast ones are not removed.

<snip>

         if (ether_addr_equal(addr, vf->default_lan_addr.addr) &&
             i40e_can_vf_change_mac(vf))
                 was_unimac_deleted = true;
         else
                 continue;

         if (i40e_del_mac_filter(vsi, al->list[i].addr)) {
         ...

</snip>

The else path with continue effectively skips any MAC filter removal except one for primary MAC addr when VF is allowed to do so. Fix the check condition so the continue is only done for primary MAC address.

Fixes 73d9629e1c8c ("i40e: Do not allow untrusted VF to remove

administratively set MAC")

---
  drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +0 -0
index b34c71770887..10267a300770 100644
@@ -3143,11 +3143,12 @@ static int i40e_vc_del_mac_addr_msg(struct

i40e_vf *vf, u8 *msg)

Quoted 4 lines
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +0 -1
                 /* Allow to delete VF primary MAC only if it was not set
                  * administratively by PF or if VF is trusted.
                  */
-               if (ether_addr_equal(addr, vf->default_lan_addr.addr) &&

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg) · line 3151

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +6 -4
-                   i40e_can_vf_change_mac(vf))
-                       was_unimac_deleted = true;
-               else
-                       continue;
+               if (ether_addr_equal(addr, vf->default_lan_addr.addr)) {
+                       if (i40e_can_vf_change_mac(vf))
+                               was_unimac_deleted = true;
+                       else
+                               continue;
+               }
Quoted 11 lines

Seems okay to me.

Quoted 7 lines
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +0 -1
                 if (i40e_del_mac_filter(vsi, al->list[i].addr)) {
                         ret = -EINVAL;
--

2.43.0

#4 lore raw
In reply to Ivan Vecera
Quoted 41 lines · Ivan Vecera

Commit 73d9629e1c8c ("i40e: Do not allow untrusted VF to remove administratively set MAC") fixed an issue where untrusted VF was allowed to remove its own MAC address although this was assigned administratively from PF. Unfortunately the introduced check is wrong because it causes that MAC filters for other MAC addresses including multi-cast ones are not removed.

<snip>

	if (ether_addr_equal(addr, vf->default_lan_addr.addr) &&
	    i40e_can_vf_change_mac(vf))
		was_unimac_deleted = true;
	else
		continue;

	if (i40e_del_mac_filter(vsi, al->list[i].addr)) {
	...

</snip>

The else path with continue effectively skips any MAC filter removal except one for primary MAC addr when VF is allowed to do so. Fix the check condition so the continue is only done for primary MAC address.

Fixes 73d9629e1c8c ("i40e: Do not allow untrusted VF to remove administratively set MAC")
---
  drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +0 -4
index b34c71770887..10267a300770 100644
@@ -3143,11 +3143,12 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
  		/* Allow to delete VF primary MAC only if it was not set
  		 * administratively by PF or if VF is trusted.
  		 */
-		if (ether_addr_equal(addr, vf->default_lan_addr.addr) &&
-		    i40e_can_vf_change_mac(vf))
-			was_unimac_deleted = true;
-		else

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg) · line 3154

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +6 -1
-			continue;
+		if (ether_addr_equal(addr, vf->default_lan_addr.addr)) {
+			if (i40e_can_vf_change_mac(vf))
+				was_unimac_deleted = true;
+			else
+				continue;
+		}
 
  		if (i40e_del_mac_filter(vsi, al->list[i].addr)) {
  			ret = -EINVAL;

Hi Tony,
the fix is not part of your recent pull series for i40e... I have submitted it to 'net' instead of 'iwl-net' as it fixes recent commit that causes MAC filter resource leaks that should be fixed as soon as possible. But its status in patchwork is 'Awaiting upstream' so it has to be resubmitted by yourself... Or should this be picked directly by netdev maintainers?

Thanks,
Ivan

maintainer
#5 lore raw

On 3/27/2024 12:29 AM, Ivan Vecera wrote:

...

Quoted 2 lines

Hi Tony,
the fix is not part of your recent pull series for i40e... I have submitted it to 'net' instead of 'iwl-net' as it fixes recent commit that causes MAC filter resource leaks that should be fixed as soon as possible. But its status in patchwork is 'Awaiting upstream' so it has to be resubmitted by yourself... Or should this be picked directly by netdev maintainers?

Hi Ivan,

The normal process is that it goes through the IWL trees. It's currently applied to the tree awaiting our validation's tested-by. I will send it on after that occurs.

Thanks,
Tony

Quoted 3 lines

Thanks,
Ivan