wifi: ath12k: hold RCU read lock when dumping vdev and beacon fw stats
Subsystems (2)
PATCH 1/1 wifi: ath12k: hold RCU read lock when dumping vdev and beacon fw stats
Commit 4498664e2d58 ("wifi: ath12k: use lockdep_assert_in_rcu_read_lock() for RCU assertions") changed the assertion in ath12k_mac_get_arvif() from WARN_ON(!rcu_read_lock_any_held()) to lockdep_assert_in_rcu_read_lock(). The old check was also satisfied by any non-preemptible context, the new one only by rcu_read_lock().
ath12k_wmi_fw_vdev_stats_dump() and ath12k_wmi_fw_bcn_stats_dump() call ath12k_mac_get_arvif() from the debugfs fw_stats open handlers with the wiphy lock and ar->data_lock (spin_lock_bh()) held, but without rcu_read_lock(). On a !PREEMPT_RT kernel with CONFIG_PROVE_RCU=y, opening fw_stats/vdev_stats or fw_stats/beacon_stats is therefore expected to trigger the WARN_ON_ONCE() in ath12k_mac_get_arvif(). PREEMPT_RT is not affected, because spin_lock_bh() takes rcu_read_lock() there.
The warning is a false positive: link vifs are only torn down under the wiphy lock, which both paths hold. Take the RCU read lock in the two helpers anyway, as ath12k_mac_get_arvif() documents and as all its other callers do.
The two callers were found by code inspection, following up on an automated review of the above commit [1]. An AI coding assistant was used for the analysis and to draft this patch and changelog.
Compile tested only.
---
I don't have access to the WCN7850 machine at the moment, so the splat itself is not reproduced; the analysis is from reading the code. I'd appreciate it if someone with hardware and a PROVE_RCU kernel could confirm.
The review in [1] also claims a use-after-free in the fw stats RX path on PREEMPT_RT. I don't think that one is real:ath12k_wmi_tlv_fw_stats_data_parse() takes rcu_read_lock() around its use of the arvif.
Build tested on x86_64 with CONFIG_PROVE_LOCKING=y and CONFIG_ATH12K_DEBUGFS=y, W=1, no new warnings.
drivers/net/wireless/ath/ath12k/wmi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath12k/wmi.c +4 -0
@@ -8038,6 +8038,8 @@ ath12k_wmi_fw_vdev_stats_dump(struct ath12k *ar,u8 *vif_macaddr;int i; +guard (rcu)(); + len +=scnprintf (buf + len, buf_len - len,"\n" ); len +=scnprintf (buf + len, buf_len - len,"%30s\n" ,"ath12k VDEV stats" );
@@ -8116,6 +8118,8 @@ ath12k_wmi_fw_bcn_stats_dump(struct ath12k *ar,u32 len = *length;size_t num_bcn; +guard (rcu)(); + num_bcn =list_count_nodes (&fw_stats->bcn); len +=scnprintf (buf + len, buf_len - len,"\n" );
base-commit: 92adc530e9b0c1f680a3b78326e069b55ccf2029
Signature · 1 line
2.56.0