From: Alan Stern <stern@rowland.harvard.edu>
To: Andrey Konovalov <andreyknvl@google.com>
Cc: Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Arnd Bergmann <arnd@arndb.de>, Michal Hocko <mhocko@suse.com>,
David Eccher <d.eccher@gmail.com>,
Binyamin Sharet <s.binyamin@gmail.com>, Bin Liu <b-liu@ti.com>,
Mathieu Laurendeau <mat.lau@laposte.net>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
<linux-usb@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Kostya Serebryany <kcc@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
syzkaller <syzkaller@googlegroups.com>
Subject: Re: usb/gadget: use-after-free in gadgetfs_setup
Date: Mon, 5 Dec 2016 14:31:57 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.44L0.1612051429480.1928-100000@iolanthe.rowland.org> (raw)
In-Reply-To: <CAAeHK+wMwJ+ZH1ysdekFwZ00jN5ES8Grm_rxr223AEWwrg2JBg@mail.gmail.com>
On Mon, 5 Dec 2016, Andrey Konovalov wrote:
> Hi!
>
> I've got the following error report while running the syzkaller fuzzer.
>
> On commit 3c49de52d5647cda8b42c4255cf8a29d1e22eff5 (Dec 2).
>
> BUG: KASAN: use-after-free in gadgetfs_setup+0x208a/0x20e0 at addr
> ffff88003dfe5bf2
> Read of size 2 by task syz-executor0/22994
> CPU: 3 PID: 22994 Comm: syz-executor0 Not tainted 4.9.0-rc7+ #16
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> ffff88006df06a18 ffffffff81f96aba ffffffffe0528500 1ffff1000dbe0cd6
> ffffed000dbe0cce ffff88006df068f0 0000000041b58ab3 ffffffff8598b4c8
> ffffffff81f96828 1ffff1000dbe0ccd ffff88006df06708 ffff88006df06748
> Call Trace:
> <IRQ> [ 201.343209] [< inline >] __dump_stack lib/dump_stack.c:15
> <IRQ> [ 201.343209] [<ffffffff81f96aba>] dump_stack+0x292/0x398
> lib/dump_stack.c:51
> [<ffffffff817e4dec>] kasan_object_err+0x1c/0x70 mm/kasan/report.c:159
> [< inline >] print_address_description mm/kasan/report.c:197
> [<ffffffff817e5080>] kasan_report_error+0x1f0/0x4e0 mm/kasan/report.c:286
> [< inline >] kasan_report mm/kasan/report.c:306
> [<ffffffff817e562a>] __asan_report_load_n_noabort+0x3a/0x40
> mm/kasan/report.c:337
> [< inline >] config_buf drivers/usb/gadget/legacy/inode.c:1298
> [<ffffffff8322c8fa>] gadgetfs_setup+0x208a/0x20e0
> drivers/usb/gadget/legacy/inode.c:1368
> [<ffffffff830fdcd0>] dummy_timer+0x11f0/0x36d0
> drivers/usb/gadget/udc/dummy_hcd.c:1858
> [<ffffffff814807c1>] call_timer_fn+0x241/0x800 kernel/time/timer.c:1308
> [< inline >] expire_timers kernel/time/timer.c:1348
> [<ffffffff81482de6>] __run_timers+0xa06/0xec0 kernel/time/timer.c:1641
> [<ffffffff814832c1>] run_timer_softirq+0x21/0x80 kernel/time/timer.c:1654
> [<ffffffff84f4af8b>] __do_softirq+0x2fb/0xb63 kernel/softirq.c:284
> [< inline >] invoke_softirq kernel/softirq.c:364
> [<ffffffff812d3b8e>] irq_exit+0x19e/0x1d0 kernel/softirq.c:405
> [< inline >] exiting_irq arch/x86/include/asm/apic.h:659
> [<ffffffff84f4a59b>] smp_apic_timer_interrupt+0x7b/0xa0
> arch/x86/kernel/apic/apic.c:960
> [<ffffffff84f4964c>] apic_timer_interrupt+0x8c/0xa0
> arch/x86/entry/entry_64.S:489
> <EOI> [ 201.343209] [<ffffffff84f472f9>] ?
> _raw_spin_unlock_irqrestore+0x119/0x1a0
> [<ffffffff8136f9e4>] try_to_wake_up+0x174/0x1160 kernel/sched/core.c:2099
> [< inline >] wake_up_process kernel/sched/core.c:2165
> [<ffffffff81370a7a>] wake_up_q+0x8a/0xe0 kernel/sched/core.c:469
> [<ffffffff814cc6de>] futex_wake+0x5be/0x6c0 kernel/futex.c:1453
> [<ffffffff814d41dd>] do_futex+0x11bd/0x1f00 kernel/futex.c:3219
> [< inline >] SYSC_futex kernel/futex.c:3275
> [<ffffffff814d521c>] SyS_futex+0x2fc/0x400 kernel/futex.c:3243
> [<ffffffff84f47ec1>] entry_SYSCALL_64_fastpath+0x1f/0xc2
Can you test whether the patch below fixes this problem?
Alan Stern
Index: usb-4.x/drivers/usb/gadget/legacy/inode.c
===================================================================
--- usb-4.x.orig/drivers/usb/gadget/legacy/inode.c
+++ usb-4.x/drivers/usb/gadget/legacy/inode.c
@@ -1762,6 +1762,10 @@ dev_config (struct file *fd, const char
}
spin_unlock_irq(&dev->lock);
+ /* Registered but not yet bound to a UDC driver? */
+ if (dev->gadget_registered)
+ return -EIO;
+
if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4))
return -EINVAL;
next prev parent reply other threads:[~2016-12-05 19:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-05 13:03 usb/gadget: use-after-free in gadgetfs_setup Andrey Konovalov
2016-12-05 19:31 ` Alan Stern [this message]
2016-12-06 12:28 ` Andrey Konovalov
2016-12-06 16:02 ` Andrey Konovalov
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=Pine.LNX.4.44L0.1612051429480.1928-100000@iolanthe.rowland.org \
--to=stern@rowland.harvard.edu \
--cc=andreyknvl@google.com \
--cc=arnd@arndb.de \
--cc=b-liu@ti.com \
--cc=balbi@kernel.org \
--cc=d.eccher@gmail.com \
--cc=dvyukov@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=kcc@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mat.lau@laposte.net \
--cc=mhocko@suse.com \
--cc=s.binyamin@gmail.com \
--cc=syzkaller@googlegroups.com \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).