* [BUG] usb: gadget: KASAN slab-out-of-bounds in gether_get_ifname
@ 2026-09-21 8:49 CJ
2026-09-21 12:29 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: CJ @ 2026-09-21 8:49 UTC (permalink / raw)
To: balbi, gregkh; +Cc: linux-usb, linux-kernel
Hi,
I am reporting an issue triggered by a syzkaller reproducer on Linux
7.3.0-rc2. The issue is reproducible with HEAD commit
df2908090cda368b01ff43709f51890076c56157.
The reproducer mounts configfs, creates a USB gadget with a phonet function
(config/usb_gadget/g1/functions/phonet.usb0), and then reads the ifname
attribute of that function without ever binding the gadget to a UDC.
Reading ifname reaches f_phonet_ifname_show(), which calls
gether_get_ifname() to format the interface name. KASAN reports a 1-byte
out-of-bounds read in gether_get_ifname(); the reported object was allocated
by alloc_netdev_mqs() from gphonet_setup_default() when the phonet instance
was created. The read is performed by the syzkaller task in the read()
syscall, through configfs_read_iter().
This looks like the interface name being read before it has been
established. The net_device exists from instance creation, but its name is
only settled once the gadget is bound and the netdev is registered, and the
attribute is readable in between. Guarding the attribute on the function
being bound, or making gether_get_ifname() tolerate an unset name, would
cover it. I could not confirm from the report alone which byte of the name
buffer is the one read past the allocation.
This failure was reported earlier against the linux-6.1 longterm series at
https://syzkaller.appspot.com/bug?extid=07886e96db1f4cfc196d, and the
reproducer below is the one from that report. It still reproduces on the
tested mainline kernel.
Reproducer:
syz reproducer:
The reproducer is the program below, which requires no large encoded image:
mkdirat(0xffffffffffffff9c, &(0x7f0000000000)='./config\x00', 0x777)
mount(0x0, &(0x7f0000000000)='./config\x00', &(0x7f0000000080)='configfs\x00', 0x0, 0x0)
mkdirat(0xffffffffffffff9c, &(0x7f0000000100)='./config/usb_gadget/g1\x00', 0x777)
mkdirat(0xffffffffffffff9c, &(0x7f0000000140)='./config/usb_gadget/g1/functions/phonet.usb0\x00', 0x777)
r0 = openat(0xffffffffffffff9c, &(0x7f0000000180)='./config/usb_gadget/g1/functions/phonet.usb0/ifname\x00', 0x0, 0x0)
read(r0, 0x0, 0x0)
console output: https://pastebin.com/raw/vszZhUpg
kernel config: https://syzkaller.appspot.com/text?tag=KernelConfig&x=872c04466179833f
Kernel:
HEAD commit: df2908090cda368b01ff43709f51890076c56157
git tree: mainline
kernel version: 7.3.0-rc2
tested tag: v7.3-rc2 (annotated tag object 5e036ce12de91c6fd674dad33b169c6150be2a7a)
Let me know if you need more details or testing.
Best regards,
Changjian Liu
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [BUG] usb: gadget: KASAN slab-out-of-bounds in gether_get_ifname
2026-09-21 8:49 [BUG] usb: gadget: KASAN slab-out-of-bounds in gether_get_ifname CJ
@ 2026-09-21 12:29 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2026-09-21 12:29 UTC (permalink / raw)
To: CJ; +Cc: balbi, linux-usb, linux-kernel
On Mon, Sep 21, 2026 at 04:49:45PM +0800, CJ wrote:
>
> Hi,
>
>
> I am reporting an issue triggered by a syzkaller reproducer on Linux
> 7.3.0-rc2. The issue is reproducible with HEAD commit
> df2908090cda368b01ff43709f51890076c56157.
>
>
> The reproducer mounts configfs, creates a USB gadget with a phonet function
> (config/usb_gadget/g1/functions/phonet.usb0), and then reads the ifname
> attribute of that function without ever binding the gadget to a UDC.
Great, can you please send a patch to resolve this now that you have a
reproducer?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-21 12:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-21 8:49 [BUG] usb: gadget: KASAN slab-out-of-bounds in gether_get_ifname CJ
2026-09-21 12:29 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®