Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2297649rwn; Fri, 9 Sep 2022 11:19:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR5XYDhhsJt46qm44qiarOSvEgYmDPRDCnjWTIIOt6KRFJtbBRM1j4Q28sUSNN37SacMHHVR X-Received: by 2002:a17:903:2450:b0:177:f32b:19fd with SMTP id l16-20020a170903245000b00177f32b19fdmr9451852pls.100.1662747594675; Fri, 09 Sep 2022 11:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662747594; cv=none; d=google.com; s=arc-20160816; b=Uq4rFekOvHffXaSu5y4dPhFo66ZntjTneO3578oi4z1yaJZPSx196I/NyaZaeoZbYC yYK50u90vJUkQ3F2MoDuiw2ou/+Bw34fISezgi8dOAkr1edozk0nBr+hknFvnS8Ds0LW w6R9iETIgN9oJz7UK62W0PLMvEvY0+6OUKclWoWRqucBFns4s1+y3iIOPSJHCk0Dy+zx /IVDyb3Chs6GewCk8CsZaASYqRW8kkmRthEsYmgu6JVRkiD2Dr8+qUAEWWEmOhsTILrc Au46JLmbavpygwkGUsg0xCFDYaezRRV7L7nTDc6A3yx4+5exs2ANdReHxRA1tNpSCj5j zqPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fGBjvKCzrV+bIJMOIVW5T0aryOY/nU2F5zo2RuD1Ua8=; b=md9RD4J11Q0c0eYNJSAPy6qVXgfa0egmh6jwvNiHgC4o5pjwUpL1eMNqDGUbsuF3nj fpCUaAvSI+pj8UO5jTuwEvs+0RyAMjY71WKChRxFegRQeiK44BMgK3e6ZWWsh3DyfL3j ckeOuh+bU+LhgKHf9R+6/uYxLu6WxTLJQFnem0YMimE12ydW5W60QSsTpeua5QoZiir6 PJspGG3WNBzxAJ0lWwbih2QBvJ86EApIj40UPunAvJ7ObaEaJ2FG4NHm2rGPl+bbOTP6 j09fyeFaS1uyOS8tUY4lA8gTlgoXGaMlMdxeGfJQYJGy59rOwcpqDobS23NvpbF2CgcF fx+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HtlSBokx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x8-20020a170902b40800b00175284c8e9dsi1162605plr.199.2022.09.09.11.19.40; Fri, 09 Sep 2022 11:19:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HtlSBokx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbiIISHw (ORCPT + 99 others); Fri, 9 Sep 2022 14:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231454AbiIISHt (ORCPT ); Fri, 9 Sep 2022 14:07:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60FE5E3D66; Fri, 9 Sep 2022 11:07:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C8565620AA; Fri, 9 Sep 2022 18:07:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D65F3C433D6; Fri, 9 Sep 2022 18:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662746866; bh=+u+FJQpP4ebPfFxqZGhMD/vKMxEpCxpDdfM0kbOkIaU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HtlSBokxiXQaXlqPfFUFfyBM2kMuS3cEWySA/IUN7UtFANjU+1sK8WuznVyc+gWtM MfC5/vBfoOr6IGVmnKwbhY2y73V1GOR/vBhNkjtfoBir0nma+i81m510PuwdVFyzEa 2r6cEeXLyeCaRmi0/kXjDbtyouQBrFurbvThVTCo= Date: Fri, 9 Sep 2022 20:07:43 +0200 From: "gregkh@linuxfoundation.org" To: Jim Lin Cc: "s.shtylyov@omp.ru" , "linux-kernel@vger.kernel.org" , Aniruddha Tvs Rao , "balbi@kernel.org" , "linux-usb@vger.kernel.org" Subject: Re: [PATCH] usb: gadget: rndis: Avoid dereference before NULL check Message-ID: References: <20220908175615.5095-1-jilin@nvidia.com> <4242e47a94bf7ffe989ca2c6ed48e862ce3b3013.camel@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4242e47a94bf7ffe989ca2c6ed48e862ce3b3013.camel@nvidia.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 09, 2022 at 02:43:14PM +0000, Jim Lin wrote: > On Fri, 2022-09-09 at 07:38 +0200, Greg KH wrote: > > External email: Use caution opening links or attachments > > > > > > On Fri, Sep 09, 2022 at 01:56:15AM +0800, Jim Lin wrote: > > > NULL check is performed after params->dev is dereferenced in > > > dev_get_stats. > > > > I do not understand this statement. > > > > > Fixed by adding a NULL check before dereferencing params->dev and > > > removing subsequent NULL checks for it. > > > > > > Signed-off-by: Aniruddha TVS Rao > > > Signed-off-by: Jim Lin > > > --- > > > drivers/usb/gadget/function/rndis.c | 37 ++++++++++++------------- > > > ---- > > > 1 file changed, 15 insertions(+), 22 deletions(-) > > > > > > diff --git a/drivers/usb/gadget/function/rndis.c > > > b/drivers/usb/gadget/function/rndis.c > > > index 64de9f1b874c..d2f18f34c8e5 100644 > > > --- a/drivers/usb/gadget/function/rndis.c > > > +++ b/drivers/usb/gadget/function/rndis.c > > > @@ -198,6 +198,9 @@ static int gen_ndis_query_resp(struct > > > rndis_params *params, u32 OID, u8 *buf, > > > outbuf = (__le32 *)&resp[1]; > > > resp->InformationBufferOffset = cpu_to_le32(16); > > > > > > + if (!params->dev) > > > + return -ENODEV; > > > + > > > > As Sergey points out, this check is useless and the ones below should > > also be removed. > > > > But, why make this check at all, how did you trigger a problem with > > the > > current code? > > > > Are you using this driver? If so, why? It is totally broken (as per > > the specification) and we really really need to just delete it from > > the > > tree to prevent anyone else from ever using it. > > > > thanks, > > > > greg k-h > Thanks for review, please ignore this patch. > Issue was triggered by our internal tool (probably not smart enough, > and cause false alarm). Ah, so that means I HAVE to reject it as you did not properly follow the requirements when you use tools like this. Please read Documentation/process/researcher-guidelines.rst for how to do this properly. That is now a requirement to make it so that we are not the ones doing the debugging of random tools like we just had to do here... You owe me 3 patch reviews now :) thanks, greg k-h