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 A3AEE45848; Thu, 22 Aug 2024 18:51:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D14842F08; Thu, 22 Aug 2024 18:51:17 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id 4F8BF42F07; Thu, 22 Aug 2024 18:51:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724345476; x=1755881476; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=nuRHSy4UV8QvTl20oI/z1rhzRThjqJIxc5CVOgmKOqU=; b=Y/3lt9R7iUYIiFej9aR2FFnwn+kntILctDOAKkNhs8oX+BXoKM4LVyJL dowhjA3IVD7ehXOn1XJwB6OsiyIKIK9X58SawsBqQZbqn0GYvZx0ngGIl gc+B4UwBU2B5dfg8/1m1XlrL8Vdc64WugMT4lOie4M7YJrtNidc4Af3+4 jswLzv2fzWoooA2O3Cdsh5lo0/pfCfjArrtYnAWRf/RRSrV2iMxTdSWEu 8nShBnIH27Qk/jDrprRsmKwoEu4WFBcwrFOB+tXkAp+na+Yz0iJ0y+tsq sQA+9g/Gx+sIlxOh0DnNJKDLXPRn+tKtEGdW+pP12yhqRw0+SDpTgHxi8 g==; X-CSE-ConnectionGUID: QL626pU9S6+/wZzemilMSg== X-CSE-MsgGUID: ZxXJKTjzRW6cxTA2SpNI8Q== X-IronPort-AV: E=McAfee;i="6700,10204,11172"; a="45297732" X-IronPort-AV: E=Sophos;i="6.10,167,1719903600"; d="scan'208";a="45297732" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2024 09:50:48 -0700 X-CSE-ConnectionGUID: Go988v9QQSyBEkesn3kFnw== X-CSE-MsgGUID: 6qiSFYgkSkWDqMjPA1mq8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,167,1719903600"; d="scan'208";a="61179655" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmviesa006.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 22 Aug 2024 09:50:48 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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, 22 Aug 2024 09:50:47 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 22 Aug 2024 09:50:47 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) 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, 22 Aug 2024 09:50:47 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.176) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 22 Aug 2024 09:50:47 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RGhrsBs3ufP8urYPHF8z/p/o8v/b1KjkJW4WTzrOoZqy+YGY9+1nXHO6coptuZxRSefo9yaNUiwJeav13Yhm20nNO2UznG3G4Rnn6IUFWjpDlm+oU6OKej+MXn4/cxrGYzbVcZfL7ywh73OTtCfH9/yWT9udI0O3zrTC/3iQHdI/KhoydcgxRbJfs1EN2dyuW6QbH+pCEP7U50r/I5Zw06Qt8+uaHXwvOHcPK/QdwnnR8o1KPFRPkyWI7m7YSBdyvH1+3LmCvor7MqKxWJQWgnoWQd6I9YCyvuSdvyC0g9HlwVTj+EksrOIZuEKtTJfdHGeDvvVLLwPEh63QQcnJZw== 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=qT9AU95RcY5xV5g891Ysa1Bahu58CbRrYwdC0tMeU+I=; b=s/N8T0nQx0UvnUdS2xZSSmiGyWLLwQwqjS+gT9LRAH5QebZnN+236tlutoKMzW88smM6snUeaxEAFzxDMmAoQUv8Suvc6Pc6Blm0xMhKmgCt6Ih5iavllM93BErm1YmOQqQPXNb5nQGT7F6FbvgtTjM6RljgWokYPOpMTxXFi/FWvjsYDdjQKDnufHOEPZuGxssXSsKLN0MzB/HGq8x97sqoGZXVEzIWD90XOSFHSnSlYOqogrE7R4EIp0ET/Leithv9GrigPBgD6ck6Ws7vb9DMDs0re5THNeWdquJktTbs54nvJ80ntpuq7+bC6yZUHQ/aAMhFazQDloyp1jPXKw== 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 SA1PR11MB8375.namprd11.prod.outlook.com (2603:10b6:806:38b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Thu, 22 Aug 2024 16:50:44 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%2]) with mapi id 15.20.7897.014; Thu, 22 Aug 2024 16:50:44 +0000 Date: Thu, 22 Aug 2024 17:50:38 +0100 From: Bruce Richardson To: Praveen Shetty CC: , Subject: Re: [PATCH v2] net/cpfl: fix cpfl parser issue Message-ID: References: <20240730050952.837611-1-praveen.shetty@intel.com> <20240731072303.1119177-1-praveen.shetty@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240731072303.1119177-1-praveen.shetty@intel.com> X-ClientProxiedBy: DB3PR06CA0035.eurprd06.prod.outlook.com (2603:10a6:8:1::48) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|SA1PR11MB8375:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c1f902f-bd67-4a99-db06-08dcc2ca907d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xLGQwbSlEawdXOfovMRV1MurxE2S8kGY45G7O+5IrQUadQShouZ73r65C1HS?= =?us-ascii?Q?1t8xsIr85Ihby20lIJrMDNhXMRUrAOXtkuzgQ254q5JekrEErX9ndfBXeU+S?= =?us-ascii?Q?33UxfveK5dIFg7aLkGwNHQ+yUNWM451NvAA8U2+C0tsO972gGIG9dn2lwD86?= =?us-ascii?Q?St+qlhApagUwGkaTacYLgN4f91/LcfKnp1+yrQiIqHGQONnA4WzLSNC/2R2w?= =?us-ascii?Q?qB/nRJCqzyaSBhdzpjCx2AvPeRzOdZvrnfZVlQybO7G4NoJ34lCeQYzsEtTg?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maAKXTw9K7Gem/soY1?= =?us-ascii?Q?p589060kIagwvT8mfsCu64kPSd19dTZwJm+Sk7lPYFGVr9NGJNraFLwUeAps?= =?us-ascii?Q?y9LYWBWakT6/6HFxI3lobssU4xesso8PlUFhoxDeMiOPOgydM8pGGa+/OfTY?= =?us-ascii?Q?V3EUxG1h51b71zTa+fTl92QdYsae/FIqV+hiEVUkSGtGVQ=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)(1800799024)(376014)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?3sEjTHkKKAL+rKtAfto+rjoUPoXgZI47pwxU+/7oUxjluKgHNHw8kjsSdEfn?= =?us-ascii?Q?79esLG6jPAXUEGJ9daZ8t2iOCKxx+Xculi8F2RIAHQrf2YTiaQ8Af2SXuU19?= =?us-ascii?Q?9QcpzNwFZEqGx6cSEsNtfLaTMGrkpFpGb71G0c9zKan29x2PFJ7tNtmeFOtX?= =?us-ascii?Q?07KeCTV0BkhTvfFuFgk++c/rbG6hPBHVWU2/RZN2TCKnZI6XAntCZRTaQRbu?= =?us-ascii?Q?PJhWoBI06WssoiVF3wu52ZpgDCrncYh4/VTyI+n3sxyAuvOiM1COVM0T0XIA?= =?us-ascii?Q?QX5jSFGz2qxg7mwaxIumaZEqNk0ZhxRdStlFcGejeNcMaIthgJ+9YRiuyeu0?= =?us-ascii?Q?tKR7Ap3omLdKUbYxzKWutwh3Cv7+XG4OmFO3W2RmFQsdN+QJaS6LEpYZ7uEw?= =?us-ascii?Q?tvmpikziVWEx/TdsmAGbEhf8OqdhfmMrXfOE+IWHE4swwFgkHlc35qZtpqpi?= =?us-ascii?Q?6rrUfeT3EMiai1egQL5FmruJNo4XkkjHn81MuUu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SKfkrOrskzuSM6uQGR+SIZcsGH8jnep67VKIltCQOr7bg3r88BTh9r0V?= =?us-ascii?Q?N4SOKwnXSDhvjjSZOwlXuA3CC1oNR9X5nNUzgg6SCpNUTNfc6j3k86OsuO3i?= =?us-ascii?Q?7mI/c+73A50kueYeHW1Nl1GIaPHg9O9HVylc5uAFxMh7iS+iCMLsScpt36JU?= =?us-ascii?Q?O3JyekHi7Jn2ThdAfkBIMfkjWwqNbZi2eC8E4ShDqK8slWbG3JE6TG5TWhVw?= =?us-ascii?Q?5Q=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5c1f902f-bd67-4a99-db06-08dcc2ca907d X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 16:50:44.5205 (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: Z7W+KvoDLLz5THX/uR8tROQuGr5bSSk9PGFH/Ap9wV4Ps5xfAlRdQaKmn/5yisS0BBvucNfeES2sA3pe4x/TTj6bwuybpw3b1Io19dQOyeY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB8375 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 Wed, Jul 31, 2024 at 07:23:03AM +0000, Praveen Shetty wrote: > CPFL parser was incorrectly parsing the mask value of the > next_proto_id field from recipe.json file as a string > instead of unsigned integer. > > Fixes: 41f20298ee8c ("net/cpfl: parse flow offloading hint from JSON") > Cc: stable@dpdk.org > > Signed-off-by: Praveen Shetty > > --- > v2: > * Fixed CI issues. > --- > drivers/net/cpfl/cpfl_flow_parser.c | 34 +++++++++++++++++++---------- > 1 file changed, 22 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/cpfl/cpfl_flow_parser.c b/drivers/net/cpfl/cpfl_flow_parser.c > index 40569ddc6f..7800ad97ea 100644 > --- a/drivers/net/cpfl/cpfl_flow_parser.c > +++ b/drivers/net/cpfl/cpfl_flow_parser.c > @@ -198,6 +198,8 @@ cpfl_flow_js_pattern_key_proto_field(json_t *ob_fields, > for (i = 0; i < len; i++) { > json_t *object; > const char *name, *mask; > + uint32_t mask_32b = 0; > + int ret; > > object = json_array_get(ob_fields, i); > name = cpfl_json_t_to_string(object, "name"); > @@ -213,20 +215,28 @@ cpfl_flow_js_pattern_key_proto_field(json_t *ob_fields, > > if (js_field->type == RTE_FLOW_ITEM_TYPE_ETH || > js_field->type == RTE_FLOW_ITEM_TYPE_IPV4) { > - mask = cpfl_json_t_to_string(object, "mask"); > - if (!mask) { > - PMD_DRV_LOG(ERR, "Can not parse string 'mask'."); > - goto err; > - } > - if (strlen(mask) > CPFL_JS_STR_SIZE - 1) { > - PMD_DRV_LOG(ERR, "The 'mask' is too long."); > - goto err; > + /* Added a check for parsing mask value of the next_proto_id field. */ > + if (strcmp(name, "next_proto_id") == 0) { > + ret = cpfl_json_t_to_uint32(object, "mask", &mask_32b); > + if (ret < 0) { > + PMD_DRV_LOG(ERR, "Cannot parse uint32 'mask'."); > + goto err; > + } > + js_field->fields[i].mask_32b = mask_32b; > + } else { > + mask = cpfl_json_t_to_string(object, "mask"); > + if (!mask) { > + PMD_DRV_LOG(ERR, "Can not parse string 'mask'."); > + goto err; > + } > + if (strlen(mask) > CPFL_JS_STR_SIZE - 1) { > + PMD_DRV_LOG(ERR, "The 'mask' is too long."); > + goto err; > + } > + rte_strscpy(js_field->fields[i].mask, mask, CPFL_JS_STR_SIZE - 1); +1 for replacing strncpy with something safer, since original code is wrong and can leave a non-null-terminated string, but unfortunately the copy here isn't quite right. For strlcpy and rte_strscpy, you specify the exact buffer size, not the size-1. Also, you don't need to check the length and then do the copy, you might as well just do the copy using strscpy or strlcpy and check the return value from it. Saves iterating the string twice (once for length, second time for copy). For example: if (rte_strscpy(js_field->fields[i].mask, mask, CPFL_JS_STR_SIZE) < 0) { PMD_DRV_LOG(ERR, "The 'mask' is too long."); goto err; } Regards, /Bruce