mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH ath-next] wifi: ath12k: hold txmgmt_idr_lock while freeing pending mgmt frames
@ 2026-11-16  2:10 Changyul Lee
  2026-11-16  9:34 ` Rameshkumar Sundaram
  0 siblings, 1 reply; 2+ messages in thread
From: Changyul Lee @ 2026-11-16  2:10 UTC (permalink / raw)
  To: Jeff Johnson
  Cc: Baochen Qiang, Sriram R, Vasanthakumar Thiagarajan, Praneesh P,
	Jiale Yao, linux-wireless, ath12k, linux-kernel, Changyul Lee,
	Rameshkumar Sundaram

ath12k_mac_vif_txmgmt_cleanup() and ath12k_mac_tx_mgmt_pending_free()
walk ar->txmgmt_idr without txmgmt_idr_lock. A WMI management TX
completion can meanwhile remove an entry and pass its skb to mac80211,
which frees it. ath12k_mac_vif_txmgmt_cleanup() then reads skb_cb->vif
from the freed skb, and both walks can read an IDR node that was freed
after an RCU grace period.

Hold txmgmt_idr_lock over both walks and make ath12k_mac_tx_mgmt_free()
expect it to be held.

Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
Suggested-by: Rameshkumar Sundaram <rameshkumar.sundaram@oss.qualcomm.com>
Signed-off-by: Changyul Lee <lcy8047@gmail.com>
---
Found with a static analysis tool we are developing.
Compile-tested only, with x86_64_defconfig plus ATH12K and W=1.

 drivers/net/wireless/ath/ath12k/mac.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index eee3f38375ae..bffb2edd0531 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -9220,10 +9220,9 @@ static void ath12k_mac_tx_mgmt_free(struct ath12k *ar, int buf_id)
 	struct sk_buff *msdu;
 	struct ieee80211_tx_info *info;
 
-	spin_lock_bh(&ar->txmgmt_idr_lock);
-	msdu = idr_remove(&ar->txmgmt_idr, buf_id);
-	spin_unlock_bh(&ar->txmgmt_idr_lock);
+	lockdep_assert_held(&ar->txmgmt_idr_lock);
 
+	msdu = idr_remove(&ar->txmgmt_idr, buf_id);
 	if (!msdu)
 		return;
 
@@ -9241,8 +9240,10 @@ void ath12k_mac_tx_mgmt_pending_free(struct ath12k *ar)
 	struct sk_buff *msdu;
 	int buf_id;
 
+	spin_lock_bh(&ar->txmgmt_idr_lock);
 	idr_for_each_entry(&ar->txmgmt_idr, msdu, buf_id)
 		ath12k_mac_tx_mgmt_free(ar, buf_id);
+	spin_unlock_bh(&ar->txmgmt_idr_lock);
 }
 
 static void ath12k_mac_vif_txmgmt_cleanup(struct ath12k *ar,
@@ -9252,11 +9253,13 @@ static void ath12k_mac_vif_txmgmt_cleanup(struct ath12k *ar,
 	struct sk_buff *skb;
 	int buf_id;
 
+	spin_lock_bh(&ar->txmgmt_idr_lock);
 	idr_for_each_entry(&ar->txmgmt_idr, skb, buf_id) {
 		skb_cb = ATH12K_SKB_CB(skb);
 		if (skb_cb->vif == vif)
 			ath12k_mac_tx_mgmt_free(ar, buf_id);
 	}
+	spin_unlock_bh(&ar->txmgmt_idr_lock);
 }
 
 static int ath12k_mac_mgmt_tx_wmi(struct ath12k *ar, struct ath12k_link_vif *arvif,

base-commit: 1be6c8d3027d4a421dc46b93a89a196c61945614
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH ath-next] wifi: ath12k: hold txmgmt_idr_lock while freeing pending mgmt frames
  2026-11-16  2:10 [PATCH ath-next] wifi: ath12k: hold txmgmt_idr_lock while freeing pending mgmt frames Changyul Lee
@ 2026-11-16  9:34 ` Rameshkumar Sundaram
  0 siblings, 0 replies; 2+ messages in thread
From: Rameshkumar Sundaram @ 2026-11-16  9:34 UTC (permalink / raw)
  To: Changyul Lee, Jeff Johnson
  Cc: Baochen Qiang, Sriram R, Vasanthakumar Thiagarajan, Praneesh P,
	Jiale Yao, linux-wireless, ath12k, linux-kernel

On 11/16/2026 7:40 AM, Changyul Lee wrote:
> ath12k_mac_vif_txmgmt_cleanup() and ath12k_mac_tx_mgmt_pending_free()
> walk ar->txmgmt_idr without txmgmt_idr_lock. A WMI management TX
> completion can meanwhile remove an entry and pass its skb to mac80211,
> which frees it. ath12k_mac_vif_txmgmt_cleanup() then reads skb_cb->vif
> from the freed skb, and both walks can read an IDR node that was freed
> after an RCU grace period.
> 
> Hold txmgmt_idr_lock over both walks and make ath12k_mac_tx_mgmt_free()
> expect it to be held.
> 
> Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
> Suggested-by: Rameshkumar Sundaram <rameshkumar.sundaram@oss.qualcomm.com>
> Signed-off-by: Changyul Lee <lcy8047@gmail.com>
> ---
> Found with a static analysis tool we are developing.
> Compile-tested only, with x86_64_defconfig plus ATH12K and W=1.
> 
>   drivers/net/wireless/ath/ath12k/mac.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
> index eee3f38375ae..bffb2edd0531 100644
> --- a/drivers/net/wireless/ath/ath12k/mac.c
> +++ b/drivers/net/wireless/ath/ath12k/mac.c
> @@ -9220,10 +9220,9 @@ static void ath12k_mac_tx_mgmt_free(struct ath12k *ar, int buf_id)
>   	struct sk_buff *msdu;
>   	struct ieee80211_tx_info *info;
>   
> -	spin_lock_bh(&ar->txmgmt_idr_lock);
> -	msdu = idr_remove(&ar->txmgmt_idr, buf_id);
> -	spin_unlock_bh(&ar->txmgmt_idr_lock);
> +	lockdep_assert_held(&ar->txmgmt_idr_lock);
>   
> +	msdu = idr_remove(&ar->txmgmt_idr, buf_id);
>   	if (!msdu)
>   		return;
>   
> @@ -9241,8 +9240,10 @@ void ath12k_mac_tx_mgmt_pending_free(struct ath12k *ar)
>   	struct sk_buff *msdu;
>   	int buf_id;
>   
> +	spin_lock_bh(&ar->txmgmt_idr_lock);
>   	idr_for_each_entry(&ar->txmgmt_idr, msdu, buf_id)
>   		ath12k_mac_tx_mgmt_free(ar, buf_id);
> +	spin_unlock_bh(&ar->txmgmt_idr_lock);
>   }
>   
>   static void ath12k_mac_vif_txmgmt_cleanup(struct ath12k *ar,
> @@ -9252,11 +9253,13 @@ static void ath12k_mac_vif_txmgmt_cleanup(struct ath12k *ar,
>   	struct sk_buff *skb;
>   	int buf_id;
>   
> +	spin_lock_bh(&ar->txmgmt_idr_lock);
>   	idr_for_each_entry(&ar->txmgmt_idr, skb, buf_id) {
>   		skb_cb = ATH12K_SKB_CB(skb);
>   		if (skb_cb->vif == vif)
>   			ath12k_mac_tx_mgmt_free(ar, buf_id);
>   	}
> +	spin_unlock_bh(&ar->txmgmt_idr_lock);
>   }
>   
>   static int ath12k_mac_mgmt_tx_wmi(struct ath12k *ar, struct ath12k_link_vif *arvif,
> 
> base-commit: 1be6c8d3027d4a421dc46b93a89a196c61945614


Reviewed-by: Rameshkumar Sundaram <rameshkumar.sundaram@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-16  9:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16  2:10 [PATCH ath-next] wifi: ath12k: hold txmgmt_idr_lock while freeing pending mgmt frames Changyul Lee
2026-11-16  9:34 ` Rameshkumar Sundaram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®