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 4371A45681; Mon, 22 Jul 2024 17:10:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C4D6406B7; Mon, 22 Jul 2024 17:10:49 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mails.dpdk.org (Postfix) with ESMTP id 747C140672 for ; Mon, 22 Jul 2024 17:10:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721661048; x=1753197048; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=Pu6hgA4JyWlb5Gx3+5lbUZ+AYHjwfVCzFJxwlyTNTv4=; b=Mm1JndkpwubT9BFNYpm061s2LNPhDZPGp8bTvOAyUVf8mve6jfq/OVOQ IWsAfGWzyuC586WCG4rBvSueGvq4oNcU08Qg/UQONBzsi7k4gma2Csv5G gh/qe5yTM13C6trPbTxNH4J6cXGmgKmKZJD1SpSihkOHdrWNc7KXDvq4u 7kv115npk+0s4PYwoOI8+3p1YP0Ewx0F2Yplj29Pkcu7NDcOX4xoPCnZp G8SESjKIFTnVNdNIyYTl3yqNmM8U9FJZJRNnsQaVaHcUUyVT1C1hqz/e9 csWIn2d8gy8uweZeb6L1Q4BF+yFuIUA0Sy+Puun8TSHGqR43p2O3RIGPc w==; X-CSE-ConnectionGUID: z8iIyRfxTpOfexX9xh5Fug== X-CSE-MsgGUID: oshxJIXFSSeVrFVrz9pEtA== X-IronPort-AV: E=McAfee;i="6700,10204,11141"; a="29821316" X-IronPort-AV: E=Sophos;i="6.09,228,1716274800"; d="scan'208";a="29821316" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2024 08:10:47 -0700 X-CSE-ConnectionGUID: dkjlAdp2RdiK9t3v1sv5ig== X-CSE-MsgGUID: 4IH+EzGUR1GlLm0kn4mA/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,228,1716274800"; d="scan'208";a="51843685" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmviesa009.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 22 Jul 2024 08:10:46 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 22 Jul 2024 08:10:45 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Mon, 22 Jul 2024 08:10:45 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.43) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 22 Jul 2024 08:10:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z+voMINflr7ifmWHjjBAV6Y1ihgjz0bpRjS41VXFnFEqNSq8V+XXpZF7YOBVC1vrtUO/CLSA/W7NiEdQ1mA7LmcOc3q618AcuJMdurdBQxiR7yp6FvEaqVDHoEKc71CLlR7s9wcO7iQGC4k3f5bET3B6zrE83fCNZnmnybS5l/Q5MftZ9gDBy48WJ17Jxk0Vsg7tLiV3iVXg3Yhr4uYKHPfsJTVMw+5dB+0tRdQOg+JMeU1RLPtP4bW2KIqjGfYujh85d6Fb1mFuhXgENG2TXOmhHCFCsdZ1yIx4tt/sYJrNDaqPKSqtFyO9bVizrwj/tLxFYqp3t5diou+8+sKVjQ== 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=K1tah4jjWZf6LUwoOZ7skMGOcd03JgWlekeNqH64BJg=; b=k7vZNbdpwxm4lgwvCvvNvgAB8tzOnZoEitb/FzXIgTi7LU/eEdp1zEZ7iR+twG8/YZ0kYF/q0QkmSDRBNQLqg83Kf9/HLtg+JKB956+e0AF00kL6RXiRKzjxWEGaWSOS/XDv/yWGEEfmDjZ+SvnJ7skzdEWgk0jnquJHxx9kCfmkMp+QTAe2Qf0M10vtb+FprRMV8S8CwEdTte0X8PQ+9KZCEhZYvK7PzecJWwcngsVdIRmNUAht9n4fd5pSFamrLtxsjoR9zaRX7D8FEd43Iwc65lBY4nqbAHqsv8toKf8whX1hMFiQdq5BSIXlNiqYZ4IwOOzg9m+pziwYoyx88A== 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 DS0PR11MB7529.namprd11.prod.outlook.com (2603:10b6:8:141::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20; Mon, 22 Jul 2024 15:10:41 +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.7784.016; Mon, 22 Jul 2024 15:10:41 +0000 Date: Mon, 22 Jul 2024 16:10:36 +0100 From: Bruce Richardson To: Vladimir Medvedkin CC: Subject: Re: [PATCH v5 2/3] net/ice: refactor raw pattern parsing function Message-ID: References: <20240722105950.199804-1-vladimir.medvedkin@intel.com> <20240722135046.285868-1-vladimir.medvedkin@intel.com> <20240722135046.285868-2-vladimir.medvedkin@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240722135046.285868-2-vladimir.medvedkin@intel.com> X-ClientProxiedBy: DB7PR03CA0073.eurprd03.prod.outlook.com (2603:10a6:10:72::14) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|DS0PR11MB7529:EE_ X-MS-Office365-Filtering-Correlation-Id: ee05a7f6-a0e3-437e-6cd6-08dcaa60739a 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?Hl/OHKr3repCd4JuA+ZpgkY4LwxWdsOQdJBcfN88usgBS6pkJjOP38Lu6bS3?= =?us-ascii?Q?Ql8wR3kH6kdZFs/22yB7L41kp6kx3/TdKs4v3n0qucbKdWBufjmLrluyZwSA?= =?us-ascii?Q?tD7OFIqVZA1NmhHvfnHSavc+I4UMzWVVLD3GsztHmpGJxfkAwGLgamDPVa2b?= =?us-ascii?Q?Lg9YPPODVmXxZcG1lYQzRbp0b/fBnB9hZrfpIX1HYtjTtkAQhqgY9aATuxPZ?= =?us-ascii?Q?5v40IASMtVB6g5dE2YJH3uGnmh6OhO9eLTIFR4x9lLKEgdbp8nJZla3teJAV?= =?us-ascii?Q?7FkniRGcdthxZk4o0GDg2rZY/JGP+nvDyW/fQhf5ILFV2GQMKiRRy8anI+Ax?= =?us-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tkpgxjZGNNEC1qE5pZ0jitFWX6N3?= =?us-ascii?Q?DqKCnUeVNC4U/1rPGsmZE06HJfdvb01jv4NRwp5VKiLDpZT7ilCRr2QGdVB+?= =?us-ascii?Q?6fj19DjUZnRJ+yaAaLIqO6HeSvgaG6b9cmrOPJ0KANg89w=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?ikoPv+5CbhIaD5wj5ab8F8vDMmoSW+t6N79RL0plPxEZW8MjFN9nX2gmBgVc?= =?us-ascii?Q?0ceCIQeTID0PVdGcXHQllx8UZzQ5GdUb+86TNBHfdUCZ/JYBGJBA8SeP+wxq?= =?us-ascii?Q?ItwcC/L/b/Yf7iWurOqlegDnKnvzUG7tt3lY/GOsGuVXVR9E0nsNjTUcqTC1?= =?us-ascii?Q?xSzXew3Sj+ufAALUwDMB3IHrr9Zq25TCDdnBuaewHFNGzSKgNLGTcwLvAi5d?= =?us-ascii?Q?VY/FmIKnQgNo/9GtBKoXQZ3K51vhLJbZjn9QCPwA8c9SQFXlUlX4RhDY5fGl?= =?us-ascii?Q?qeKPVQz1Z7Qd+uy58mMfov7IDNbRNJWgojDyF4Ecfshu6U84if8lG7VdPcKO?= =?us-ascii?Q?EBFAm9L2XWIJplAHGkO+DAjJJ/UpvErfVdpCicfCCeeqXeC4jBgitIUUrnKd?= =?us-ascii?Q?doPghEH/XEdGvDfUuFBkXpLdXyMi7YQGc8HO9MHFzYJoa0WlHrFL0s+7Gdu3?= =?us-ascii?Q?VSuizqAR/MNsgCrpp+SiyQlBj3Jim3F7l9/9/fXJgSP5hp38GmV1oCxcu6hZ?= =?us-ascii?Q?68wa8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CchoQNNCLO?= =?us-ascii?Q?AoP9337L98ZYbuROZSCf3EwvpAkBPvil2BfhA9cBDchdzRDpJ5NpwNPsppke?= =?us-ascii?Q?kuXUQvG3Frb1G0PEhqN/xeg4eMqjN9EKRUR7JwaH07XIn5c2mgVipQvY0yNm?= =?us-ascii?Q?69HOj4YLSmUL5UYX2QVTFMnhG1MPCyTYO43qp1NN+ICiQe67shmVfK6qZIbs?= =?us-ascii?Q?9A=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: ee05a7f6-a0e3-437e-6cd6-08dcaa60739a X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2024 15:10:41.4847 (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: os6KK663f1emyiJ8Qbsv+WFG2lKbm4iSyyWxxlfHlckkZ2o7o/VC/IHR+haC2xTpDJ0kvjM+eTWmUu3ZkkpY82Ca6TiLj82yIFeQ6rx8p/g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB7529 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 Mon, Jul 22, 2024 at 01:50:45PM +0000, Vladimir Medvedkin wrote: > Replace strlen with more secure strnlen in ice_hash_parse_raw_pattern. > > Signed-off-by: Vladimir Medvedkin > I believe there are quite a number of other small things in this function that could do with improvement e.g. the processing of the hex strings has no error checks for reporting invalid (i.e. non-hex) characters. However, this patch does improve things a bit by enhancing the length checks, so Acked-by: Bruce Richardson > --- > drivers/net/ice/ice_hash.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c > index 6b3095e2c5..aa76718313 100644 > --- a/drivers/net/ice/ice_hash.c > +++ b/drivers/net/ice/ice_hash.c > @@ -658,10 +658,13 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, > 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 + 1); > + if (spec_len != raw_spec->length) > + return -EINVAL; > + if (strnlen((char *)(uintptr_t)raw_mask->pattern, raw_spec->length + 1) != > + spec_len) > + return -EINVAL; > > pkt_len = spec_len / 2; > > -- > 2.34.1 >