From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Andrey Konovalov <andreyknvl@google.com>
Cc: Felipe Balbi <balbi@kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Al Viro <viro@zeniv.linux.org.uk>,
David Eccher <d.eccher@gmail.com>, Arnd Bergmann <arnd@arndb.de>,
Binyamin Sharet <s.binyamin@gmail.com>, Bin Liu <b-liu@ti.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
linux-usb@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
Dmitry Vyukov <dvyukov@google.com>,
Kostya Serebryany <kcc@google.com>,
syzkaller <syzkaller@googlegroups.com>
Subject: Re: usb/gadget: warning in dev_config/memdup_user
Date: Fri, 2 Dec 2016 16:56:15 +0100 [thread overview]
Message-ID: <20161202155615.GB32414@kroah.com> (raw)
In-Reply-To: <CAAeHK+xi0dzmOE7=zQTHMCdPH3n4NvVr0uyRW9jEPxbO9kwPpA@mail.gmail.com>
On Fri, Dec 02, 2016 at 04:07:38PM +0100, Andrey Konovalov wrote:
> Hi!
>
> I've got the following error report while running the syzkaller fuzzer.
>
> The length passed to memdup_user() directly without limitations.
>
> On commit 2caceb3294a78c389b462e7e236a4e744a53a474 (Dec 1).
>
> WARNING: CPU: 3 PID: 14477 at mm/page_alloc.c:3511
> __alloc_pages_nodemask+0x159c/0x1e20
> Kernel panic - not syncing: panic_on_warn set ...
>
> CPU: 3 PID: 14477 Comm: syz-executor0 Not tainted 4.9.0-rc7+ #61
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> ffff880039b67298 ffffffff81f96bba ffffffff00000200 1ffff1000736cde6
> ffffed000736cdde 0000000000000a06 0000000041b58ab3 ffffffff8598af00
> ffffffff81f96928 0000000041b58ab3 ffffffff859423c8 ffffffff81432790
> Call Trace:
> [< inline >] __dump_stack lib/dump_stack.c:15
> [<ffffffff81f96bba>] dump_stack+0x292/0x398 lib/dump_stack.c:51
> [<ffffffff8168c7ae>] panic+0x1cb/0x3a9 kernel/panic.c:179
> [<ffffffff812b80b4>] __warn+0x1c4/0x1e0 kernel/panic.c:542
> [<ffffffff812b831c>] warn_slowpath_null+0x2c/0x40 kernel/panic.c:585
> [< inline >] __alloc_pages_slowpath mm/page_alloc.c:3511
> [<ffffffff816c07cc>] __alloc_pages_nodemask+0x159c/0x1e20 mm/page_alloc.c:3781
> [<ffffffff817cdd27>] alloc_pages_current+0x1c7/0x6b0 mm/mempolicy.c:2072
> [< inline >] alloc_pages include/linux/gfp.h:469
> [<ffffffff8172fcdf>] kmalloc_order+0x1f/0x70 mm/slab_common.c:1015
> [<ffffffff8172fd4f>] kmalloc_order_trace+0x1f/0x160 mm/slab_common.c:1026
> [< inline >] kmalloc_large include/linux/slab.h:422
> [<ffffffff817e348f>] __kmalloc_track_caller+0x1df/0x290 mm/slub.c:4233
> [<ffffffff8171bb3c>] memdup_user+0x2c/0xa0 mm/util.c:137
> [<ffffffff83228ca2>] dev_config+0x2e2/0x1180
> drivers/usb/gadget/legacy/inode.c:1776
> [<ffffffff817fde55>] __vfs_write+0x5d5/0x760 fs/read_write.c:510
> [<ffffffff817ff750>] vfs_write+0x170/0x4e0 fs/read_write.c:560
> [< inline >] SYSC_write fs/read_write.c:607
> [<ffffffff81803b5b>] SyS_write+0xfb/0x230 fs/read_write.c:599
> [<ffffffff84f44cc1>] entry_SYSCALL_64_fastpath+0x1f/0xc2
> Dumping ftrace buffer:
> (ftrace buffer empty)
> Kernel Offset: disabled
Oh how nice, we check to ensure that the buffer is not too small, but no
one checks if it is too big :(
Felipe, would a patch like the one below solve this? If so, I'll resend
it in a "proper" format...
thanks,
greg k-h
---------------------
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index bd82dd12deff..42f9003b1621 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1765,6 +1765,10 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4))
return -EINVAL;
+ /* No one needs more than 64k... */
+ if (len > PAGE_SIZE * 8)
+ return -EINVAL;
+
/* we might need to change message format someday */
if (copy_from_user (&tag, buf, 4))
return -EFAULT;
next prev parent reply other threads:[~2016-12-02 15:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-02 15:07 Andrey Konovalov
2016-12-02 15:56 ` Greg Kroah-Hartman [this message]
2016-12-02 16:04 ` Greg Kroah-Hartman
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=20161202155615.GB32414@kroah.com \
--to=gregkh@linuxfoundation.org \
--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=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=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
all inboxes | Powered by JetHome®