mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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: Wed, 14 Dec 2016 10:10:06 +0100	[thread overview]
Message-ID: <20161214091005.GD25573@dhcp22.suse.cz> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1612130826230.31292-100000@netrider.rowland.org>

On Tue 13-12-16 08:33:34, Alan Stern wrote:
> On Tue, 13 Dec 2016, Michal Hocko wrote:
> 
> > > > 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?
> 
> We could (although one page is really too small -- USB 3.1 can transfer
> 800 KB per ms so we ought to handle at least 128 KB at a time).

Is there any problem to submit larger transfers without having the
buffer physically contiguous?

> But
> turn the argument around: If the user wants to transfer that much data,
> why can't he _submit_ it one page at a time?

Not sure I understand.
 
> > > 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.
> 
> Putting a limit on the total size of a single transfer would prevent 
> this.

Dunno, putting a limit to the user visible interface sounds wrong to me.
-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2016-12-14  9:10 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
2016-12-13 13:33         ` Alan Stern
2016-12-14  9:10           ` Michal Hocko [this message]
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=20161214091005.GD25573@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®