Skip to content

Commit 21779ca

Browse files
Wen Gongharshimogalapalli
authored andcommitted
wifi: ath11k: update channel list in reg notifier instead reg worker
commit 933ab18 upstream. Currently when ath11k gets a new channel list, it will be processed according to the following steps: 1. update new channel list to cfg80211 and queue reg_work. 2. cfg80211 handles new channel list during reg_work. 3. update cfg80211's handled channel list to firmware by ath11k_reg_update_chan_list(). But ath11k will immediately execute step 3 after reg_work is just queued. Since step 2 is asynchronous, cfg80211 may not have completed handling the new channel list, which may leading to an out-of-bounds write error: BUG: KASAN: slab-out-of-bounds in ath11k_reg_update_chan_list Call Trace: ath11k_reg_update_chan_list+0xbfe/0xfe0 [ath11k] kfree+0x109/0x3a0 ath11k_regd_update+0x1cf/0x350 [ath11k] ath11k_regd_update_work+0x14/0x20 [ath11k] process_one_work+0xe35/0x14c0 Should ensure step 2 is completely done before executing step 3. Thus Wen raised patch[1]. When flag NL80211_REGDOM_SET_BY_DRIVER is set, cfg80211 will notify ath11k after step 2 is done. So enable the flag NL80211_REGDOM_SET_BY_DRIVER then cfg80211 will notify ath11k after step 2 is done. At this time, there will be no KASAN bug during the execution of the step 3. [1] https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3 Fixes: f45cb6b ("wifi: ath11k: avoid deadlock during regulatory update in ath11k_regd_update()") Signed-off-by: Wen Gong <[email protected]> Signed-off-by: Kang Yang <[email protected]> Reviewed-by: Aditya Kumar Singh <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jeff Johnson <[email protected]> Signed-off-by: Harshit Mogalapalli <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 26618c039b78a76c373d4e02c5fbd52e3a73aead) Signed-off-by: Harshit Mogalapalli <[email protected]>
1 parent 0ab0243 commit 21779ca

File tree

1 file changed

+15
-7
lines changed
  • drivers/net/wireless/ath/ath11k

1 file changed

+15
-7
lines changed

drivers/net/wireless/ath/ath11k/reg.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66
#include <linux/rtnetlink.h>
77

@@ -55,6 +55,19 @@ ath11k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
5555
ath11k_dbg(ar->ab, ATH11K_DBG_REG,
5656
"Regulatory Notification received for %s\n", wiphy_name(wiphy));
5757

58+
if (request->initiator == NL80211_REGDOM_SET_BY_DRIVER) {
59+
ath11k_dbg(ar->ab, ATH11K_DBG_REG,
60+
"driver initiated regd update\n");
61+
if (ar->state != ATH11K_STATE_ON)
62+
return;
63+
64+
ret = ath11k_reg_update_chan_list(ar, true);
65+
if (ret)
66+
ath11k_warn(ar->ab, "failed to update channel list: %d\n", ret);
67+
68+
return;
69+
}
70+
5871
/* Currently supporting only General User Hints. Cell base user
5972
* hints to be handled later.
6073
* Hints from other sources like Core, Beacons are not expected for
@@ -293,12 +306,6 @@ int ath11k_regd_update(struct ath11k *ar)
293306
if (ret)
294307
goto err;
295308

296-
if (ar->state == ATH11K_STATE_ON) {
297-
ret = ath11k_reg_update_chan_list(ar, true);
298-
if (ret)
299-
goto err;
300-
}
301-
302309
return 0;
303310
err:
304311
ath11k_warn(ab, "failed to perform regd update : %d\n", ret);
@@ -977,6 +984,7 @@ void ath11k_regd_update_work(struct work_struct *work)
977984
void ath11k_reg_init(struct ath11k *ar)
978985
{
979986
ar->hw->wiphy->regulatory_flags = REGULATORY_WIPHY_SELF_MANAGED;
987+
ar->hw->wiphy->flags |= WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER;
980988
ar->hw->wiphy->reg_notifier = ath11k_reg_notifier;
981989
}
982990

0 commit comments

Comments
 (0)