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 CD67245E41 for ; Sat, 7 Dec 2024 09:03:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C571340281; Sat, 7 Dec 2024 09:03:36 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2042.outbound.protection.outlook.com [40.107.220.42]) by mails.dpdk.org (Postfix) with ESMTP id 491CD40281 for ; Sat, 7 Dec 2024 09:03:35 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ntt7/n3ThRofTc0LNDP2Q9gzQx2+ts9/yZiffBQBs0yW+ZVIRurgB+lACSafvq7MdnPF9sAi1wbjEATFBUyCsfh/L/pOOQelApbYkW9haXpB+cBZDWU9h7YcOShNtAXcPgyXxAKicnmDqdE3pJQpyVjJqQIIkoNTp5PaLixSEmxU6jnFTYCYdqEB+5pyslZj8Uka3gR7sAasWjsMdDpGbKJ66IU2VEd0TlAWmpalFSErxV56/ol6scAXEkcDfLwz9QLuwR8qP0TiDOMSI3OACUEziEFnFfR77T3pXw56zM/ZgVmQ89BDTQ8q/k/ggS7oD2B4Ibu3W4Ql4GH1Uqm9DA== 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=1g3txjo0gxkDI+Nn1MODIM1BAoKtg7zOjdfr0vffmQE=; b=cvMksZqHe/ew9zLUN+wGWRImxe2rfAKUtTwJzGIRLWfZWAR9YgPiPZnQzyklrDT9QSgHRJGW8FxqBACCo69zBCfurusELs57xRQoljwefbt8OIqP/q504FWwfo+6NCqkTnjioD/0TS9OpbCAlLmGUfP7em+oUCQSOlwCEoGyGn2hsmvXClFPuGrm/ILd/84OWUksMzduSd9isPz5wF/l8kHfFBweGSUQ5ylOFHBWS6Ja7W+ABzSJCYt+P5zXNbhODOG7gCpfYlUB7njoGfDksHulX7AifqyhrAbOERpWfRH9yNtyKuIlAWCeLaexu+FsUJmf9DBqVQJp5K9rkh8rrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=huawei.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1g3txjo0gxkDI+Nn1MODIM1BAoKtg7zOjdfr0vffmQE=; b=lK3+AmUtj7z/v3o4zrKkmeepmIZML2HxmTcWkp2MDFhgP5/h5W+WoUUKsdjgGQ0VkldpqKyy8g8QtQkJqS94XLC6GFZWgxZU/q7FLlKzwPV+hKH4qaMF1k0rSYreDeSHFZh3R41YesSwmREnC6biQR1EYejHi2mcU3kxc5jZHR6oUy6OTI7wXbqFpPjmhH4xskJCT1la7eygGHVrA1Q2todXXGJOhsby4XSq+OjHwI+1MacJcQ64Gje5AMNUUK4EHHv61ugC3aPIF3WTj004be2kfyaBxnxhQ93ET09CHhKyn/646JsAwY41ILIhYe5WpjwznnkHjW3V1dDrfTtyPg== Received: from DM6PR17CA0014.namprd17.prod.outlook.com (2603:10b6:5:1b3::27) by IA1PR12MB9063.namprd12.prod.outlook.com (2603:10b6:208:3a9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Sat, 7 Dec 2024 08:03:26 +0000 Received: from CY4PEPF0000E9D5.namprd05.prod.outlook.com (2603:10b6:5:1b3:cafe::83) by DM6PR17CA0014.outlook.office365.com (2603:10b6:5:1b3::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Sat, 7 Dec 2024 08:03:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000E9D5.mail.protection.outlook.com (10.167.241.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7 via Frontend Transport; Sat, 7 Dec 2024 08:03:25 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sat, 7 Dec 2024 00:03:14 -0800 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sat, 7 Dec 2024 00:03:12 -0800 From: Xueming Li To: Huisong Li CC: Xueming Li , Konstantin Ananyev , Chengwen Feng , Sivaprasad Tummala , dpdk stable Subject: patch 'examples/l3fwd-power: fix options parsing overflow' has been queued to stable release 23.11.3 Date: Sat, 7 Dec 2024 15:59:42 +0800 Message-ID: <20241207080055.488538-25-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241207080055.488538-1-xuemingl@nvidia.com> References: <20241111062847.216344-122-xuemingl@nvidia.com> <20241207080055.488538-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D5:EE_|IA1PR12MB9063:EE_ X-MS-Office365-Filtering-Correlation-Id: 97a48dc6-059b-411b-5173-08dd1695a0d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JsBrVo6momnwmeRIHtSvYKuU/LfVlpDWVs5I7EXPokOtudg0aa+oQP+ijER3?= =?us-ascii?Q?DqUnzuGioMEjXfYc7Qz5RQrYzKZwv3zI26AGT1FFTxt9hAnjWhuWSp3IJ/oN?= =?us-ascii?Q?gRcNspGtYLNVmChrq/ktS2vtx0g5+DT3ImqLLDCQ9oGTA2m47vFWd+REFHml?= =?us-ascii?Q?EXhDntEtfOgWZFTdwI23ELchiSgB2RJmT+nZnfxu0uupdGywaN5We00Xs714?= =?us-ascii?Q?Vv7BMsZ/3dAZWt3NvEV92nEthFbLibXJ46bk5vkoSReUlPiQFmyn63EDY4Bd?= =?us-ascii?Q?dJ2YqkAP8VBk7sWxWKBDr3noMg2hxrBAEHe3R1PUCJYBJtUbzxsVDwwl9bay?= =?us-ascii?Q?ceAAOmKmlh6CC6R4EFDOpoUTXUfV+5AW1eabIcj0qVhPV71o9RRkFvVNLNGp?= =?us-ascii?Q?y4O/jifopJs0vvG7QG5FJbDc0Q1caHNMBzRbHIz/H4FfxpN/GbNq4RTBylb/?= =?us-ascii?Q?eK5sd3VQ9VXeOJQmGTgk9BbkNKGOcfzo/Mm4pwZoLhOKnthG4osVMprqEVOx?= =?us-ascii?Q?5FhY8IKqVtGk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?= =?us-ascii?Q?zKekjtGs4Z8HA6LzR2kwrIhy4UHd9Hcl?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026)(7053199007); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2024 08:03:25.9854 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97a48dc6-059b-411b-5173-08dd1695a0d8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9063 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 23.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/10/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://git.dpdk.org/dpdk-stable/log/?h=23.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=d24b14e13169592f838b16a8ec12d6c37e1c537e Thanks. Xueming Li --- >From d24b14e13169592f838b16a8ec12d6c37e1c537e Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Mon, 11 Nov 2024 10:25:49 +0800 Subject: [PATCH] examples/l3fwd-power: fix options parsing overflow Cc: Xueming Li [ upstream commit 0bc4795d5994459a3d261afd7f843eb0cabdecf5 ] Many variables are 'uint32_t', like, 'pause_duration', 'scale_freq_min' and so on. They use parse_int() to parse it from command line. But overflow problem occurs when this function return. Fixes: 59f2853c4cae ("examples/l3fwd_power: add configuration options") Signed-off-by: Huisong Li Acked-by: Konstantin Ananyev Acked-by: Chengwen Feng Acked-by: Sivaprasad Tummala --- examples/l3fwd-power/main.c | 41 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 996ac6dc56..7640b5a9a3 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -1523,8 +1523,12 @@ print_usage(const char *prgname) prgname); } +/* + * Caller must give the right upper limit so as to ensure receiver variable + * doesn't overflow. + */ static int -parse_int(const char *opt) +parse_uint(const char *opt, uint32_t max, uint32_t *res) { char *end = NULL; unsigned long val; @@ -1534,23 +1538,15 @@ parse_int(const char *opt) if ((opt[0] == '\0') || (end == NULL) || (*end != '\0')) return -1; - return val; -} - -static int parse_max_pkt_len(const char *pktlen) -{ - char *end = NULL; - unsigned long len; - - /* parse decimal string */ - len = strtoul(pktlen, &end, 10); - if ((pktlen[0] == '\0') || (end == NULL) || (*end != '\0')) + if (val > max) { + RTE_LOG(ERR, L3FWD_POWER, "%s parameter shouldn't exceed %u.\n", + opt, max); return -1; + } - if (len == 0) - return -1; + *res = val; - return len; + return 0; } static int @@ -1897,8 +1893,9 @@ parse_args(int argc, char **argv) if (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_MAX_PKT_LEN, sizeof(CMD_LINE_OPT_MAX_PKT_LEN))) { + if (parse_uint(optarg, UINT32_MAX, &max_pkt_len) != 0) + return -1; printf("Custom frame size is configured\n"); - max_pkt_len = parse_max_pkt_len(optarg); } if (!strncmp(lgopts[option_index].name, @@ -1911,29 +1908,33 @@ parse_args(int argc, char **argv) if (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_MAX_EMPTY_POLLS, sizeof(CMD_LINE_OPT_MAX_EMPTY_POLLS))) { + if (parse_uint(optarg, UINT32_MAX, &max_empty_polls) != 0) + return -1; printf("Maximum empty polls configured\n"); - max_empty_polls = parse_int(optarg); } if (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_PAUSE_DURATION, sizeof(CMD_LINE_OPT_PAUSE_DURATION))) { + if (parse_uint(optarg, UINT32_MAX, &pause_duration) != 0) + return -1; printf("Pause duration configured\n"); - pause_duration = parse_int(optarg); } if (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_SCALE_FREQ_MIN, sizeof(CMD_LINE_OPT_SCALE_FREQ_MIN))) { + if (parse_uint(optarg, UINT32_MAX, &scale_freq_min) != 0) + return -1; printf("Scaling frequency minimum configured\n"); - scale_freq_min = parse_int(optarg); } if (!strncmp(lgopts[option_index].name, CMD_LINE_OPT_SCALE_FREQ_MAX, sizeof(CMD_LINE_OPT_SCALE_FREQ_MAX))) { + if (parse_uint(optarg, UINT32_MAX, &scale_freq_max) != 0) + return -1; printf("Scaling frequency maximum configured\n"); - scale_freq_max = parse_int(optarg); } break; -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-12-06 23:26:44.938557317 +0800 +++ 0024-examples-l3fwd-power-fix-options-parsing-overflow.patch 2024-12-06 23:26:43.903044828 +0800 @@ -1 +1 @@ -From 0bc4795d5994459a3d261afd7f843eb0cabdecf5 Mon Sep 17 00:00:00 2001 +From d24b14e13169592f838b16a8ec12d6c37e1c537e Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 0bc4795d5994459a3d261afd7f843eb0cabdecf5 ] @@ -11 +13,0 @@ -Cc: stable@dpdk.org @@ -22 +24 @@ -index 272e069207..7bc524aa16 100644 +index 996ac6dc56..7640b5a9a3 100644 @@ -25 +27 @@ -@@ -1520,8 +1520,12 @@ print_usage(const char *prgname) +@@ -1523,8 +1523,12 @@ print_usage(const char *prgname) @@ -39 +41 @@ -@@ -1531,23 +1535,15 @@ parse_int(const char *opt) +@@ -1534,23 +1538,15 @@ parse_int(const char *opt) @@ -69 +71 @@ -@@ -1894,8 +1890,9 @@ parse_args(int argc, char **argv) +@@ -1897,8 +1893,9 @@ parse_args(int argc, char **argv) @@ -80 +82 @@ -@@ -1908,29 +1905,33 @@ parse_args(int argc, char **argv) +@@ -1911,29 +1908,33 @@ parse_args(int argc, char **argv)