From: Michal Hocko <mhocko@kernel.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Andrey Konovalov <andreyknvl@google.com>,
Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Deepa Dinamani <deepa.kernel@gmail.com>,
Mathieu Laurendeau <mat.lau@laposte.net>, Bin Liu <b-liu@ti.com>,
USB list <linux-usb@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
syzkaller <syzkaller@googlegroups.com>,
Dmitry Vyukov <dvyukov@google.com>,
Kostya Serebryany <kcc@google.com>,
Cristopher Lameter <cl@linux.com>
Subject: Re: usb/gadget: warning in ep_write_iter/__alloc_pages_nodemask
Date: Tue, 13 Dec 2016 09:04:26 +0100 [thread overview]
Message-ID: <20161213080426.GA10492@dhcp22.suse.cz> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1612121608270.1502-100000@iolanthe.rowland.org>
On Mon 12-12-16 16:12:16, Alan Stern wrote:
> On Mon, 12 Dec 2016, Michal Hocko wrote:
>
> > On Mon 12-12-16 21:32:35, Andrey Konovalov wrote:
> > > On Mon, Dec 12, 2016 at 9:31 PM, Andrey Konovalov <andreyknvl@google.com> wrote:
> > > > Hi!
> > > >
> > > > While running the syzkaller fuzzer I've got the following error report.
> > > >
> > > > The issue is that the len argument is not checked for being too big.
> >
> > Well, the value is checked in kmalloc_slab. There is a discrepancy
> > though. While the page allocator enforces order < MAX_ORDER, slab
> > allocators enforce size <= KMALLOC_MAX_SIZE and
> >
> > KMALLOC_MAX_SIZE is 1UL << (MAX_ORDER + PAGE_SHIFT) for SLUB which is
> > what I expect you have or 1UL << (MAX_ORDER + PAGE_SHIFT - 1) for SLAB
> > on most archs. This means that KMALLOC_MAX_SIZE might be MAX_ORDER for
> > SLUB which would explain your warning.
> >
> > Let's CC Christoph, this is nothing really new, but I suspect that SLUB
> > should change the maximum size to something like SLAB does.
> >
> > That being said, what ep_write_iter does sounds quite stupit. It just
> > allocates a large continuous buffer which seems to be under user
> > control... Aka no good! It should do that per pages or something like
> > that. Something worth fixing
>
> It's not important enough to make the driver do all this work. If
> users want to send large amounts of data, they can send it a page at a
> time (or something like that).
Is it really necessary to allocate the full iov_iter_count? Why cannot
we process the from buffer one page at a time?
> If you really want to prevent the driver from attempting to allocate a
> large buffer, all that's needed is an upper limit on the total size.
> For example, 64 KB.
Well, my point was that it is not really hard to imagine to deplete
larger contiguous memory blocks (say PAGE_ALLOC_COSTLY_ORDER). Those are
still causing the OOM killer and chances are that a controlled flood of
these requests could completely DoS the system.
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2016-12-13 8:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-12 20:31 Andrey Konovalov
2016-12-12 20:32 ` Andrey Konovalov
2016-12-12 21:00 ` Alan Stern
2016-12-12 21:05 ` Michal Hocko
2016-12-12 21:12 ` Alan Stern
2016-12-13 8:04 ` Michal Hocko [this message]
2016-12-13 13:33 ` Alan Stern
2016-12-14 9:10 ` Michal Hocko
2016-12-14 16:13 ` Alan Stern
2016-12-14 16:18 ` Michal Hocko
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=20161213080426.GA10492@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=andreyknvl@google.com \
--cc=b-liu@ti.com \
--cc=balbi@kernel.org \
--cc=cl@linux.com \
--cc=deepa.kernel@gmail.com \
--cc=dvyukov@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=kcc@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mat.lau@laposte.net \
--cc=stern@rowland.harvard.edu \
--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®