Commit ea2a1cfc authored by Ivan Vecera's avatar Ivan Vecera Committed by Jakub Kicinski
Browse files

i40e: Fix VF MAC filter removal



Commit 73d9629e ("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: 73d9629e ("i40e: Do not allow untrusted VF to remove administratively set MAC")
Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
Reviewed-by: default avatarMichal Schmidt <mschmidt@redhat.com>
Reviewed-by: default avatarBrett Creeley <brett.creeley@amd.com>
Tested-by: default avatarRafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
Link: https://lore.kernel.org/r/20240329180638.211412-1-anthony.l.nguyen@intel.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0323b251
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -3137,11 +3137,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))
		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;