Skip to contentSkip to conversation

ath10k: hold RCU lock when calling ieee80211_find_sta_by_ifaddr()

PATCH In review Shuah Khan 2 participants 3 messages Feb 10, 2021 – Feb 11, 2021

Subsystems (3)
lore
Share & tools
lore

Shuah Khan

author
#0 lore raw

PATCH v2 1/1 ath10k: hold RCU lock when calling ieee80211_find_sta_by_ifaddr()

ieee80211_find_sta_by_ifaddr() must be called under the RCU lock and the resulting pointer is only valid under RCU lock as well.

Fix ath10k_wmi_tlv_op_pull_peer_stats_info() to hold RCU lock before it calls ieee80211_find_sta_by_ifaddr() and release it when the resulting pointer is no longer needed.

This problem was found while reviewing code to debug RCU warn from ath10k_wmi_tlv_parse_peer_stats_info().

---
Changes since v1:
- v1 also included fix to ath10k_wmi_tlv_parse_peer_stats_info() RCU wrn which was already fixed. v2 drops that and fixes just ath10k_wmi_event_tdls_peer()

 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/wmi-tlv.c +5 -2
index bfdd017f1405..d97b33f789e4 100644
@@ -576,13 +576,13 @@ static void ath10k_wmi_event_tdls_peer(struct ath10k *ar, struct sk_buff *skb)
 	case WMI_TDLS_TEARDOWN_REASON_TX:
 	case WMI_TDLS_TEARDOWN_REASON_RSSI:
 	case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
+		rcu_read_lock();
 		station = ieee80211_find_sta_by_ifaddr(ar->hw,
 						       ev->peer_macaddr.addr,
 						       NULL);
 		if (!station) {
 			ath10k_warn(ar, "did not find station from tdls peer event");
-			kfree(tb);
-			return;
+			goto exit;
 		}
 		arvif = ath10k_get_arvif(ar, __le32_to_cpu(ev->vdev_id));
 		ieee80211_tdls_oper_request(
@@ -593,6 +593,9 @@ static void ath10k_wmi_event_tdls_peer(struct ath10k *ar, struct sk_buff *skb)
 					);
 		break;
 	}
+
+exit:
+	rcu_read_unlock();
 	kfree(tb);
 }
 
Signature · 7 lines
2.27.0


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#1 lore raw
Quoted 7 lines · Shuah Khan

ieee80211_find_sta_by_ifaddr() must be called under the RCU lock and the resulting pointer is only valid under RCU lock as well.

Fix ath10k_wmi_tlv_op_pull_peer_stats_info() to hold RCU lock before it calls ieee80211_find_sta_by_ifaddr() and release it when the resulting pointer is no longer needed.

Quoted 6 lines

This problem was found while reviewing code to debug RCU warn from ath10k_wmi_tlv_parse_peer_stats_info().

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

09078368d516 ath10k: hold RCU lock when calling ieee80211_find_sta_by_ifaddr()

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

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


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#2 lore raw
In reply to Shuah Khan
Quoted 7 lines · Shuah Khan

ieee80211_find_sta_by_ifaddr() must be called under the RCU lock and the resulting pointer is only valid under RCU lock as well.

Fix ath10k_wmi_tlv_op_pull_peer_stats_info() to hold RCU lock before it calls ieee80211_find_sta_by_ifaddr() and release it when the resulting pointer is no longer needed.

Quoted 6 lines

This problem was found while reviewing code to debug RCU warn from ath10k_wmi_tlv_parse_peer_stats_info().

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

09078368d516 ath10k: hold RCU lock when calling ieee80211_find_sta_by_ifaddr()

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

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