Skip to contentSkip to conversation

iavf: Fix double free in iavf_reset_task

PATCH New Mateusz Palczewski 2 participants 2 messages Mar 9, 2022 – Mar 15, 2022

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

PATCH 1/1 iavf: Fix double free in iavf_reset_task

From: Przemyslaw Patynowski <[email protected]>

Fix double free possibility in iavf_disable_vf, as crit_lock is freed in caller, iavf_reset_task. Add kernel-doc for iavf_disable_vf. Remove mutex_unlock in iavf_disable_vf.
Without this patch there is double free scenario, when calling iavf_reset_task.

Fixes e85ff9c631e1 ("iavf: Fix deadlock in iavf_reset_task")

---
Note: This is targeted to net-next because it fixes a patch that is not present in net.

---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +7 -1
index 7c4b75a..c11e2ab 100644
@@ -2705,6 +2705,13 @@ static void iavf_watchdog_task(struct work_struct *work)
 		queue_delayed_work(iavf_wq, &adapter->watchdog_task, HZ * 2);
 }
 
+/**
+ * iavf_disable_vf - disable VF
+ * @adapter: board private structure
+ *
+ * Set communication failed flag and free all resources.
+ * NOTE: This function is expected to be called with crit_lock being held.
+ **/
 static void iavf_disable_vf(struct iavf_adapter *adapter)
 {
 	struct iavf_mac_filter *f, *ftmp;
@@ -2759,7 +2766,6 @@ static void iavf_disable_vf(struct iavf_adapter *adapter)
 	memset(adapter->vf_res, 0, IAVF_VIRTCHNL_VF_RESOURCE_SIZE);
 	iavf_shutdown_adminq(&adapter->hw);
 	adapter->netdev->flags &= ~IFF_UP;
-	mutex_unlock(&adapter->crit_lock);
 	adapter->flags &= ~IAVF_FLAG_RESET_PENDING;
 	iavf_change_state(adapter, __IAVF_DOWN);
 	wake_up(&adapter->down_waitqueue);
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/1 iavf: Fix double free in iavf_reset_task

drivers/net/ethernet/intel/iavf/iavf_main.c static void iavf_watchdog_task(struct work_struct

Quoted 39 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Mateusz Palczewski
Sent: Wednesday, March 9, 2022 4:38 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Palczewski, Mateusz <[email protected]>; Patynowski, PrzemyslawX <[email protected]>; Dan Carpenter <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next v1] iavf: Fix double free in iavf_reset_task

From: Przemyslaw Patynowski <[email protected]>

Fix double free possibility in iavf_disable_vf, as crit_lock is freed in caller, iavf_reset_task. Add kernel-doc for iavf_disable_vf.
Remove mutex_unlock in iavf_disable_vf.
Without this patch there is double free scenario, when calling iavf_reset_task.

Fixes e85ff9c631e1 ("iavf: Fix deadlock in iavf_reset_task")
Signed-off-by Przemyslaw Patynowski

<[email protected]>

---
Note: This is targeted to net-next because it fixes a patch that is not present
in net.

---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -0
index 7c4b75a..c11e2ab 100644
@@ -2705,6 +2705,13 @@ static void iavf_watchdog_task(struct work_struct