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 6BE90455FE; Thu, 11 Jul 2024 19:05:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5895C42E5A; Thu, 11 Jul 2024 19:05:22 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id 078BC4065B for ; Thu, 11 Jul 2024 19:05:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720717521; x=1752253521; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=n8oTIeH+beUUCGuPHzLSqy8r3lUfNX/5Hocpsz2mtnQ=; b=RNJ+bWWOAW0Y72f0/mMWGeIxhv6Trtxm7K7kSwj7g3KeQZcH8zxRA5cm 0ltnbkumXZwhbhJXQAHIVlnCF8q9DDDtPHSF7Ycf8x+oUX7rG8oio4O8x QMfCpGiSxmEEoPJYu0zP175NfIywj6rdHm95aEt1D4w2ACQ6SbCGcLx/i ohvUHMtqU+IJ6Mb6jzGYzbAo0blIXAsEa6LBIL7PA5+mub5kc4CDFud0V uni3B7ukwkCFBQdMM9IvdoyXIueCIt5OlqzcyfxrMk+Ai7pm+UFACOw5U tLwIRGMqi9JaMq/op+OD0uISIJrQ1pZT1WR7qvP8eVXGfQbpeMVRvaR3H g==; X-CSE-ConnectionGUID: GjNtec7CS2SvzNBDNCoMbA== X-CSE-MsgGUID: Pmqbbx46TQiv6eNaQiPsLA== X-IronPort-AV: E=McAfee;i="6700,10204,11130"; a="40641544" X-IronPort-AV: E=Sophos;i="6.09,200,1716274800"; d="scan'208";a="40641544" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2024 10:05:20 -0700 X-CSE-ConnectionGUID: cmHZBBtlTRWi2BrTF6wYmw== X-CSE-MsgGUID: FGNC7MCkRqu4ttVwbMnl8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,200,1716274800"; d="scan'208";a="79328679" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orviesa002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 11 Jul 2024 10:05:21 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) 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; Thu, 11 Jul 2024 10:05:19 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX611.amr.corp.intel.com (10.22.229.24) 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:05:19 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx601.amr.corp.intel.com (10.22.229.14) 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:05:19 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.47) 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:05:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FR33REE7OtB0wJ38blc6xc+M4/CxyLgXeCo2lHWT+pWEbnsvuJGCkiSDwoNIyCUvrzBtmSGEXv0Et+/f7mt7NlKLMiSSYydA2m2f9Q8PVsOnAbMukiX9wb8MAE2r5K0nNja9cZ24TNgTrlZnxjtcBL+kHcZVukN9LzVwGdhHvcyvhKHm+0HK4YOlz8NNnQZeFYhK7oliEBOBVCg7Uby/MM9dnqn6/BexdZW5C5YgpUKK43oOE0G2zKQ6FB7KP2kWaSGiPgTbcwWTggR9QOBuygdyM5tMBaaK4s/hxX3KoY1hbGxc6VMSzLzMtoWytt86SC16rYVUwPx9Rm+Zlef7zA== 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=3/4JZgVnqbh378K4f9jzS9rER+cB7eA6SRdZBLBnX6w=; b=MEh8s+FQKsOVsq8uaaCIVONO8x+EXowpDcl3J9AZ7kcT3XGD1INxka+GldfGTjl1e6eZUQ4WaJ21BnTYsud2JzthMs1xM9lr/Ieg2aAzqnaTHlQTTPCLBKwPqf8G8N44WMhSZBZYmoNALVd6LIkh2dzKdn9CwSTvV0UVqtTZmRNrkkqSYq6sAI/96zQD6yqP20UBhS0jqXnBijY+LS4joUtzGvVNIF62kuHQ5v9fpjHQdJdaQsmfTmUKitvnlsLcJI9byNQcjJK0gybwmzWH5lvzNM3OCht9QU/IeacRLSDi+/cQuzTtHDoQsUwdnZmAVv792TySOQsInrgVOjdU/w== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by MW4PR11MB6981.namprd11.prod.outlook.com (2603:10b6:303:229::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23; Thu, 11 Jul 2024 17:05:17 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%7]) with mapi id 15.20.7762.016; Thu, 11 Jul 2024 17:05:17 +0000 Date: Thu, 11 Jul 2024 18:05:11 +0100 From: Bruce Richardson To: Vladimir Medvedkin CC: , , Michael Theodore Stolarchuk Subject: Re: [PATCH] net/ice: fix possible memory leak Message-ID: References: <20240711165907.3169191-1-vladimir.medvedkin@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240711165907.3169191-1-vladimir.medvedkin@intel.com> X-ClientProxiedBy: DB9PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:10:1da::33) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|MW4PR11MB6981:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ec60cb7-8b2e-496a-4b90-08dca1cba342 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|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?NlDRqXzFX6wTOUnoRv+yhHMrCnUA+rUFTzBsBOmPZdE/VHR+xh5f6uBXTRDP?= =?us-ascii?Q?d5c/jCIRBEespLIlEBGwvgFl9PFpVi2LPwcDE3zW4/AIYcteJ04Nrd++pElb?= =?us-ascii?Q?bM0g3sAKxpce6sO8ZwgUM3SeOcuF6aHNzsUXoDmXY4Jj3UXqdXp524sxLDrj?= =?us-ascii?Q?WCOQZsF6sh7NsChW94+idSJRrr3AkDgX4fZ1/sMMnRYNVRlNEjEScBueg0OK?= =?us-ascii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cpEW+K2akP5KFbo3aUZ?= =?us-ascii?Q?jhrIncjh0eFJHxDSQ0vbAr1CPSx94/xmAGmXXzToRmiiMwc9Ai5e66Omrbd8?= =?us-ascii?Q?91/X5iInGgroY4IoSQtRj+VgtsfbaysZTWLZU/1aC6R1rAw9A7BZ9PGelhaX?= =?us-ascii?Q?76zLWgdWnwClZaUPiImQX7lpX0D4bTOVBaG9cqTGaxRBQQIOtu0VIh/IJXoL?= =?us-ascii?Q?ZnSsKo95j/Nhpya3o0oOYVNa+z6JGebjT1ABsuJpJUZz/A=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?QIkPnWFtLoSLkl94E8FMX5vV97PH5SPjzIMh5mFgovqBnqwZJHZWWoD+UINz?= =?us-ascii?Q?edXd1reNVwGzugtTOJjSwjkCMwYk2OddgTETqNj+7udnYGRKtXaLw+A8GWAX?= =?us-ascii?Q?QUt/FYKg1EkH7Z4f8L6p//RWUNLAoUnBZo9AqiVyDKbaLpfbmSniI6bTb0ST?= =?us-ascii?Q?qKhVRvkAqC3IIR3J2iUcwD+h1oYNyVisM7fDUGtq/Ck6Z83vgVf0wZAFUBoj?= =?us-ascii?Q?QU0t7J4G/3DUs/yimrgF7OfMwsbC52PKI3LNQSANRIZdyA6ldejYxsIXkL5e?= =?us-ascii?Q?r+bSbQHSeH+zCmoQJaTm0TCt3nfbc5YnLZSA0LFjQPh31b2eig+E/ZA+hZjL?= =?us-ascii?Q?9fHbPYxy73T3B3n7KXMqoF95HubxVIxDbF3hRSBifU6hlKSMZdxtJk3v7Vx8?= =?us-ascii?Q?ojz5F+ihE1po1K1uBMN4fwKOddF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TmLIO4lMvfXTMcMi3vb3wezgTagiJED3yyIA39Raicy3B/0r1UWAih?= =?us-ascii?Q?FtGGEhcA0dDQ/I5GwFUOBN4zdaPtK8ErbhvLXa7bpZIOIhEPT2l+PR52xsgH?= =?us-ascii?Q?d/beBeG+w1zNbBKAQsUeHQ+6Eq19XY6SDI7BAOTfKdbH6lpEjv5ux9tkAD65?= =?us-ascii?Q?tDAtyTlyyTexGuNUXtke51NooDLZaugGtEoPWaOrFQzDrLY/LDYE2WVOnEXC?= =?us-ascii?Q?q5+EsPQKLbkBLXAO97+JiW/CM5VJ3P/8Ahx0bsXwpk/0CAw+ki4cqPij7rHV?= =?us-ascii?Q?8w=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5ec60cb7-8b2e-496a-4b90-08dca1cba342 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 17:05:17.1806 (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: lQtlbBhd5Sb0VnLYLAbsGVx0K51U+Oed6p3awTTFeyBi73rUqEACObO1D9aEGbLtE+V5EjWxog3ADNrqbWxM+6Dnyt0TYYX+XO0OanzMMYs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB6981 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 On Thu, Jul 11, 2024 at 04:59:07PM +0000, Vladimir Medvedkin wrote: > This patch fixes possible memleak inside the > ice_hash_parse_raw_pattern(). > Additionally replaces using strlen() with more secure strnlen(). > Also replaces the returned inconsistent rte_errno > with explicit error statuses. > Hi Vladimir, I think you could do with explaining more about how the memory leak comes about. It's also not helped by having multiple additional changes in this patch, can they be split off into a separate patch to fix the error codes (and change the strlen in passing), or even two additional patches for the error code and strlen issues individually. /Bruce. > Fixes: 1b9c68120a1c ("net/ice: enable protocol agnostic flow offloading in RSS") > Cc: ting.xu@intel.com > Cc:stable@dpdk.org > > Reported-by: Michael Theodore Stolarchuk > Signed-off-by: Vladimir Medvedkin > --- > drivers/net/ice/ice_hash.c | 32 +++++++++++++++++++------------- > 1 file changed, 19 insertions(+), 13 deletions(-) > > diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c > 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 = 0; > uint8_t tmp_c = 0; > - int i, j; > + int i, j, ret = 0; > > if (ad->psr == NULL) > - return -rte_errno; > + return -ENOTSUP; > > raw_spec = item->spec; > raw_mask = item->mask; > > - spec_len = strlen((char *)(uintptr_t)raw_spec->pattern); > - if (strlen((char *)(uintptr_t)raw_mask->pattern) != > - spec_len) > - return -rte_errno; > + spec_len = strnlen((char *)(uintptr_t)raw_spec->pattern, raw_spec->length); > + if (strnlen((char *)(uintptr_t)raw_mask->pattern, raw_mask->length) != > + spec_len) > + return -EINVAL; > > pkt_len = spec_len / 2; > > @@ -670,8 +670,10 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, > return -ENOMEM; > > msk_buf = rte_zmalloc(NULL, pkt_len, 0); > - if (!msk_buf) > + if (!msk_buf) { > + rte_free(pkt_buf); > return -ENOMEM; > + } > > /* convert string to int array */ > for (i = 0, j = 0; i < spec_len; i += 2, j++) { > @@ -708,18 +710,22 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, > msk_buf[j] = tmp_val * 16 + tmp_c - '0'; > } > > - if (ice_parser_run(ad->psr, pkt_buf, pkt_len, &rslt)) > - return -rte_errno; > + ret = ice_parser_run(ad->psr, pkt_buf, pkt_len, &rslt); > + if (ret) > + goto free_mem; > > - if (ice_parser_profile_init(&rslt, pkt_buf, msk_buf, > - pkt_len, ICE_BLK_RSS, true, &prof)) > - return -rte_errno; > + ret = ice_parser_profile_init(&rslt, pkt_buf, msk_buf, > + pkt_len, ICE_BLK_RSS, true, &prof); > + if (ret) > + goto free_mem; > > rte_memcpy(&meta->raw.prof, &prof, sizeof(prof)); > > +free_mem: > rte_free(pkt_buf); > rte_free(msk_buf); > - return 0; > + > + return ret; > } > > static void > -- > 2.34.1 >