From: Michal Pecio <michal.pecio@gmail.com>
To: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
Cc: sanan.hasanou@gmail.com, vbabka@suse.cz,
akpm@linux-foundation.org, cl@gentwo.org, rientjes@google.com,
roman.gushchin@linux.dev, harry.yoo@oracle.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
syzkaller@googlegroups.com, contact@pgazz.com,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, Dinghao Liu <dinghao.liu@zju.edu.cn>
Subject: Re: WARNING in usb_free_urb
Date: Mon, 29 Jun 2026 09:20:33 +0200 [thread overview]
Message-ID: <20260629092033.4a83e91b.michal.pecio@gmail.com> (raw)
In-Reply-To: <85cf5045-b52b-4aaa-a038-ca1b856b55f9@kernel.org>
On Mon, 29 Jun 2026 08:27:48 +0200, Vlastimil Babka (SUSE) wrote:
> On 6/26/26 23:27, sanan.hasanou@gmail.com wrote:
> > Good day, dear maintainers,
> >
> > We found a bug using a modified version of syzkaller.
>
> Subject says "usb_free_urb" but you only CC'd slab maintainers, where slab
> slab is most likely a victim here of e.g. double kfree() or a kfree() of
> otherwise broken pointer.
>
> Ccing USB and EM28XX maintainers. But they can feel free to ignore this per
> the next point.
>
> > Kernel Branch: 7.0-rc1
>
> Why use such a version for fuzzing? rc1 will have many bugs that are
> already fixed in 7.0 final. And it's not even latest, 7.1 was
> released 2 weeks ago too.
To be fair, em28xx had no changes since 2024 until 7.1-rc1, so the bug
must be present in various stable releases and likely in mainline too.
> > WARNING: mm/slub.c:6352 at free_large_kmalloc+0xb3/0x160 mm/slub.c:6352, CPU#1: kworker/1:4/12317
>
> A kfree() was attempted on a pointer that's neither from a slab page nor a
> large kmalloc page. Might be double free or corrupted.
>
> > Call Trace:
> > <TASK>
> > kfree+0xae/0x630 mm/slub.c:6437
> > urb_destroy drivers/usb/core/urb.c:25 [inline]
>
> static void urb_destroy(struct kref *kref)
> {
> struct urb *urb = to_urb(kref);
>
> if (urb->transfer_flags & URB_FREE_BUFFER)
> kfree(urb->transfer_buffer); <--- this one
>
> kfree(urb);
> }
>
> > kref_put include/linux/kref.h:65 [inline]
> > usb_free_urb+0xd1/0x120 drivers/usb/core/urb.c:96
>
> USB layer itself is likely also not the root cause.
>
> > em28xx_uninit_usb_xfer+0x165/0x310 drivers/media/usb/em28xx/em28xx-core.c:833
> > em28xx_alloc_urbs+0xf2a/0x1130 drivers/media/usb/em28xx/em28xx-core.c:-1
> > em28xx_dvb_init+0x2b0/0x4a20 drivers/media/usb/em28xx/em28xx-dvb.c:-1
> > em28xx_init_extension+0x121/0x1d0 drivers/media/usb/em28xx/em28xx-core.c:1117
>
> So it might be this driver doing something wrong?
Yes, it is.
/* allocate urbs and transfer buffers */
for (i = 0; i < usb_bufs->num_bufs; i++) {
urb = usb_alloc_urb(usb_bufs->num_packets, GFP_KERNEL);
if (!urb) {
em28xx_uninit_usb_xfer(dev, mode);
return -ENOMEM;
}
usb_bufs->urb[i] = urb;
usb_bufs->buf[i] = kzalloc(sb_size, GFP_KERNEL);
if (!usb_bufs->buf[i]) {
for (i--; i >= 0; i--)
kfree(usb_bufs->buf[i]);
em28xx_uninit_usb_xfer(dev, mode);
return -ENOMEM;
}
urb->transfer_flags = URB_FREE_BUFFER;
If buf[i] allocation fails, all previous buffers are freed and then all
previous URBs are destroyed. But they already have the URB_FREE_BUFFER
flag set, which causes a double free as shown above.
The free(buf[i]) loop should simply be removed. It was mistakenly added
by d571b592c6206, then a26efd1961a18 recognized the double free but
attempted to fix it only by changing the order of freeing. Sent from
.edu domain, so probably an automatic static analyzer fix...
Regards,
Michal
next prev parent reply other threads:[~2026-06-29 7:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 21:27 WARNING in usb_free_urb sanan.hasanou
2026-06-29 6:27 ` Vlastimil Babka (SUSE)
2026-06-29 7:20 ` Michal Pecio [this message]
2026-06-29 7:28 ` Michal Pecio
2026-06-29 7:31 ` Vlastimil Babka (SUSE)
2026-06-29 7:40 ` Hans Verkuil
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=20260629092033.4a83e91b.michal.pecio@gmail.com \
--to=michal.pecio@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=contact@pgazz.com \
--cc=dinghao.liu@zju.edu.cn \
--cc=gregkh@linuxfoundation.org \
--cc=harry.yoo@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-usb@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=sanan.hasanou@gmail.com \
--cc=syzkaller@googlegroups.com \
--cc=vbabka@kernel.org \
--cc=vbabka@suse.cz \
/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