Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3182644pxy; Mon, 3 May 2021 17:48:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyE+otEK7tJqENqvwRLARpKtr/UzvTIFILVHAtV0AfsSKTm2f292JXI4EF9xafYfqdfA9eO X-Received: by 2002:aa7:d705:: with SMTP id t5mr22907416edq.141.1620089322989; Mon, 03 May 2021 17:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620089322; cv=none; d=google.com; s=arc-20160816; b=FRhBCjbzpoeEH2m+xzERXP1AXPnJrXciVIm2T9YcUd1npok+jQ7rshOwlDNh/L13Se yYdqTN5YcjK+iLcu3Cfvlb6he02Ct+90iF6NIMoasFci4nHSY/TYI0TbKYDzzeESY/Wb 5/iThP3e7b0g2pbuzEAUtMKa+Xy34QuOvv5NJeTN4DWqIywHPxTO+ZXWpegz362XALcV ZAOjkqyZFsZ8HI7TRBdCYUlIaiooiUS9moIC4LB4aCifzZqRkAq1VlvtB3SVTf5Y7I7O Zd8pRs/AMYN/oD0aQyAk32dPg8f8gDghS8aJdhTeHFDRBMZ/WJzXww10RKpJfXPqOjVD Jg8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=SHBXqojcrfLN11ajDNaLnR6xOVPNP+h70Eh/2pwsGvo=; b=ykfbvJ4Ry2+WBbCbtEgxPib2MkbU6eMn+7KcPex9nSFfavvSxqMGpMFpHO2ag3xII1 t8nkSQMu+Uyjqr5sEuAYlGCj2KdLJzUjC3Ewh4qLHOUKk/ZrVg/gg00nyg4j7FtI+ph+ UCnyG02rxfCuKuWcRVJVgI56MRbEjyCOcync1QdwPdrIpFhv8RiAJTrbAFMPZ6NFQhCW klRJZWykvaujLmkdrRUojRwjy9Ezi+3BEleh03jnQrofBAmo7cufAcBlGmgb+UTRnskX aX1lHyGNoCRSKFG0hv6NJgWZFdW10cRe3yz6dlh+qWIoqjDt5xgXiIu9sxL8B8W9wOoO MvnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k15si1231806ejj.682.2021.05.03.17.48.18; Mon, 03 May 2021 17:48:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbhEDAr4 (ORCPT + 99 others); Mon, 3 May 2021 20:47:56 -0400 Received: from netrider.rowland.org ([192.131.102.5]:44489 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S229499AbhEDArz (ORCPT ); Mon, 3 May 2021 20:47:55 -0400 Received: (qmail 638919 invoked by uid 1000); 3 May 2021 20:47:00 -0400 Date: Mon, 3 May 2021 20:47:00 -0400 From: Alan Stern To: Andrew Morton Cc: syzbot , linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com, Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: Re: [syzbot] WARNING in do_proc_bulk Message-ID: <20210504004700.GA638732@rowland.harvard.edu> References: <000000000000b47bc805c15e4b11@google.com> <00000000000000186405c16a6156@google.com> <20210503105351.0966275d0d9e001ed794de2c@linux-foundation.org> <20210503185614.GA628313@rowland.harvard.edu> <20210503122428.30ebfddbaf8f5184dc73e1a7@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210503122428.30ebfddbaf8f5184dc73e1a7@linux-foundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 03, 2021 at 12:24:28PM -0700, Andrew Morton wrote: > On Mon, 3 May 2021 14:56:14 -0400 Alan Stern wrote: > > > > > > > do_proc_bulk() is asking kmalloc for more than MAX_ORDER bytes, in > > > > > > tbuf = kmalloc(len1, GFP_KERNEL); > > > > This doesn't seem to be a bug. do_proc_bulk is simply trying to > > allocate a kernel buffer for data passed to/from userspace. If a user > > wants too much space all at once, that's their problem. > > > > As far as I know, the kmalloc API doesn't require the caller to filter > > out requests for more the MAX_ORDER bytes. Only to be prepared to > > handle failures -- which do_proc_bulk is all set for. > > > > Am I wrong about this? Should we add __GFP_NOWARN to the gfp flags? > > Yes, if the oversized request is a can-happen and the resulting error is handled > appropriately, __GFP_NOWARN is the way to go. Okay, let's see how this does. Alan Stern #syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git d2b6f8a1 Index: usb-devel/drivers/usb/core/devio.c =================================================================== --- usb-devel.orig/drivers/usb/core/devio.c +++ usb-devel/drivers/usb/core/devio.c @@ -1218,7 +1218,12 @@ static int do_proc_bulk(struct usb_dev_s ret = usbfs_increase_memory_usage(len1 + sizeof(struct urb)); if (ret) return ret; - tbuf = kmalloc(len1, GFP_KERNEL); + + /* + * len1 can be almost arbitrarily large. Don't WARN if it's + * too big, just fail the request. + */ + tbuf = kmalloc(len1, GFP_KERNEL | __GFP_NOWARN); if (!tbuf) { ret = -ENOMEM; goto done;