Skip to contentSkip to conversation

iavf: Fix ping is lost after untrusted VF had tried to change MAC

PATCH Superseded Mateusz Palczewski 2 participants 2 messages Jun 23, 2021 – Jun 24, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iavf: Fix ping is lost after untrusted VF had tried to change MAC

From: Sylwester Dziedziuch <[email protected]>

Make changes to MAC address dependent on the response of PF. Disallow changes to hw mac address and mac filter from untrusted VF, thanks to that ping is not lost if VF tries to change MAC. Add a new field in iavf_mac_filter, to indicate whether there was response from PF for given filter. Based on this field pass or discard the filter.
If untrusted VF tried to change it's address, it's not changed. Still filter was changed, because of that ping couldn't go through.

Fixes c5c922b3e09b ("iavf: fix MAC address setting for VFs when filter is rejected")
---
 drivers/net/ethernet/intel/iavf/iavf.h        |  1 +
 drivers/net/ethernet/intel/iavf/iavf_main.c   |  1 +
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   | 47 ++++++++++++++++++-
 3 files changed, 47 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +1 -0
index 9ccb88e..b79d02f 100644
@@ -137,6 +137,7 @@ struct iavf_q_vector {
 struct iavf_mac_filter {
 	struct list_head list;
 	u8 macaddr[ETH_ALEN];
+	bool is_new_mac;	/* filter is new, wait for PF decision */
 	bool remove;		/* filter needs to be removed */
 	bool add;		/* filter needs to be added */
 };
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -0
index d64e256..c9d9bf9 100644
@@ -797,6 +797,7 @@ struct iavf_mac_filter *iavf_add_filter(struct iavf_adapter *adapter,
 
 		list_add_tail(&f->list, &adapter->mac_filter_list);
 		f->add = true;
+		f->is_new_mac = true;
 		adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER;
 	} else {
 		f->remove = false;
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +45 -2

67 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 iavf: Fix ping is lost after untrusted VF had tried to change MAC

Quoted 18 lines · Mateusz Palczewski

From: Sylwester Dziedziuch <[email protected]>

Make changes to MAC address dependent on the response of PF. Disallow changes to hw mac address and mac filter from untrusted VF, thanks to that ping is not lost if VF tries to change MAC. Add a new field in iavf_mac_filter, to indicate whether there was response from PF for given filter. Based on this field pass or discard the filter.
If untrusted VF tried to change it's address, it's not changed. Still filter was changed, because of that ping couldn't go through.

Fixes c5c922b3e09b ("iavf: fix MAC address setting for VFs when

filter is rejected")
Signed-off-by: Przemyslaw Patynowski <
przemyslawx.patynowski at intel.com>

---

<snip>

Quoted 2 lines

+/**
+ * iavf_is_mac_add_ok

Please fix this to match the function name.

warning: expecting prototype for iavf_is_mac_add_ok(). Prototype was for iavf_mac_add_ok() instead

Quoted 11 lines

+ * @adapter: adapter structure
+ *
+ * Submit list of filters based on PF response.
+ **/

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +6 -0
+static void iavf_mac_add_ok(struct iavf_adapter *adapter)
+{
+	struct iavf_mac_filter *f, *ftmp;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);
+	list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list,

list) {

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c void iavf_del_ether_addrs(struct iavf_adapter *adapter) · line 561

Quoted 7 lines
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +7 -0
+		f->is_new_mac = false;
+	}
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+}
+
+/**
+ * iavf_is_mac_add_reject

Same here.

warning: expecting prototype for iavf_is_mac_add_reject(). Prototype was for iavf_mac_add_reject() instead

Quoted 5 lines

+ * @adapter: adapter structure
+ *
+ * Remove filters from list based on PF response.
+ **/
+static void iavf_mac_add_reject(struct iavf_adapter *adapter)