Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752806AbcDKHQY (ORCPT ); Mon, 11 Apr 2016 03:16:24 -0400 Received: from mailgw01.mediatek.com ([218.249.47.110]:58718 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752250AbcDKHQX (ORCPT ); Mon, 11 Apr 2016 03:16:23 -0400 Message-ID: <1460358968.10419.26.camel@mhfsdcap03> Subject: Re: [PATCH] usb: core: buffer: avoid NULL pointer dereferrence From: chunfeng yun To: Felipe Balbi CC: Greg Kroah-Hartman , , , , Date: Mon, 11 Apr 2016 15:16:08 +0800 In-Reply-To: <87shyspwbz.fsf@intel.com> References: <1460106483-24793-1-git-send-email-chunfeng.yun@mediatek.com> <20160408140701.GA3547@kroah.com> <1460343705.10419.12.camel@mhfsdcap03> <87shyspwbz.fsf@intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1163 Lines: 30 On Mon, 2016-04-11 at 08:07 +0300, Felipe Balbi wrote: > Hi, > > chunfeng yun writes: > > On Fri, 2016-04-08 at 07:07 -0700, Greg Kroah-Hartman wrote: > >> On Fri, Apr 08, 2016 at 05:08:03PM +0800, Chunfeng Yun wrote: > >> > NULL pointer dereferrence will happen when class driver > >> > wants to allocate zero length buffer and pool_max[0] > >> > can't be used, so skip reserved pool in this case. > >> > >> Why would a driver want to allocate a 0 length buffer? What driver does > >> this? > > It's misc/usbtest.c > > that'll do what you ask it to do with the userspace tool testusb. Are > you trying to pass a size of 0 ? > No, I just ran "testusb -t10" which called test_ctrl_queue(). In this function, sub-case 8 passed a parameter @len as 0 to simple_alloc_urb(), and then it tried to allocate a 0-length buffer. > >> Shouldn't we fix that issue instead? > > I don't know which way is better, but it seems simple to fix it up in > > buffer.c > > I think we should, really, avoid a 0-length allocation, but passing a > size of 0 to testusb isn't very good either ;-) How are you calling > testusb ? > As explained above.