From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5662145601; Thu, 11 Jul 2024 19:07:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 459F542E5A; Thu, 11 Jul 2024 19:07:17 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by mails.dpdk.org (Postfix) with ESMTP id D693A4065B for ; Thu, 11 Jul 2024 19:07:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720717635; x=1752253635; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=xcg0Jz6D2GcehuhFS7wTEh5f7HkLiMw+JUy10Ca1sQ0=; b=RAQFQXwJ0fKFyCzHDgLpKzrXVrZxrlFuqCtR1hDMImPAr7MtK+FMyquw 0ddnNqt7FERxJ5aPVfESGIGx3PFAhxBFizzgBgWuCv+GzvKyOabWWiK5A X2Gr3wYH/L0mZpVAwkmBnwiJlA1XC7K3gPmEVIT3NJLOyMdpevhKRT6gz QAOBWxMUs+LEFyFUF9Iipz9LnlM5l4JiXtWR0EIgXWAW4gWdUbs0E/G4U YWlW5x/dQZWdtVopDJFV3ZDO7mfEkmZKDUvrN/hUbXVtS/AElmBXRGbOo k43WiXK5yvhR70jXDuPdJajECAHk3cjIV/DGsjX5qsVFaB4UXNfUnrY3z w==; X-CSE-ConnectionGUID: aYNscqa9RrWlCv1GY2pKEA== X-CSE-MsgGUID: 8noYXrmJRbuYd2eC1CV7Sg== X-IronPort-AV: E=McAfee;i="6700,10204,11130"; a="21030882" X-IronPort-AV: E=Sophos;i="6.09,200,1716274800"; d="scan'208";a="21030882" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2024 10:07:14 -0700 X-CSE-ConnectionGUID: lQmZT9QkTguuoQd4x9F7uw== X-CSE-MsgGUID: KLgn1imQToqU8Hmm4tWQlg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,200,1716274800"; d="scan'208";a="53574080" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orviesa005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 11 Jul 2024 10:07:14 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 10:07:13 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 10:07:12 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 11 Jul 2024 10:07:12 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.171) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 11 Jul 2024 10:07:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WkjZ84cP9fof7r8C7ERFNfwbRxVDcS41dMU4Eh60AKt2LzF4f1pzaRLZaBZKm/XdIvprtzp62QU/wBI++f+FQetYUNif4PzT1lRV/E/HyVR4qV0stPlAcYHuCd7DBEUGAgG0/vAFtGSg0sEcx9zZXhlf3G5EyUlhmWsmA9LLZI+amobW6kwP7xoFCcEKyxJMiGfJ3BFxqXivXvcg/a+jCm8WyJIIASzQuPUwG5NPA82DXr4XCZ2TX/ozj0X9fp1r/liIW3XZHKNvByq0AezI77W65yRDCfHoEnmDCNQPtM1b1JktRcjoS4l3U/DnLkXFAhHQ3fHQMdY78J92Kox1Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nh2XSZhBhd0DSCbUDXgoFgizcinclqDac8XWcl4VqYE=; b=NWygXmqwqsFHj/BdPpi4awBmVpwnQnTWAUK7b4w6S9Dc0yPzpU7K7DboKBGdDG2T2rlnshmulg3CCvMbCWuiS/NDmEZx5vD9R/NVgcjdEqBH10wR92NmCRwoGOxMWusGZ2Bhj7wPKXtJd6LEEKs/0j1olQFezkFDcMd9OaasNEQbFZ0t5wNp1f0xb3gvb1sdMeV5+ohG79/GdLX2l2/NI25s8x3TyPi68J8U3aRZ4fhusS+QlmAIA26W4P9BNFNOjU1sNl459fQ/Z0MiqzdCgV1g9cW+KQZKbHZxZ7yvK+ph5ZeCNhSe+zZm0T10h1D34jVujxTfpH/ea15AgOCBYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SJ0PR11MB5772.namprd11.prod.outlook.com (2603:10b6:a03:422::8) by MN0PR11MB5985.namprd11.prod.outlook.com (2603:10b6:208:370::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.20; Thu, 11 Jul 2024 17:07:08 +0000 Received: from SJ0PR11MB5772.namprd11.prod.outlook.com ([fe80::5851:319:3da6:850b]) by SJ0PR11MB5772.namprd11.prod.outlook.com ([fe80::5851:319:3da6:850b%5]) with mapi id 15.20.7741.033; Thu, 11 Jul 2024 17:07:08 +0000 From: "Medvedkin, Vladimir" To: "Richardson, Bruce" CC: "dev@dpdk.org" , "Stolarchuk, Michael" Subject: RE: [PATCH] net/ice: fix possible memory leak Thread-Topic: [PATCH] net/ice: fix possible memory leak Thread-Index: AQHa07Ok/KqdPyU6802if4n5YlLykbHxwZOAgAAARqA= Date: Thu, 11 Jul 2024 17:07:08 +0000 Message-ID: References: <20240711165907.3169191-1-vladimir.medvedkin@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SJ0PR11MB5772:EE_|MN0PR11MB5985:EE_ x-ms-office365-filtering-correlation-id: 93f1c4cc-d3df-44df-2c0c-08dca1cbe5f8 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?us-ascii?Q?RE+lMMrh6n+3IObMldxAeWuICXwSmPUCB9c5uNRagEBa0r3F8nqzgu+QekbT?= =?us-ascii?Q?hYJQ4u8yH9zYCXHOB1ba7FWESyDYJkRoUpY1g+lnFfN/+ZLfYaHokEMxXAiQ?= =?us-ascii?Q?6sAn2gba+RsjlbaMDxB5svXCG3+JqSTuRBcvR68c4ilB7gl28Fql/VmuFdUK?= =?us-ascii?Q?5zon/tfDSdbCA7BxriqjxgNErWyneULCpOCCKDlgCG5dgp3nGzLeCwwVRsEf?= =?us-ascii?Q?QqK2KYFLFcJ4WQIuyRhiZSv+JNzY8tm+E1wUZaiYoLs0AaG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aDYDEoVUrANC8WGgnJXYadd2zK6l4L1Rjfpc+KDZL5t?= =?us-ascii?Q?DvkhWB87Nd57dPxarNFV3IKozZSZJ1y+EFrRrejYD0xLY7XDAaIj2Lv4j352?= =?us-ascii?Q?tCVf7/IXdxlIrc8swjFL3o5xdWa4M4qBeQnKV4vNp4wEy/prD35ZPLM2XaJt?= =?us-ascii?Q?7or2dsHFx1WPMoPXc1YlOGnDqU5hmjY6R7Yr1q9GtmpgH6BnUhKNvufsQ1p0?= =?us-ascii?Q?Zz2Qg6sWgeCJ+ojcHiJi8WugVEi4AipzA7FiJtZlVo0/yEZoiA=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR11MB5772.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?J6G9xXtRNk0d14KFX9MGgsLfAfncaa7tGVIzEYjRJkoYUIA+MflBKw6YFFVn?= =?us-ascii?Q?kecJ94KBBy9wtlbbJCueJXcFRz/B/7Icu3QzeIQSbnzT7okRoBd026rvUDPm?= =?us-ascii?Q?7F0XL6VjrOe4wjQ/qsqOpOWZOhJv8cAstUkQX+ogHrgVyyWmUOYP8hzA1gqZ?= =?us-ascii?Q?mMwVWJwJ9TDKem8J3WjkNycLScQYytMpEYCAFfGjqWnzQNiAI4RqtdcXPYrp?= =?us-ascii?Q?btbRuKJsr0YHeFztxATPTqIQtxTRRQ0xjoL6YMsZTcAcofS9Gz9Be+suxico?= =?us-ascii?Q?pLJLj5td10qanEoMdOQ9EzZ5SqfOTXUcZO4tiBnJdzO0Em/lVjxzqgDnpuGf?= =?us-ascii?Q?oHvK8guzYKr+/IfoO+m9BRYeosOREXmbNewXiMr1np4qXcemu5cLUykuNpde?= =?us-ascii?Q?FDt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DdRbAsX?= =?us-ascii?Q?s3HX1izFtVHK+zgDmTb7ud0L0GB/+dbcqay/COzCxhjG2MomlyrsalzW7pzk?= =?us-ascii?Q?PhJNhzoJSBkwfkZZMGXbqXpnMmtUIf4b0li9yMampCDTOSk6UwYpvItMQbRM?= =?us-ascii?Q?y7p+hhNnCzkxFpgD7gctHhbhIIg6U9hmL9ci+gzmXB2YlM/13+vTbMOE63bq?= =?us-ascii?Q?55UCw4hngIZPMxPlTDjaEmto1dG2AeKWVuF0gr4MpHOZtXSux80uOZx9tji/?= =?us-ascii?Q?bFCp54K2Drnp6JjckcgDGiZxl3gokX10rzhKeUK2+CEpLfu3XvgEgFxzOd9E?= =?us-ascii?Q?xg=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB5772.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93f1c4cc-d3df-44df-2c0c-08dca1cbe5f8 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jul 2024 17:07:08.8178 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: P9uWwS3La5V7X+Snw0ZCO40CJFb4nRT2Ee3bETUUlYDRD29gM+Eeso6D6xWkhNLUBwHTkxbr57IZAlja4nA2vqD3RGPJ0MHL/4fWmWHtKhg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR11MB5985 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Bruce, Sure, will submit v2. Thanks! -----Original Message----- From: Richardson, Bruce =20 Sent: Thursday, July 11, 2024 6:05 PM To: Medvedkin, Vladimir Cc: dev@dpdk.org; ting.xu@intel.com; Stolarchuk, Michael Subject: Re: [PATCH] net/ice: fix possible memory leak On Thu, Jul 11, 2024 at 04:59:07PM +0000, Vladimir Medvedkin wrote: > This patch fixes possible memleak inside the=20 > ice_hash_parse_raw_pattern(). > Additionally replaces using strlen() with more secure strnlen(). > Also replaces the returned inconsistent rte_errno with explicit error=20 > statuses. >=20 Hi Vladimir, I think you could do with explaining more about how the memory leak comes a= bout. It's also not helped by having multiple additional changes in this pa= tch, can they be split off into a separate patch to fix the error codes (an= d change the strlen in passing), or even two additional patches for the err= or code and strlen issues individually. /Bruce. > Fixes: 1b9c68120a1c ("net/ice: enable protocol agnostic flow=20 > offloading in RSS") > Cc: ting.xu@intel.com > Cc:stable@dpdk.org >=20 > Reported-by: Michael Theodore Stolarchuk > Signed-off-by: Vladimir Medvedkin > --- > drivers/net/ice/ice_hash.c | 32 +++++++++++++++++++------------- > 1 file changed, 19 insertions(+), 13 deletions(-) >=20 > diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c=20 > index f923641533..a7dbb54d91 100644 > --- a/drivers/net/ice/ice_hash.c > +++ b/drivers/net/ice/ice_hash.c > @@ -650,18 +650,18 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, > uint8_t *pkt_buf, *msk_buf; > uint8_t tmp_val =3D 0; > uint8_t tmp_c =3D 0; > - int i, j; > + int i, j, ret =3D 0; > =20 > if (ad->psr =3D=3D NULL) > - return -rte_errno; > + return -ENOTSUP; > =20 > raw_spec =3D item->spec; > raw_mask =3D item->mask; > =20 > - spec_len =3D strlen((char *)(uintptr_t)raw_spec->pattern); > - if (strlen((char *)(uintptr_t)raw_mask->pattern) !=3D > - spec_len) > - return -rte_errno; > + spec_len =3D strnlen((char *)(uintptr_t)raw_spec->pattern, raw_spec->le= ngth); > + if (strnlen((char *)(uintptr_t)raw_mask->pattern, raw_mask->length) != =3D > + spec_len) > + return -EINVAL; > =20 > pkt_len =3D spec_len / 2; > =20 > @@ -670,8 +670,10 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, > return -ENOMEM; > =20 > msk_buf =3D rte_zmalloc(NULL, pkt_len, 0); > - if (!msk_buf) > + if (!msk_buf) { > + rte_free(pkt_buf); > return -ENOMEM; > + } > =20 > /* convert string to int array */ > for (i =3D 0, j =3D 0; i < spec_len; i +=3D 2, j++) { @@ -708,18 +710,2= 2=20 > @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, > msk_buf[j] =3D tmp_val * 16 + tmp_c - '0'; > } > =20 > - if (ice_parser_run(ad->psr, pkt_buf, pkt_len, &rslt)) > - return -rte_errno; > + ret =3D ice_parser_run(ad->psr, pkt_buf, pkt_len, &rslt); > + if (ret) > + goto free_mem; > =20 > - if (ice_parser_profile_init(&rslt, pkt_buf, msk_buf, > - pkt_len, ICE_BLK_RSS, true, &prof)) > - return -rte_errno; > + ret =3D ice_parser_profile_init(&rslt, pkt_buf, msk_buf, > + pkt_len, ICE_BLK_RSS, true, &prof); > + if (ret) > + goto free_mem; > =20 > rte_memcpy(&meta->raw.prof, &prof, sizeof(prof)); > =20 > +free_mem: > rte_free(pkt_buf); > rte_free(msk_buf); > - return 0; > + > + return ret; > } > =20 > static void > -- > 2.34.1 >=20