[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210212021312.40486-2-skhan@linuxfoundation.org>
Date: Thu, 11 Feb 2021 19:13:07 -0700
From: Shuah Khan <skhan@...uxfoundation.org>
To: tony0620emma@...il.com, kvalo@...eaurora.org, davem@...emloft.net,
kuba@...nel.org
Cc: Shuah Khan <skhan@...uxfoundation.org>,
linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] rtw88: 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 rtw_rx_addr_match_iter() to hold RCU read 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() and a subsequent manual audit
of other callers of ieee80211_find_sta_by_ifaddr() that don't hold
RCU read lock.
Signed-off-by: Shuah Khan <skhan@...uxfoundation.org>
---
- Note: This patch is compile tested. I don't have access to
hardware.
drivers/net/wireless/realtek/rtw88/rx.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtw88/rx.c b/drivers/net/wireless/realtek/rtw88/rx.c
index 7087e385a9b3..4ab3d3e2bfab 100644
--- a/drivers/net/wireless/realtek/rtw88/rx.c
+++ b/drivers/net/wireless/realtek/rtw88/rx.c
@@ -111,6 +111,9 @@ static void rtw_rx_addr_match_iter(void *data, u8 *mac,
return;
rtw_rx_phy_stat(rtwdev, pkt_stat, hdr);
+
+ rcu_read_lock();
+
sta = ieee80211_find_sta_by_ifaddr(rtwdev->hw, hdr->addr2,
vif->addr);
if (!sta)
@@ -118,6 +121,9 @@ static void rtw_rx_addr_match_iter(void *data, u8 *mac,
si = (struct rtw_sta_info *)sta->drv_priv;
ewma_rssi_add(&si->avg_rssi, pkt_stat->rssi);
+
+exit:
+ rcu_read_unlock();
}
static void rtw_rx_addr_match(struct rtw_dev *rtwdev,
--
2.27.0
Powered by blists - more mailing lists