2024-02-23 05:45:34

by Kang Yang

[permalink] [raw]
Subject: [PATCH] wifi: ath12k: add rcu lock for ath12k_wmi_p2p_noa_event()

Warning will appear when running P2P GO:

WARNING: suspicious RCU usage
drivers/net/wireless/ath/ath12k/mac.c:583 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
no locks held by swapper/0/0.
stack backtrace:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.8.0-rc4-wt-ath+ #4
Call Trace:
<IRQ>
dump_stack_lvl+0x82/0xa0
dump_stack+0x14/0x20
lockdep_rcu_suspicious+0x214/0x3b0
ath12k_mac_get_ar_by_vdev_id+0x192/0x220 [ath12k]
ath12k_wmi_op_rx+0x2d7/0x1b40 [ath12k]

ath12k_mac_get_ar_by_vdev_id() requires its callers to have called
rcu_read_lock(), but in ath12k_wmi_p2p_noa_event() it is called without
doing so, and hence the warning was triggered.

Add rcu_read_lock() and rcu_read_unlock() to avoid warning.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Fixes: 9411eecb60cb ("wifi: ath12k: implement handling of P2P NoA event")
Reported-by: Kalle Valo <[email protected]>
Closes: https://lore.kernel.org/linux-wireless/[email protected]/
Signed-off-by: Kang Yang <[email protected]>
---
drivers/net/wireless/ath/ath12k/wmi.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index 838161dd9098..9d69a1769926 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -6736,18 +6736,21 @@ static int ath12k_wmi_p2p_noa_event(struct ath12k_base *ab,
"wmi tlv p2p noa vdev_id %i descriptors %u\n",
vdev_id, le32_get_bits(noa->noa_attr, WMI_P2P_NOA_INFO_DESC_NUM));

+ rcu_read_lock();
ar = ath12k_mac_get_ar_by_vdev_id(ab, vdev_id);
if (!ar) {
ath12k_warn(ab, "invalid vdev id %d in P2P NoA event\n",
vdev_id);
ret = -EINVAL;
- goto out;
+ goto unlock;
}

ath12k_p2p_noa_update_by_vdev_id(ar, vdev_id, noa);

ret = 0;

+unlock:
+ rcu_read_unlock();
out:
kfree(tb);
return ret;

base-commit: 707e306f3573fa321ae197d77366578e4566cff5
--
2.34.1



2024-02-23 18:11:15

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH] wifi: ath12k: add rcu lock for ath12k_wmi_p2p_noa_event()

On 2/22/2024 9:45 PM, Kang Yang wrote:
> Warning will appear when running P2P GO:
>
> WARNING: suspicious RCU usage
> drivers/net/wireless/ath/ath12k/mac.c:583 suspicious rcu_dereference_check() usage!
> other info that might help us debug this:
> rcu_scheduler_active = 2, debug_locks = 1
> no locks held by swapper/0/0.
> stack backtrace:
> CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.8.0-rc4-wt-ath+ #4
> Call Trace:
> <IRQ>
> dump_stack_lvl+0x82/0xa0
> dump_stack+0x14/0x20
> lockdep_rcu_suspicious+0x214/0x3b0
> ath12k_mac_get_ar_by_vdev_id+0x192/0x220 [ath12k]
> ath12k_wmi_op_rx+0x2d7/0x1b40 [ath12k]
>
> ath12k_mac_get_ar_by_vdev_id() requires its callers to have called
> rcu_read_lock(), but in ath12k_wmi_p2p_noa_event() it is called without
> doing so, and hence the warning was triggered.
>
> Add rcu_read_lock() and rcu_read_unlock() to avoid warning.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Fixes: 9411eecb60cb ("wifi: ath12k: implement handling of P2P NoA event")
> Reported-by: Kalle Valo <[email protected]>
> Closes: https://lore.kernel.org/linux-wireless/[email protected]/
> Signed-off-by: Kang Yang <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-02-28 14:07:32

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH] wifi: ath12k: add rcu lock for ath12k_wmi_p2p_noa_event()

Kang Yang <[email protected]> wrote:

> Warning will appear when running P2P GO:
>
> WARNING: suspicious RCU usage
> drivers/net/wireless/ath/ath12k/mac.c:583 suspicious rcu_dereference_check() usage!
> other info that might help us debug this:
> rcu_scheduler_active = 2, debug_locks = 1
> no locks held by swapper/0/0.
> stack backtrace:
> CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.8.0-rc4-wt-ath+ #4
> Call Trace:
> <IRQ>
> dump_stack_lvl+0x82/0xa0
> dump_stack+0x14/0x20
> lockdep_rcu_suspicious+0x214/0x3b0
> ath12k_mac_get_ar_by_vdev_id+0x192/0x220 [ath12k]
> ath12k_wmi_op_rx+0x2d7/0x1b40 [ath12k]
>
> ath12k_mac_get_ar_by_vdev_id() requires its callers to have called
> rcu_read_lock(), but in ath12k_wmi_p2p_noa_event() it is called without
> doing so, and hence the warning was triggered.
>
> Add rcu_read_lock() and rcu_read_unlock() to avoid warning.
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Fixes: 9411eecb60cb ("wifi: ath12k: implement handling of P2P NoA event")
> Reported-by: Kalle Valo <[email protected]>
> Closes: https://lore.kernel.org/linux-wireless/[email protected]/
> Signed-off-by: Kang Yang <[email protected]>
> Acked-by: Jeff Johnson <[email protected]>
> Signed-off-by: Kalle Valo <[email protected]>

Patch applied to ath-next branch of ath.git, thanks.

ee3b63586b30 wifi: ath12k: add rcu lock for ath12k_wmi_p2p_noa_event()

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches