* [PATCH] wifi: cfg80211: Fix use-after-free bug in brcmf_cfg80211_detach
@ 2023-11-04 5:47 Zheng Wang
2023-11-04 9:34 ` kernel test robot
2023-11-04 16:29 ` Johannes Berg
0 siblings, 2 replies; 3+ messages in thread
From: Zheng Wang @ 2023-11-04 5:47 UTC (permalink / raw
To: aspriel
Cc: franky.lin, hante.meuleman, kvalo, johannes.berg, marcan,
linus.walleij, jisoo.jang, linuxlovemin, wataru.gohda,
linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
linux-kernel, security, stable, Zheng Wang
In brcm80211 driver,it starts with the following invoking chain
to start init a timeout worker:
->brcmf_usb_probe
->brcmf_usb_probe_cb
->brcmf_attach
->brcmf_bus_started
->brcmf_cfg80211_attach
->wl_init_priv
->brcmf_init_escan
->INIT_WORK(&cfg->escan_timeout_work,
brcmf_cfg80211_escan_timeout_worker);
If we disconnect the USB by hotplug, it will call
brcmf_usb_disconnect to make cleanup. The invoking chain is :
brcmf_usb_disconnect
->brcmf_usb_disconnect_cb
->brcmf_detach
->brcmf_cfg80211_detach
->kfree(cfg);
While the timeout woker may still be running. This will cause
a use-after-free bug on cfg in brcmf_cfg80211_escan_timeout_worker.
Fix it by deleting the timer and canceling the worker in
brcmf_cfg80211_detach.
Fixes: e756af5b30b0 ("brcmfmac: add e-scan support.")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Cc: stable@vger.kernel.org
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 667462369a32..0224e377eb6e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -8431,6 +8431,9 @@ void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg)
if (!cfg)
return;
+ if (timer_pending(&cfg->escan_timeout))
+ del_timer_sync(&cfg->escan_timeout);
+ cancel_delayed_work_sync(&cfg->escan_timeout_work);
brcmf_pno_detach(cfg);
brcmf_btcoex_detach(cfg);
wiphy_unregister(cfg->wiphy);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] wifi: cfg80211: Fix use-after-free bug in brcmf_cfg80211_detach
2023-11-04 5:47 [PATCH] wifi: cfg80211: Fix use-after-free bug in brcmf_cfg80211_detach Zheng Wang
@ 2023-11-04 9:34 ` kernel test robot
2023-11-04 16:29 ` Johannes Berg
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2023-11-04 9:34 UTC (permalink / raw
To: Zheng Wang, aspriel
Cc: oe-kbuild-all, franky.lin, hante.meuleman, kvalo, johannes.berg,
marcan, linus.walleij, jisoo.jang, linuxlovemin, wataru.gohda,
linux-wireless, brcm80211-dev-list.pdl, SHA-cyfmac-dev-list,
linux-kernel, stable, Zheng Wang
Hi Zheng,
kernel test robot noticed the following build errors:
[auto build test ERROR on wireless-next/main]
[also build test ERROR on wireless/main linus/master v6.6 next-20231103]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Zheng-Wang/wifi-cfg80211-Fix-use-after-free-bug-in-brcmf_cfg80211_detach/20231104-135107
base: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link: https://lore.kernel.org/r/20231104054709.716585-1-zyytlz.wz%40163.com
patch subject: [PATCH] wifi: cfg80211: Fix use-after-free bug in brcmf_cfg80211_detach
config: arc-randconfig-002-20231104 (https://download.01.org/0day-ci/archive/20231104/202311041735.pCIzwiLF-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231104/202311041735.pCIzwiLF-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311041735.pCIzwiLF-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c: In function 'brcmf_cfg80211_detach':
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:8436:34: error: passing argument 1 of 'cancel_delayed_work_sync' from incompatible pointer type [-Werror=incompatible-pointer-types]
8436 | cancel_delayed_work_sync(&cfg->escan_timeout_work);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| |
| struct work_struct *
In file included from include/linux/mm_types.h:19,
from include/linux/mmzone.h:22,
from include/linux/gfp.h:7,
from include/linux/xarray.h:15,
from include/linux/list_lru.h:14,
from include/linux/fs.h:13,
from include/linux/highmem.h:5,
from include/linux/bvec.h:10,
from include/linux/skbuff.h:17,
from include/linux/if_ether.h:19,
from include/linux/etherdevice.h:20,
from drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:9:
include/linux/workqueue.h:511:59: note: expected 'struct delayed_work *' but argument is of type 'struct work_struct *'
511 | extern bool cancel_delayed_work_sync(struct delayed_work *dwork);
| ~~~~~~~~~~~~~~~~~~~~~^~~~~
cc1: some warnings being treated as errors
vim +/cancel_delayed_work_sync +8436 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
8428
8429 void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg)
8430 {
8431 if (!cfg)
8432 return;
8433
8434 if (timer_pending(&cfg->escan_timeout))
8435 del_timer_sync(&cfg->escan_timeout);
> 8436 cancel_delayed_work_sync(&cfg->escan_timeout_work);
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wifi: cfg80211: Fix use-after-free bug in brcmf_cfg80211_detach
2023-11-04 5:47 [PATCH] wifi: cfg80211: Fix use-after-free bug in brcmf_cfg80211_detach Zheng Wang
2023-11-04 9:34 ` kernel test robot
@ 2023-11-04 16:29 ` Johannes Berg
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2023-11-04 16:29 UTC (permalink / raw
To: Zheng Wang, aspriel
Cc: franky.lin, hante.meuleman, kvalo, marcan, linus.walleij,
jisoo.jang, linuxlovemin, wataru.gohda, linux-wireless,
brcm80211-dev-list.pdl, SHA-cyfmac-dev-list, linux-kernel,
security, stable
On Sat, 2023-11-04 at 13:47 +0800, Zheng Wang wrote:
>
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 3 +++
>
Nothing to do with cfg80211, please fix the subject.
johannes
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-04 16:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-04 5:47 [PATCH] wifi: cfg80211: Fix use-after-free bug in brcmf_cfg80211_detach Zheng Wang
2023-11-04 9:34 ` kernel test robot
2023-11-04 16:29 ` Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).