Skip to contentSkip to conversation

wifi: mwifiex: hold ack_status_lock while freeing pending ack frames

PATCH New Changyul Lee 1 participant 1 message Nov 16 Marvell mwifiex wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: mwifiex: hold ack_status_lock while freeing pending ack frames

mwifiex_clean_txrx() frees the frames left in priv->ack_status_frames and destroys the IDR without ack_status_lock. It runs on every disconnect from the event work, while mwifiex_clone_skb_for_tx_status() can still add an entry from the mgmt TX or data TX path. idr_destroy() then drops the new entry and leaks its skb, and idr_alloc() can write to a node that idr_destroy() has already passed to call_rcu().

Hold ack_status_lock around both calls, as the other users of the IDR do.

Fixes 808bbebcc8fc ("mwifiex: add Tx status support for EAPOL packets")

---
Found with a static analysis tool we are developing.

Compile-tested only, with x86_64_defconfig plus MWIFIEX_SDIO, MWIFIEX_PCIE, MWIFIEX_USB and W=1.

 drivers/net/wireless/marvell/mwifiex/wmm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/wireless/marvell/mwifiex/wmm.c +2 -0
index 841505e83c7f..b889a58c7f6c 100644
@@ -611,8 +611,10 @@ mwifiex_clean_txrx(struct mwifiex_private *priv)
 	}
 	atomic_set(&priv->adapter->bypass_tx_pending, 0);
 
+	spin_lock_bh(&priv->ack_status_lock);
 	idr_for_each(&priv->ack_status_frames, mwifiex_free_ack_frame, NULL);
 	idr_destroy(&priv->ack_status_frames);
+	spin_unlock_bh(&priv->ack_status_lock);
 }
 
 /*

base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb

Signature · 1 line
2.43.0