Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH ath-next] wifi: ath11k: Hold the ring lock when returning a monitor link descriptor
@ 2026-12-04 18:51 Praneeth Balasubramanian
  0 siblings, 0 replies; only message in thread
From: Praneeth Balasubramanian @ 2026-12-04 18:51 UTC (permalink / raw)
  To: Jeff Johnson
  Cc: linux-wireless, ath11k, linux-kernel, Praneeth Balasubramanian,
	stable

ath11k_dp_rx_monitor_link_desc_return() writes an entry into a source
ring with ath11k_hal_srng_access_begin(),
ath11k_hal_srng_src_get_next_entry() and ath11k_hal_srng_access_end().
All three assert with lockdep_assert_held() that srng->lock is held, but
this function never takes it. On chips with rxdma1_enable (IPQ8074,
IPQ6018, QCN9074, IPQ5018) it is called for every link descriptor in
monitor mode, so a kernel with lockdep warns three times per call.

The ring it uses there, rxdma_mon_desc_ring, is only written by the
monitor path under pmon->mon_lock, so this is not a data race today.
The function would also pick wbm_desc_rel_ring on chips without
rxdma1, and that ring is shared with ath11k_dp_rx_link_desc_return(),
which takes srng->lock. No current caller reaches that branch.

Take srng->lock around the ring access, as
ath11k_dp_rx_link_desc_return() and ath11k_dp_link_desc_setup() do. Each
ring has its own lock class, so nesting it under the destination ring
lock held by the callers does not trigger lockdep.

The missing lock was found by a static check that turns lockdep
assertions into Clang context-analysis requirements on the callers.
Compile tested only.

Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
Cc: stable@vger.kernel.org
Signed-off-by: Praneeth Balasubramanian <praneethb2002@gmail.com>
---

Notes:
    This was found by a compiler-based check, part of research at UCSB SecLab.
    A lockdep_assert_held() at the start of a function is turned into a Clang
    context-analysis requirement (__must_hold) on that function, and Clang 23
    with CONFIG_WARN_CONTEXT_ANALYSIS then checks every caller. No LLM was
    involved in finding the bug. The patch and changelog were drafted with
    Claude Opus 5.5. I reviewed the patch and take responsibility for it.
    
    Testing: builds without new warnings with W=1 (x86_64, clang 23,
    allmodconfig). Not runtime-tested; I do not have this hardware, and I
    have not seen the warning myself.

 drivers/net/wireless/ath/ath11k/dp_rx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c
index 6d95f7b343a5..e3844bfb0dd5 100644
--- a/drivers/net/wireless/ath/ath11k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_rx.c
@@ -4542,7 +4542,7 @@ int ath11k_dp_rx_monitor_link_desc_return(struct ath11k *ar,
 {
 	struct ath11k_pdev_dp *dp = &ar->dp;
 	struct dp_srng *dp_srng;
-	void *hal_srng;
+	struct hal_srng *hal_srng;
 	void *src_srng_desc;
 	int ret = 0;
 
@@ -4554,6 +4554,8 @@ int ath11k_dp_rx_monitor_link_desc_return(struct ath11k *ar,
 		hal_srng = &ar->ab->hal.srng_list[dp_srng->ring_id];
 	}
 
+	spin_lock_bh(&hal_srng->lock);
+
 	ath11k_hal_srng_access_begin(ar->ab, hal_srng);
 
 	src_srng_desc = ath11k_hal_srng_src_get_next_entry(ar->ab, hal_srng);
@@ -4569,6 +4571,9 @@ int ath11k_dp_rx_monitor_link_desc_return(struct ath11k *ar,
 	}
 
 	ath11k_hal_srng_access_end(ar->ab, hal_srng);
+
+	spin_unlock_bh(&hal_srng->lock);
+
 	return ret;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-04 18:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 18:51 [PATCH ath-next] wifi: ath11k: Hold the ring lock when returning a monitor link descriptor Praneeth Balasubramanian

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