mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rameshkumar Sundaram <rameshkumar.sundaram@oss.qualcomm.com>
To: Jiale Yao <yaojiale02@163.com>,
	Jeff Johnson <jjohnson@kernel.org>,
	Maharaja Kennadyrajan <quic_mkenna@quicinc.com>,
	Govindaraj Saminathan <quic_gsamin@quicinc.com>,
	Karthikeyan Periyasamy <quic_periyasa@quicinc.com>,
	Rajkumar Manoharan <rmanohar@codeaurora.org>,
	Sriram R <quic_srirrama@quicinc.com>,
	linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/5] wifi: ath11k: avoid IDR mutation during vif mgmt TX cleanup
Date: Mon, 12 Oct 2026 10:44:44 +0530	[thread overview]
Message-ID: <167d7bdc-05d0-4d77-8bb5-199a1f8e6aa8@oss.qualcomm.com> (raw)
In-Reply-To: <20261003092104.520135-4-yaojiale02@163.com>

On 10/3/2026 2:51 PM, Jiale Yao wrote:
> ath11k_mac_op_remove_interface() walks txmgmt_idr with idr_for_each(),
> and its callback removes each entry belonging to the interface. Removing
> the current entry can invalidate the radix-tree iterator retained by
> idr_for_each().
> 
> Move the walk into a helper that uses idr_for_each_entry(). It performs a
> fresh lookup for every iteration, so each matching entry can be removed
> through the locked removal helper without retaining iterator state across
> the removal.
> 
> Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
> Signed-off-by: Jiale Yao <yaojiale02@163.com>
> ---
>   drivers/net/wireless/ath/ath11k/mac.c | 21 +++++++++++----------
>   1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
> index f9af403a2f0d..e7ece258f142 100644
> --- a/drivers/net/wireless/ath/ath11k/mac.c
> +++ b/drivers/net/wireless/ath/ath11k/mac.c
> @@ -6176,16 +6176,18 @@ void ath11k_mac_tx_mgmt_pending_free(struct ath11k *ar)
>   		ath11k_mac_tx_mgmt_free(ar, buf_id);
>   }
>   
> -static int ath11k_mac_vif_txmgmt_idr_remove(int buf_id, void *skb, void *ctx)
> +static void ath11k_mac_vif_txmgmt_cleanup(struct ath11k *ar,
> +					  struct ieee80211_vif *vif)
>   {
> -	struct ieee80211_vif *vif = ctx;
> -	struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB((struct sk_buff *)skb);
> -	struct ath11k *ar = skb_cb->ar;
> -
> -	if (skb_cb->vif == vif)
> -		ath11k_mac_tx_mgmt_free(ar, buf_id);
> +	struct ath11k_skb_cb *skb_cb;
> +	struct sk_buff *skb;
> +	int buf_id;
>   
> -	return 0;
> +	idr_for_each_entry(&ar->txmgmt_idr, skb, buf_id) {
> +		skb_cb = ATH11K_SKB_CB(skb);


The skb dereference here appears unsafe. A parallel WMI TX completion 
path can remove the entry from txmgmt_idr and free the skb while the IDR 
is being iterated, leading to a potential UAF when accessing skb_cb->vif.

Would it make sense to hold txmgmt_idr_lock for the duration of the 
iteration and remove the locking from ath11k_mac_tx_mgmt_free()? 
ath11k_mac_tx_mgmt_pending_free() could take the same lock as well.

This looks like a pre-existing issue rather than something introduced by 
this change, so I'm fine with fixing it in a follow-up patch if preferred.


> +		if (skb_cb->vif == vif)
> +			ath11k_mac_tx_mgmt_free(ar, buf_id);
> +	}
>   }
>   
>   static int ath11k_mac_mgmt_tx_wmi(struct ath11k *ar, struct ath11k_vif *arvif,
> @@ -7416,8 +7418,7 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw,
>   
>   	ath11k_peer_cleanup(ar, arvif->vdev_id);
>   
> -	idr_for_each(&ar->txmgmt_idr,
> -		     ath11k_mac_vif_txmgmt_idr_remove, vif);
> +	ath11k_mac_vif_txmgmt_cleanup(ar, vif);
>   
>   	for (i = 0; i < ab->hw_params.hal_params->num_tx_rings; i++) {
>   		spin_lock_bh(&ab->dp.tx_ring[i].tx_idr_lock);


-- 
Ramesh

  reply	other threads:[~2026-10-12  5:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-03  9:20 [PATCH v2 0/5] wifi: ath: avoid IDR mutation while iterating Jiale Yao
2026-10-03  9:20 ` [PATCH v2 1/5] wifi: ath10k: avoid IDR mutation during TX cleanup Jiale Yao
2026-10-10  1:31   ` Jeff Johnson
2026-10-10 14:20     ` Jeff Johnson
2026-10-03  9:20 ` [PATCH v2 2/5] wifi: ath11k: avoid IDR mutation during pending mgmt " Jiale Yao
2026-10-03  9:21 ` [PATCH v2 3/5] wifi: ath11k: avoid IDR mutation during vif " Jiale Yao
2026-10-12  5:14   ` Rameshkumar Sundaram [this message]
2026-10-03  9:21 ` [PATCH v2 4/5] wifi: ath12k: avoid IDR mutation during pending " Jiale Yao
2026-10-03  9:21 ` [PATCH v2 5/5] wifi: ath12k: avoid IDR mutation during vif " Jiale Yao
2026-10-12  5:49   ` Baochen Qiang
2026-10-10 17:07 ` [PATCH v2 0/5] wifi: ath: avoid IDR mutation while iterating Jeff Johnson
2026-10-12  5:52 ` Baochen Qiang
2026-10-12 13:30   ` Jeff Johnson
2026-10-12 15:56 ` Rameshkumar Sundaram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=167d7bdc-05d0-4d77-8bb5-199a1f8e6aa8@oss.qualcomm.com \
    --to=rameshkumar.sundaram@oss.qualcomm.com \
    --cc=ath11k@lists.infradead.org \
    --cc=jjohnson@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=quic_gsamin@quicinc.com \
    --cc=quic_mkenna@quicinc.com \
    --cc=quic_periyasa@quicinc.com \
    --cc=quic_srirrama@quicinc.com \
    --cc=rmanohar@codeaurora.org \
    --cc=yaojiale02@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®