Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755214AbcLNJKM (ORCPT ); Wed, 14 Dec 2016 04:10:12 -0500 Received: from mail-wj0-f196.google.com ([209.85.210.196]:34908 "EHLO mail-wj0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755010AbcLNJKJ (ORCPT ); Wed, 14 Dec 2016 04:10:09 -0500 Date: Wed, 14 Dec 2016 10:10:06 +0100 From: Michal Hocko To: Alan Stern Cc: Andrey Konovalov , Felipe Balbi , Greg Kroah-Hartman , Al Viro , Marek Szyprowski , Deepa Dinamani , Mathieu Laurendeau , Bin Liu , USB list , LKML , syzkaller , Dmitry Vyukov , Kostya Serebryany , Cristopher Lameter Subject: Re: usb/gadget: warning in ep_write_iter/__alloc_pages_nodemask Message-ID: <20161214091005.GD25573@dhcp22.suse.cz> References: <20161213080426.GA10492@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1723 Lines: 43 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