mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 18:05:21 +02:00
wifi: wilc1000: fix potential RCU dereference issue in wilc_parse_join_bss_param
[ Upstream commit6d7c6ae1ef
] In the `wilc_parse_join_bss_param` function, the TSF field of the `ies` structure is accessed after the RCU read-side critical section is unlocked. According to RCU usage rules, this is illegal. Reusing this pointer can lead to unpredictable behavior, including accessing memory that has been updated or causing use-after-free issues. This possible bug was identified using a static analysis tool developed by myself, specifically designed to detect RCU-related issues. To address this, the TSF value is now stored in a local variable `ies_tsf` before the RCU lock is released. The `param->tsf_lo` field is then assigned using this local variable, ensuring that the TSF value is safely accessed. Fixes:205c50306a
("wifi: wilc1000: fix RCU usage in connect path") Signed-off-by: Jiawei Ye <jiawei.ye@foxmail.com> Reviewed-by: Alexis Lothoré <alexis.lothore@bootlin.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://patch.msgid.link/tencent_466225AA599BA49627FB26F707EE17BC5407@qq.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
058c9026ad
commit
84398204c5
|
@ -381,6 +381,7 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
|
||||||
struct wilc_join_bss_param *param;
|
struct wilc_join_bss_param *param;
|
||||||
u8 rates_len = 0;
|
u8 rates_len = 0;
|
||||||
int ies_len;
|
int ies_len;
|
||||||
|
u64 ies_tsf;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
param = kzalloc(sizeof(*param), GFP_KERNEL);
|
param = kzalloc(sizeof(*param), GFP_KERNEL);
|
||||||
|
@ -396,6 +397,7 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ies_len = ies->len;
|
ies_len = ies->len;
|
||||||
|
ies_tsf = ies->tsf;
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
param->beacon_period = cpu_to_le16(bss->beacon_interval);
|
param->beacon_period = cpu_to_le16(bss->beacon_interval);
|
||||||
|
@ -451,7 +453,7 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
|
||||||
IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
|
IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
|
||||||
(u8 *)&noa_attr, sizeof(noa_attr));
|
(u8 *)&noa_attr, sizeof(noa_attr));
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
param->tsf_lo = cpu_to_le32(ies->tsf);
|
param->tsf_lo = cpu_to_le32(ies_tsf);
|
||||||
param->noa_enabled = 1;
|
param->noa_enabled = 1;
|
||||||
param->idx = noa_attr.index;
|
param->idx = noa_attr.index;
|
||||||
if (noa_attr.oppps_ctwindow & IEEE80211_P2P_OPPPS_ENABLE_BIT) {
|
if (noa_attr.oppps_ctwindow & IEEE80211_P2P_OPPPS_ENABLE_BIT) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user