Re: [syzbot] Re: [syzbot] [wireless?] [usb?] KASAN: use-after-free Read in rtw_load_firmware_cb

From: syzbot
Date: Thu Jul 25 2024 - 23:10:16 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.

***

Subject: Re: [syzbot] [wireless?] [usb?] KASAN: use-after-free Read in rtw_load_firmware_cb
Author: lizhi.xu@xxxxxxxxxxxxx

if firmware doesn't exist, don't run cb

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 933069701c1b

diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index da8ca01d011c..ce2e996be3d9 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -1159,12 +1159,14 @@ static void request_firmware_work_func(struct work_struct *work)
{
struct firmware_work *fw_work;
const struct firmware *fw;
+ int ret;

fw_work = container_of(work, struct firmware_work, work);

- _request_firmware(&fw, fw_work->name, fw_work->device, NULL, 0, 0,
+ ret = _request_firmware(&fw, fw_work->name, fw_work->device, NULL, 0, 0,
fw_work->opt_flags);
- fw_work->cont(fw, fw_work->context);
+ if (ret != -ENOENT)
+ fw_work->cont(fw, fw_work->context);
put_device(fw_work->device); /* taken in request_firmware_nowait() */

module_put(fw_work->module);