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 957A645CE3 for ; Mon, 11 Nov 2024 07:37:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E7594067A; Mon, 11 Nov 2024 07:37:47 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2075.outbound.protection.outlook.com [40.107.223.75]) by mails.dpdk.org (Postfix) with ESMTP id 9A2BC40E2D for ; Mon, 11 Nov 2024 07:37:45 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Inu53p8IjxrpSSouUr2X7hUv7gfPknPM9HVdfH+4DdXj6CRPNQJyNwBvYFS2OjK/T1n1jAgDdFeEXZL1yRJKk0ePYVMce7BjuFtn/2ThskwJpPQvfix24ncOsltFtSZx+Ps0H2XrCloND83zwhteDFs/o5Bch98zw7HtkdmDgQRzhY+kBHtbRilcSX4UGIInlMbAdPtsrjO8x8/ycSahoPsvlTEfQjE7s/6ob6Cp76zq1Ldboe//xCCiFfbMcusLu9NCeL5Wb6TIRytbyGXPmrnf0LVXvilg+koCWfXyIdaaFayvbgYeNStU4Ezyw2yJdzXRqROghUo3sPpgzxLyMg== 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=Ep/ofEB2FLoMQX98luLBVxniV6siLUCq1phgprSp6Uo=; b=hPyBjUbxL2UdkYb4u93FCPIlFfJxTHtNgIoN/p6dhMQeh5w5UdgXO9Vo0RuwtoP/xeBnnv48dO2Zrqm14Q97oreTAKendKiakfVLdDMF8K1cJCkJhQGDAyFVxg1kRERbbo+Da+wLOLpHKGvquKi2GMAcwGwVlowktiqFCt1MOZS5wos7SkU1aiZ9/6vp/tmcpv32mOlG3nq86nazxEHQJBVooqZ6XMLgtG1KYjRFfOLd03Ve7f7nDlzRTj8J5zohLKcPbP5lTsiOPR0vq4ZuzoMov0IsK2iyMqEzuYBhzqEF1QD4bdgRhlOex+wvK0O2e59cljecAwZUYpxZKrYWQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=intel.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=Ep/ofEB2FLoMQX98luLBVxniV6siLUCq1phgprSp6Uo=; b=SvImaTJh7lmH/deqR+736A/Tqct1ajNV3vcfW9wZAx6rbb58inrvxrHm/Mfu07rJL25Tm5DNZwHcILhzDyfwcT2lMuohUJA0C1kZld6nZ9vyrEb9GNDAokAdzlUd+xyPBPnVVuxkBNwP4LhSpVsv3RApRThtik45zj36F4Hfp45jDnP9t5wb2XZcUKToyJXqIK3AltnQlIL+H31Pex66hjbvHiIW1F8oBOCR51vju7wAnvmcTZ6byfGNT4FYAzMURzLF3QegIfqO/98mQtJznUxw1kAvkY5ETnYenTGhFUT1tamloipOXMFL+uUxCJ1XXUazlSFYNBF+TmenswpBIw== Received: from BLAPR03CA0175.namprd03.prod.outlook.com (2603:10b6:208:32f::14) by MN2PR12MB4422.namprd12.prod.outlook.com (2603:10b6:208:265::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Mon, 11 Nov 2024 06:37:42 +0000 Received: from BN2PEPF000044A7.namprd04.prod.outlook.com (2603:10b6:208:32f:cafe::8a) by BLAPR03CA0175.outlook.office365.com (2603:10b6:208:32f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28 via Frontend Transport; Mon, 11 Nov 2024 06:37:42 +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 BN2PEPF000044A7.mail.protection.outlook.com (10.167.243.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 11 Nov 2024 06:37:42 +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; Sun, 10 Nov 2024 22:37:26 -0800 Received: from nvidia.com (10.126.230.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; Sun, 10 Nov 2024 22:37:23 -0800 From: Xueming Li To: Niall Meade CC: , Ferruh Yigit , dpdk stable Subject: patch 'ethdev: fix overflow in descriptor count' has been queued to stable release 23.11.3 Date: Mon, 11 Nov 2024 14:28:08 +0800 Message-ID: <20241111062847.216344-83-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241111062847.216344-1-xuemingl@nvidia.com> References: <20241111062847.216344-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A7:EE_|MN2PR12MB4422:EE_ X-MS-Office365-Filtering-Correlation-Id: 3bf1c6f9-6b49-4694-1c6c-08dd021b583d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?MsKiwzDoUVJ8h2bJ3jbC4VYfGqnTnzriV/3p480iVSfNykJrE93pLUIKDjM2?= =?us-ascii?Q?cLpnRmJhQwXv0xMCEo6TBjfTgvHKMG+NugDlrqduLmuwMXyAJ6CHZ1/jyZVL?= =?us-ascii?Q?2NNtksBLxMSt5HhTsP2qysfSrCuI4ge5WeIZvoQ6qhkTJjWIJEBGLaNM5Fz4?= =?us-ascii?Q?4CZ8bZQhJJTz5ed/vH73HThGMge0cp+pwa/Xna+We8zwYDte8Zw1MbkrjFUT?= =?us-ascii?Q?BCRBJt1xqvYYDsdcmKt8+LODuJT3SBjFpbVlYsrs6wRBGqtrujjeOmhYtuFg?= =?us-ascii?Q?wd6Wb8I0rwc3ro2//RNJyJoaBENE9ph4tsxOpC27XdVMeNBPdMCo8gnxDaan?= =?us-ascii?Q?QB5O78nDOrjvmhSQlCCGu2MdyWgQ7nxh3/c/M6t72yd2hAhm6BOy/BhSpapD?= =?us-ascii?Q?VZ7PYH33+EvEos3A/XZu9a+b8iUV+bwlcwv8y18AxTgLcrMuUa1CMGeBNK6e?= =?us-ascii?Q?3O5DXuOl6npSQr47cOXGEYbsq8C/2LK7xSIMA8luPATCjjUqexlT1YfXgs1L?= =?us-ascii?Q?Wp9rGyUWXk8vMErO7H1syt19CRrw0/lYDSJw59G5OrRlRuOLRHEhoFkQjwZm?= =?us-ascii?Q?Bj+DRJvtT+wQTeG8KEsLJnUN+2TBjcGMgFNrO1RX42CeGuA1NwltcmFu2j4N?= =?us-ascii?Q?AMHNT/KH545Snyxo6vok9yNl3HgFHDSKPp/ZKl9PoHHWRRsSkd5jugaYwSWp?= =?us-ascii?Q?agoVhW1t4GTsaYtB6wmZxBZNJcWQ058gMtkzhK9SK+JLhUohc5rkqDsJebXD?= =?us-ascii?Q?eJb6mhU1pxUlDmRv/nnl8+TCtdgbUaYUlnTuXgGNYubkekwVN5lVjFO/gmAE?= =?us-ascii?Q?GK4OnO8fMwx1wC5nFXVdOTUznusybi8GEeyvIaxTqESICGtfsqH4OMCj+hxd?= =?us-ascii?Q?KMqCH8xh2QaPWoe9qevpf2etzrCOMBdDqNL+H2/9ovHG2HtHuyegcbW639F6?= =?us-ascii?Q?hh5WlITX3nF8SKtqBVBUGm4xz698FEMAeX/KBeoJRqNZYs54fVKCkbuUmCtl?= =?us-ascii?Q?0Ys5nE4GPiC3oZT8Ev2kJuBzBOSBNH2zSXkMiV8dgELDdJ2fGcaDVw12E3kg?= =?us-ascii?Q?adYECJn6nnkf6HgezEeGhz7e9OoNey9Hf7a8yaVMwXMto0diRdZKNw91Vk+0?= =?us-ascii?Q?gOIDLQiBxSffhosnrqZflKeBLbdPrFsPysLIU9HrTSW0lStHVQ7pctHETG0d?= =?us-ascii?Q?8s7p2lhJfQD3rU1a0Zfu4rUzNtQaT3e4DHguPAUqdbbmp9vWlenN5h83hzr2?= =?us-ascii?Q?Onu9y7oIoIbaUL8V4W4/E6MefvE0bM/jTlPdn1phDFRbR6p0/ShouIQZs7Sv?= =?us-ascii?Q?kGWjZyBOYFi2eAl7WiWDpfgtNJ3h18GKfv+TA2mZu6qxEkVDAFclORQwVWCw?= =?us-ascii?Q?uLxnSJTx5Y7NmNgjeBcHi0L+/Ka5nVBdaNIVhP94W0gYDyzv5Q=3D=3D?= 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); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 06:37:42.1750 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3bf1c6f9-6b49-4694-1c6c-08dd021b583d 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: BN2PEPF000044A7.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4422 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 11/30/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=c795236ed2bc295e4ff8c8d8eafcf81f2b96c6dd Thanks. Xueming Li --- >From c795236ed2bc295e4ff8c8d8eafcf81f2b96c6dd Mon Sep 17 00:00:00 2001 From: Niall Meade Date: Mon, 30 Sep 2024 13:40:02 +0000 Subject: [PATCH] ethdev: fix overflow in descriptor count Cc: Xueming Li [ upstream commit 30efe60d3a37896567b660229ef6a04c5526f6db ] Addressed a specific overflow issue in the eth_dev_adjust_nb_desc() function where the uint16_t variable nb_desc would overflow when its value was greater than (2^16 - nb_align). This overflow caused nb_desc to incorrectly wrap around between 0 and nb_align-1, leading to the function setting nb_desc to nb_min instead of the expected nb_max. To give an example, let nb_desc=UINT16_MAX, nb_align=32, nb_max=4096 and nb_min=64. RTE_ALIGN_CEIL(nb_desc, nb_align) calls RTE_ALIGN_FLOOR(nb_desc + nb_align - 1, nb_align). This results in an overflow of nb_desc, leading to nb_desc being set to 30 and then 0 when the macros return. As a result of this, nb_desc is then set to nb_min later on. The resolution involves upcasting nb_desc to a uint32_t before the RTE_ALIGN_CEIL macro is applied. This change ensures that the subsequent call to RTE_ALIGN_FLOOR(nb_desc + (nb_align - 1), nb_align) does not result in an overflow, as it would when nb_desc is a uint16_t. By using a uint32_t for these operations, the correct behavior is maintained without the risk of overflow. Fixes: 0f67fc3baeb9 ("ethdev: add function to adjust number of descriptors") Signed-off-by: Niall Meade Reviewed-by: Ferruh Yigit --- .mailmap | 1 + lib/ethdev/rte_ethdev.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.mailmap b/.mailmap index 5f2593e00e..674384cfc5 100644 --- a/.mailmap +++ b/.mailmap @@ -1029,6 +1029,7 @@ Nelson Escobar Nemanja Marjanovic Netanel Belgazal Netanel Gonen +Niall Meade Niall Power Nicholas Pratte Nick Connolly diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index b9d99ece15..1f067873a9 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6556,13 +6556,19 @@ static void eth_dev_adjust_nb_desc(uint16_t *nb_desc, const struct rte_eth_desc_lim *desc_lim) { + /* Upcast to uint32 to avoid potential overflow with RTE_ALIGN_CEIL(). */ + uint32_t nb_desc_32 = (uint32_t)*nb_desc; + if (desc_lim->nb_align != 0) - *nb_desc = RTE_ALIGN_CEIL(*nb_desc, desc_lim->nb_align); + nb_desc_32 = RTE_ALIGN_CEIL(nb_desc_32, desc_lim->nb_align); if (desc_lim->nb_max != 0) - *nb_desc = RTE_MIN(*nb_desc, desc_lim->nb_max); + nb_desc_32 = RTE_MIN(nb_desc_32, desc_lim->nb_max); + + nb_desc_32 = RTE_MAX(nb_desc_32, desc_lim->nb_min); - *nb_desc = RTE_MAX(*nb_desc, desc_lim->nb_min); + /* Assign clipped u32 back to u16. */ + *nb_desc = (uint16_t)nb_desc_32; } int -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-11-11 14:23:08.921019263 +0800 +++ 0082-ethdev-fix-overflow-in-descriptor-count.patch 2024-11-11 14:23:05.212192838 +0800 @@ -1 +1 @@ -From 30efe60d3a37896567b660229ef6a04c5526f6db Mon Sep 17 00:00:00 2001 +From c795236ed2bc295e4ff8c8d8eafcf81f2b96c6dd Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 30efe60d3a37896567b660229ef6a04c5526f6db ] @@ -27 +29,0 @@ -Cc: stable@dpdk.org @@ -37 +39 @@ -index d49838320e..6e72362ebc 100644 +index 5f2593e00e..674384cfc5 100644 @@ -40 +42 @@ -@@ -1070,6 +1070,7 @@ Nelson Escobar +@@ -1029,6 +1029,7 @@ Nelson Escobar @@ -49 +51 @@ -index a1f7efa913..84ee7588fc 100644 +index b9d99ece15..1f067873a9 100644 @@ -52 +54 @@ -@@ -6667,13 +6667,19 @@ static void +@@ -6556,13 +6556,19 @@ static void