From: Stanislaw Gruszka <stf_xl@wp.pl>
To: Yuhong Cheng <ceohunk@gmail.com>
Cc: castet.matthieu@free.fr, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+123456@syzkaller.appspotmail.com
Subject: Re: [PATCH] usb: atm: ueagle-atm: fix use-after-free in uea_upload_pre_firmware
Date: Sat, 11 Jul 2026 17:17:44 +0200 [thread overview]
Message-ID: <20260711151744.GA8759@wp.pl> (raw)
In-Reply-To: <20260711144259.1124-1-ceohunk@gmail.com>
Hi,
On Sat, Jul 11, 2026 at 10:42:59PM +0800, Yuhong Cheng wrote:
> 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.
I think this not true, please see:
https://lore.kernel.org/linux-usb/20260702093707.GA6804@wp.pl/
Regards
Stanislaw
> 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 prev parent reply other threads:[~2026-07-11 15:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 14:42 [PATCH] usb: atm: ueagle-atm: fix use-after-free in uea_upload_pre_firmware Yuhong Cheng
2026-07-11 15:17 ` Stanislaw Gruszka [this message]
-- 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=20260711151744.GA8759@wp.pl \
--to=stf_xl@wp.pl \
--cc=castet.matthieu@free.fr \
--cc=ceohunk@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--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