From: Yuhong Cheng <ceohunk@gmail.com>
To: castet.matthieu@free.fr, stf_xl@wp.pl
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Yuhong Cheng <ceohunk@gmail.com>,
syzbot+123456@syzkaller.appspotmail.com
Subject: [PATCH] usb: atm: ueagle-atm: fix use-after-free in uea_upload_pre_firmware
Date: Sat, 11 Jul 2026 22:42:59 +0800 [thread overview]
Message-ID: <20260711144259.1124-1-ceohunk@gmail.com> (raw)
syzbot reported a slab-use-after-free read in uea_upload_pre_firmware. This is because the usb_device is passed as context to request_firmware_nowait but its reference count is not incremented. Thus, if the USB device is disconnected before the firmware load completes, the callback accesses a freed usb_device.
Fix this by taking a reference with usb_get_dev() before calling request_firmware_nowait() and releasing it with usb_put_dev() in the completion callback or if the request fails to start.
Reported-by: syzbot+123456@syzkaller.appspotmail.com
---
drivers/usb/atm/ueagle-atm.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index d610cdcef..eaf2f2d3a 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -663,6 +663,7 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry,
uea_err(usb, "firmware is corrupted\n");
err:
release_firmware(fw_entry);
+ usb_put_dev(usb);
}
/*
@@ -693,13 +694,16 @@ static int uea_load_firmware(struct usb_device *usb, unsigned int ver)
break;
}
+ usb_get_dev(usb);
ret = request_firmware_nowait(THIS_MODULE, 1, fw_name, &usb->dev,
GFP_KERNEL, usb,
uea_upload_pre_firmware);
- if (ret)
+ if (ret) {
uea_err(usb, "firmware %s is not available\n", fw_name);
- else
+ usb_put_dev(usb);
+ } else {
uea_info(usb, "loading firmware %s\n", fw_name);
+ }
return ret;
}
--
2.46.0.windows.1
next reply other threads:[~2026-07-11 14:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 14:42 Yuhong Cheng [this message]
2026-07-11 15:17 ` [PATCH] usb: atm: ueagle-atm: fix use-after-free in uea_upload_pre_firmware Stanislaw Gruszka
-- strict thread matches above, loose matches on Subject: below --
2026-06-29 21:09 [syzbot] [usb?] KASAN: slab-use-after-free Read " syzbot
2026-07-11 14:49 ` [PATCH] usb: atm: ueagle-atm: fix use-after-free " Yuhong Cheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260711144259.1124-1-ceohunk@gmail.com \
--to=ceohunk@gmail.com \
--cc=castet.matthieu@free.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stf_xl@wp.pl \
--cc=syzbot+123456@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox