wifi: rtl8xxxu: Fix use after rcu_read_unlock()
PATCH 1/1 wifi: rtl8xxxu: Fix use after rcu_read_unlock()
... in rtl8xxxu_bss_info_changed().
Commit a8b5aef2cca1 ("wifi: rtl8xxxu: gen2: Enable 40 MHz channel width") introduced a line where the pointer returned by ieee80211_find_sta() is used after rcu_read_unlock().
Move rcu_read_unlock() a bit lower to fix this.
---
My bad. I'm not sure how serious this problem is because I've been using this code all this time (2+ months) without any trouble. I only noticed it when moving some of this code into a new function.
--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +1 -1
@@ -4645,7 +4645,6 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,if (sta->deflink.ht_cap.cap & (IEEE80211_HT_CAP_SGI_40 |IEEE80211_HT_CAP_SGI_20 )) sgi =1 ; -rcu_read_unlock (); highest_rate =fls (ramask) -1 ;if (highest_rate <DESC_RATE_MCS0 ) {
@@ -4670,6 +4669,7 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,else rarpt->txrate.bw =RATE_INFO_BW_20 ; } +rcu_read_unlock (); bit_rate =cfg80211_calculate_bitrate (&rarpt->txrate); rarpt->bit_rate = bit_rate; rarpt->desc_rate = highest_rate;
Signature · 1 line
2.38.0
Quoted 10 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Monday, November 21, 2022 4:47 AM
To: [email protected]
Cc: Jes Sorensen <[email protected]>
Subject: [PATCH] wifi: rtl8xxxu: Fix use afterrcu_read_unlock()... in
rtl8xxxu_bss_info_changed().
Mentioned where you modify in subject might be better.
Quoted 5 lines
Commit
a8b5aef2cca1("wifi: rtl8xxxu: gen2: Enable 40 MHz channel width") introduced a line where the pointer returned byieee80211_find_sta()is used afterrcu_read_unlock().
Quoted 8 lines
Move
rcu_read_unlock()a bit lower to fix this.Fixes a8b5aef2cca1 ("wifi: rtl8xxxu: gen2: Enable 40 MHz channel width")Signed-off-by Bitterblue Smith <[email protected]>---
My bad. I'm not sure how serious this problem is because I've been using this code all this time (2+ months) without any trouble. I only noticed it when moving some of this code into a new function.
'sta' can be freed if a station leaves, and then causes use-after-free. But, luckily iface_work processes rtl8xxxu_bss_info_changed() and 'sta' leaving, so it will not happen at the same time.
Quoted 29 lines
--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +1
-2@@ -4645,7 +4645,6 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,if (sta->deflink.ht_cap.cap & (IEEE80211_HT_CAP_SGI_40 |IEEE80211_HT_CAP_SGI_20 )) sgi =1 ; -rcu_read_unlock (); highest_rate =fls (ramask) -1 ;if (highest_rate <DESC_RATE_MCS0 ) {@@ -4670,6 +4669,7 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,else rarpt->txrate.bw =RATE_INFO_BW_20 ; } +rcu_read_unlock (); bit_rate =cfg80211_calculate_bitrate (&rarpt->txrate); rarpt->bit_rate = bit_rate; rarpt->desc_rate = highest_rate; --2.38.0
------Please consider the environment before printing this e-mail.
Quoted 9 lines · Ping-Ke Shih
Quoted 9 lines
-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Monday, November 21, 2022 4:47 AM
To: [email protected]
Cc: Jes Sorensen <[email protected]>
Subject: [PATCH] wifi: rtl8xxxu: Fix use afterrcu_read_unlock()
Quoted 4 lines
Quoted 1 line
... in
rtl8xxxu_bss_info_changed().Mentioned where you modify in subject might be better.
Okay.
Quoted 14 lines
Quoted 5 lines
Commit
a8b5aef2cca1("wifi: rtl8xxxu: gen2: Enable 40 MHz channel width") introduced a line where the pointer returned byieee80211_find_sta()is used afterrcu_read_unlock().Quoted 8 lines
Move
rcu_read_unlock()a bit lower to fix this.Fixes a8b5aef2cca1 ("wifi: rtl8xxxu: gen2: Enable 40 MHz channel width")Signed-off-by Bitterblue Smith <[email protected]>---
My bad. I'm not sure how serious this problem is because I've been using this code all this time (2+ months) without any trouble. I only noticed it when moving some of this code into a new function.
Quoted 4 lines
'sta' can be freed if a station leaves, and then causes use-after-free. But, luckily
iface_workprocessesrtl8xxxu_bss_info_changed()and 'sta' leaving, so it will not happen at the same time.
That's good then.
Quoted 29 lines
Quoted 29 lines
--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +1
-2@@ -4645,7 +4645,6 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,if (sta->deflink.ht_cap.cap & (IEEE80211_HT_CAP_SGI_40 |IEEE80211_HT_CAP_SGI_20 )) sgi =1 ; -rcu_read_unlock (); highest_rate =fls (ramask) -1 ;if (highest_rate <DESC_RATE_MCS0 ) {@@ -4670,6 +4669,7 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,else rarpt->txrate.bw =RATE_INFO_BW_20 ; } +rcu_read_unlock (); bit_rate =cfg80211_calculate_bitrate (&rarpt->txrate); rarpt->bit_rate = bit_rate; rarpt->desc_rate = highest_rate; --2.38.0
------Please consider the environment before printing this e-mail.