Message ID | 20231212024015.11595-1-chentao@kylinos.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7473814vqy; Mon, 11 Dec 2023 18:41:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6g1jFDY3H8Lf/EqUybZ9qZXfdN2CLQgFOvyWDTYaKdKDCtE7fj/acxCWldNoH/88pX6KZ X-Received: by 2002:a05:6808:1493:b0:3b9:d4c0:5fac with SMTP id e19-20020a056808149300b003b9d4c05facmr7261582oiw.22.1702348909799; Mon, 11 Dec 2023 18:41:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702348909; cv=none; d=google.com; s=arc-20160816; b=jCuyvF+vHznUu3SWkB7kn0kI6FVHD8Ki91WLlbOL0/oXLEGsMYuzy3tqWDvSbIvbM1 oOmSp1dpX38orMYrpuz0fZh2iuNfUzL4G2VTvE9N+c484uYPaNkpt7ahUw+5bFpz9RCE rK4QF5JaD2Zk0nAoM0O0YU52RUN9puh7NGT9ESBasiMA/xijEHKdbNz+npHxkCCKHHhO vOEDxINgnsVvrVntFaDnUfdej7E3wsW03L2xb/Vu0+oPz+AuWBPRUn7ErjI8ShL/96VI Mpajrln/oH1M3pUwdPWTt4ixQCqkxOZHt+48psbVaSqOAOFHokz1xP9hFth51xdmamar YoVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ClQm7TMg1QtULVZBJp3IluzjYfaMQlj9xvz//FC/YEA=; fh=mxdIi1UagyzNWwtTL9nf2TVBF4+jojfbudp7+wRChsM=; b=mPYlNY9+LRD0hKD1QDX2cSOhfPLSLYH8Dbcpkl2g8lH0gBoUp/XAdIeO62bjhGCHQl T2tN7jR1KQftAtphG9Mtd0gGsQCDVS+s1ZnZbQFxaXQ/4FdJGsy4zZ0HUnJKKyFVANQ+ JDKLRtsO99PsriaqAwcJVmIJfZzmaCnPEh5Pz83g+GtNhUmEMN+dlqMJM7eT/0MuMk2S MoDJ5lIUtPAE1enp1YMgnxIV8p3iGoPn7BdfoLchCPCpRi4A6l4rQNKT8YDgvSot4Yhx ehVHyiK8xL0NrKQ5F+FWb7ix2OidBP91jHQX7Y4g4AnrZHRy99nYsSu7HWaZk74VH/Fg G1DA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id r4-20020a6560c4000000b005b90af1943asi6884507pgv.807.2023.12.11.18.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 18:41:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B000C80C6197; Mon, 11 Dec 2023 18:41:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231131AbjLLCle (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Mon, 11 Dec 2023 21:41:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbjLLCld (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 11 Dec 2023 21:41:33 -0500 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A37395; Mon, 11 Dec 2023 18:41:37 -0800 (PST) X-UUID: 4759270ba271402a9eb2763b09177321-20231212 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:ef34a73b-103f-49bd-8d1b-2c1247446e59,IP:15, URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:-5 X-CID-INFO: VERSION:1.1.33,REQID:ef34a73b-103f-49bd-8d1b-2c1247446e59,IP:15,UR L:0,TC:0,Content:-5,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-5 X-CID-META: VersionHash:364b77b,CLOUDID:32091661-c89d-4129-91cb-8ebfae4653fc,B ulkID:231212104122Y4L22WMT,BulkQuantity:0,Recheck:0,SF:44|66|38|24|17|19|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 4759270ba271402a9eb2763b09177321-20231212 X-User: chentao@kylinos.cn Received: from vt.. [(116.128.244.169)] by mailgw (envelope-from <chentao@kylinos.cn>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1486382473; Tue, 12 Dec 2023 10:41:20 +0800 From: Kunwu Chan <chentao@kylinos.cn> To: jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, jacob.e.keller@intel.com Cc: karol.kolacinski@intel.com, michal.michalik@intel.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan <chentao@kylinos.cn>, Kunwu Chan <kunwu.chan@hotmail.com>, Przemek Kitszel <przemyslaw.kitszel@intel.com> Subject: [PATCH v2 iwl-next] ice: Fix some null pointer dereference issues in ice_ptp.c Date: Tue, 12 Dec 2023 10:40:15 +0800 Message-Id: <20231212024015.11595-1-chentao@kylinos.cn> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 11 Dec 2023 18:41:42 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785042210641304231 X-GMAIL-MSGID: 1785042210641304231 |
Series |
[v2,iwl-next] ice: Fix some null pointer dereference issues in ice_ptp.c
|
|
Commit Message
Kunwu Chan
Dec. 12, 2023, 2:40 a.m. UTC
devm_kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure.
Fixes: d938a8cca88a ("ice: Auxbus devices & driver for E822 TS")
Cc: Kunwu Chan <kunwu.chan@hotmail.com>
Suggested-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
drivers/net/ethernet/intel/ice/ice_ptp.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
On 12/12/23 03:40, Kunwu Chan wrote: > devm_kasprintf() returns a pointer to dynamically allocated memory > which can be NULL upon failure. > > Fixes: d938a8cca88a ("ice: Auxbus devices & driver for E822 TS") > Cc: Kunwu Chan <kunwu.chan@hotmail.com> > Suggested-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> You found the bug (or some some static analysis tool in that case); there is no need to add Suggested-by for every person that suggests something during review - the tag is for "person/s that suggested making such change in the repo". Subject line would be better if less generic, eg: ice: avoid null deref of ptp auxbus name > Signed-off-by: Kunwu Chan <chentao@kylinos.cn> > --- > drivers/net/ethernet/intel/ice/ice_ptp.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c > index e9e59f4b5580..848e3e063e64 100644 > --- a/drivers/net/ethernet/intel/ice/ice_ptp.c > +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c > @@ -2743,6 +2743,8 @@ static int ice_ptp_register_auxbus_driver(struct ice_pf *pf) > name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u", > pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn), > ice_get_ptp_src_clock_index(&pf->hw)); > + if (!name) > + return -ENOMEM; > > aux_driver->name = name; > aux_driver->shutdown = ice_ptp_auxbus_shutdown; > @@ -2989,6 +2991,8 @@ static int ice_ptp_create_auxbus_device(struct ice_pf *pf) > name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u", > pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn), > ice_get_ptp_src_clock_index(&pf->hw)); > + if (!name) > + return -ENOMEM; > > aux_dev->name = name; > aux_dev->id = id; Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Regarding iwl-next vs iwl-net: this bug is really unlikely to manifest, as we take care of both earlier and future mem allocs for ptp auxbus, and auxiliary_device_init() checks for null name, so no big deal, so: -next is fine
On Wed, Dec 13, 2023 at 10:49:10AM +0100, Przemek Kitszel wrote: > On 12/12/23 03:40, Kunwu Chan wrote: > > devm_kasprintf() returns a pointer to dynamically allocated memory > > which can be NULL upon failure. > > > > Fixes: d938a8cca88a ("ice: Auxbus devices & driver for E822 TS") > > Cc: Kunwu Chan <kunwu.chan@hotmail.com> > > Suggested-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> > > You found the bug (or some some static analysis tool in that case); > there is no need to add Suggested-by for every person that suggests > something during review - the tag is for "person/s that suggested > making such change in the repo". > > Subject line would be better if less generic, eg: > ice: avoid null deref of ptp auxbus name > > > Signed-off-by: Kunwu Chan <chentao@kylinos.cn> > > --- > > drivers/net/ethernet/intel/ice/ice_ptp.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c > > index e9e59f4b5580..848e3e063e64 100644 > > --- a/drivers/net/ethernet/intel/ice/ice_ptp.c > > +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c > > @@ -2743,6 +2743,8 @@ static int ice_ptp_register_auxbus_driver(struct ice_pf *pf) > > name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u", > > pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn), > > ice_get_ptp_src_clock_index(&pf->hw)); > > + if (!name) > > + return -ENOMEM; > > aux_driver->name = name; > > aux_driver->shutdown = ice_ptp_auxbus_shutdown; > > @@ -2989,6 +2991,8 @@ static int ice_ptp_create_auxbus_device(struct ice_pf *pf) > > name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u", > > pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn), > > ice_get_ptp_src_clock_index(&pf->hw)); > > + if (!name) > > + return -ENOMEM; > > aux_dev->name = name; > > aux_dev->id = id; > > Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> > > Regarding iwl-next vs iwl-net: this bug is really unlikely to manifest, > as we take care of both earlier and future mem allocs for ptp auxbus, > and auxiliary_device_init() checks for null name, so no big deal, > so: -next is fine Thanks. FWIIW, this looks good to me too. Reviewed-by: Simon Horman <horms@kernel.org>
> -----Original Message----- > From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Kunwu Chan > Sent: Tuesday, December 12, 2023 8:10 AM > To: Brandeburg, Jesse <jesse.brandeburg@intel.com>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>; davem@davemloft.net; edumazet@google.com; kuba@kernel.org; pabeni@redhat.com; richardcochran@gmail.com; Keller, Jacob E <jacob.e.keller@intel.com> > Cc: Michalik, Michal <michal.michalik@intel.com>; Kunwu Chan <chentao@kylinos.cn>; Kunwu Chan <kunwu.chan@hotmail.com>; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Kolacinski, Karol <karol.kolacinski@intel.com>; intel-wired-lan@lists.osuosl.org; Kitszel, Przemyslaw <przemyslaw.kitszel@intel.com> > Subject: [Intel-wired-lan] [PATCH v2 iwl-next] ice: Fix some null pointer dereference issues in ice_ptp.c > > devm_kasprintf() returns a pointer to dynamically allocated memory > which can be NULL upon failure. > > Fixes: d938a8cca88a ("ice: Auxbus devices & driver for E822 TS") > Cc: Kunwu Chan <kunwu.chan@hotmail.com> > Suggested-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> > Signed-off-by: Kunwu Chan <chentao@kylinos.cn> > --- > drivers/net/ethernet/intel/ice/ice_ptp.c | 4 ++++ > 1 file changed, 4 insertions(+) > Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index e9e59f4b5580..848e3e063e64 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -2743,6 +2743,8 @@ static int ice_ptp_register_auxbus_driver(struct ice_pf *pf) name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u", pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn), ice_get_ptp_src_clock_index(&pf->hw)); + if (!name) + return -ENOMEM; aux_driver->name = name; aux_driver->shutdown = ice_ptp_auxbus_shutdown; @@ -2989,6 +2991,8 @@ static int ice_ptp_create_auxbus_device(struct ice_pf *pf) name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u", pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn), ice_get_ptp_src_clock_index(&pf->hw)); + if (!name) + return -ENOMEM; aux_dev->name = name; aux_dev->id = id;