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 BDBA645E41 for ; Sat, 7 Dec 2024 09:04:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B569C40281; Sat, 7 Dec 2024 09:04:49 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2068.outbound.protection.outlook.com [40.107.236.68]) by mails.dpdk.org (Postfix) with ESMTP id B49ED40E7C for ; Sat, 7 Dec 2024 09:04:47 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q8X206rAgaKzdXVyqe4goKLoyVgLZdUkgP3bdOxe8NaW4I17lzFUWYDT1jTW2bF20ehF0R5Yhm4ZsaGAJYNYniaNCsvDVfl40qmeu5dMLISFavM4DNfdqShNYVpwRDigy655O/yDkS4JNmEeL3asAUR/CXDw4DpR7guvLFJhzlv1GZap2BOnU++SCoinyyZFrCOsr7sRV7Nz4SP5+F9LPQ2HE8ofaxs/KES7KGTN0ERp2Bxuqfg5JLMBgz3W2eh3Yca+j2nM4KF89g2RGT/3vcEvw++OkZbcMijRttyw8+DXT6YTBejh2OorRx+9/tVboIn0LSBIrKIRgG9PYJWBfg== 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=ZBj6C98x2k6S4kDa1vD+cWB+XkVeXrncx7VN5s71Up0=; b=O12cGnLjQtge8DG51bmuOvTHidIXWeTpAmKk0yrfiSgZ4aMuecTBm+vrfEiYW4mrp+8H7NG4Ci1op3DvKnUELz2HvuOUZgm4wvc05eN7nj8unz0nQ6oC3lAk86d+dhs9GzUa9+iWOye1xV03B5wQZwYwe5Rl/NLTArlVhDCnkZhqcXh0L8SgMb329D6erq8NAgfcIKXkZUZeMGDTbeX5YrV6qFU+jx1e4Tvbm1+5L1JmN34OuVn2oFfGx2gXeM7ARQU07wm7tKQ547W8j346r2e07CvwVRrJ77rZSNE2eySbSv96OVxFkOa50Vp5wsYpvHlL4sIoW6vEmZuFwOXAuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=smartsharesystems.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=ZBj6C98x2k6S4kDa1vD+cWB+XkVeXrncx7VN5s71Up0=; b=I3U/eWTSpLaShCiiYPapAV+75Y2pq/0tO9yX2bjYryahzrK/yO50xpX7H06yRbfSxt67tv3tO2U/FK+AL3bOgCBVqemaUq/UxqLdNaLxllSOx5jA0cuu5Lpyzz0VD1sCivjB85xqMqN4D30OqFNdBcC2d97ceCTUBwtZmhFWcLGUS7AawwOxLcPs6bUDpbM529YgKsJyuKiwTqtDWe2+uhULxuK43QfImavPTOEVXr5khxhykbJFhHk6cPqpqu5WgUBsobMI8XIg5q9XFuzk0VvUgC5BeUd50ub3oleNSPzwv6INQcSCCXTs3f7O6lNgzpKeC6Bl3k31RnPAtPl0eA== Received: from BY3PR10CA0008.namprd10.prod.outlook.com (2603:10b6:a03:255::13) by SN7PR12MB7107.namprd12.prod.outlook.com (2603:10b6:806:2a2::16) 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:04:41 +0000 Received: from SJ1PEPF00001CE0.namprd05.prod.outlook.com (2603:10b6:a03:255:cafe::65) by BY3PR10CA0008.outlook.office365.com (2603:10b6:a03:255::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.12 via Frontend Transport; Sat, 7 Dec 2024 08:04:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ1PEPF00001CE0.mail.protection.outlook.com (10.167.242.8) 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:04:40 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) 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:04:35 -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:04:33 -0800 From: Xueming Li To: =?UTF-8?q?Morten=20Br=C3=B8rup?= CC: Xueming Li , Ferruh Yigit , dpdk stable Subject: patch 'net/vmxnet3: fix potential out of bounds stats access' has been queued to stable release 23.11.3 Date: Sat, 7 Dec 2024 15:59:57 +0800 Message-ID: <20241207080055.488538-40-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-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit 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: SJ1PEPF00001CE0:EE_|SN7PR12MB7107:EE_ X-MS-Office365-Filtering-Correlation-Id: 69d8e00a-188f-49b0-774d-08dd1695cd77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|376014|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?dnJ3Tk1wZ1BtbGM0OFZnT2pzMFVMTCtiNnFHYVp0TVA5THF5RXEzZlNEdkJh?= =?utf-8?B?Y0FIbzRFNHptVWQ5SWRQaVhKZVhvM0R4NktMV21oOGpSRlVaakF5RTY3dHhk?= =?utf-8?B?NkdmaXNXYjJvUHFHUmVERU12ZjlBaE9IWUgxNEg5TmFoRmd5ZjdtbkRWcHRt?= =?utf-8?B?a3NrOE43dERicnRYVDN4em1ZWnZHS0xRcnQxakxYRWVtS1lqRWxqS2w0eFRQ?= =?utf-8?B?UWFDM1F1Qlc0Vk0yK3l5UHM0eFRXZE1Kd21QaW9mVkZNYUk2aXA0Z29QdGhz?= =?utf-8?B?YkdrNjEwNWdUcmtIN2lES1pjckQ1UE95YmxIUnBVNGtRMER5ZGJhbmlWaksz?= =?utf-8?B?VzNwa201UjNmc0t4YSsxWEZCMW9OK3FRVy85SG0xcy9EZEV2bGQvUk9Ga0dU?= =?utf-8?B?ZExwLzVXd2dORElwTEl3enFEb3Nhck9pSUp5cTBQeTExM1JnbWVST1MxRDRh?= =?utf-8?B?MDJ5ZXNiSWpCUWR3eEhkUlZkN2JjOVR3WE12ZnhEVTZoZVZzR2dmWGJuSWs0?= =?utf-8?B?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=?utf-8?B?Tm1zK1Z6M2dQa0pBSG1tQmQ2TVRSVHdwR3ZLOHZLWUs1c05zQ1RWR1QwYnk2?= =?utf-8?B?eWVuSDR6RnMxN0hMNnB5eWk2bW8zMUJURVlNTHZiNU1FR1VwRHJIN0xzNmM3?= =?utf-8?B?UE5DU1h5a2hCdU0vYWhYcmREVzA4QWF0ZUhkdmpwblozQ0lnMEoxNHJTOENw?= =?utf-8?B?UTc5VWEvZFp1bHRLcm91VzVlWks1SU1QbHdiRlVCb0pGanJZSjlRNysrS2RW?= =?utf-8?B?NTJjU1AxNFkwZ3NiY3o3VjJBRzI0c2NMallwSXhQL3krN1JkK3RlZ25pSVdu?= =?utf-8?B?elJBSjhzYnpGczdJN3lvS2RTWFhsZjNEZ0syaFVFZXlDTnZEcE1Uei9ZZzNE?= =?utf-8?B?a3lZTUJTb01YaExCZ3d3SUp1THRQb3IrRW9TbWtKYnMxQ00vZFVNVWNXeG5R?= =?utf-8?B?NTFkbk4vcWdjQ0pFTEU1RzJnWlNDaWtNWWJWM3pjOXFRdkFjZzQ5Rmswc3Ew?= =?utf-8?Q?aS2I9AGf5x1wjoVm3cMjNz6dzJA1pOrv?= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014)(7053199007); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2024 08:04:40.8950 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69d8e00a-188f-49b0-774d-08dd1695cd77 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00001CE0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7107 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=6a832ea8eef5041729951f20c670daaedfd29171 Thanks. Xueming Li --- >From 6a832ea8eef5041729951f20c670daaedfd29171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Br=C3=B8rup?= Date: Mon, 4 Nov 2024 10:52:19 +0000 Subject: [PATCH] net/vmxnet3: fix potential out of bounds stats access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Xueming Li [ upstream commit d3a229dd493abcb29d5717c5ce37e0a0bc1777c4 ] With virtual hardware version 6, the max number of RX queues was increased to VMXNET3_EXT_MAX_RX_QUEUES (32) from VMXNET3_MAX_RX_QUEUES (16), similarly, the max number of TX queues was increased to VMXNET3_EXT_MAX_TX_QUEUES (32) from VMXNET3_MAX_TX_QUEUES (8). These increases were not fully considered in the PMD... The configured number of queues to provide statistics for (RTE_ETHDEV_QUEUE_STAT_CNTRS) can be smaller than driver's max number of supported transmit queues for virtual hardware version 6 (VMXNET3_EXT_MAX_RX_QUEUES) (32), which will cause accessing the queue stats array out of boundary if the application uses more than RTE_ETHDEV_QUEUE_STAT_CNTRS queues. This patch fixes this by two modifications - Increased stats array size to support hardware version 6. - Respect RTE_ETHDEV_QUEUE_STAT_CNTRS when getting the per-queue counters. The build time check RTE_BUILD_BUG_ON(RTE_ETHDEV_QUEUE_STAT_CNTRS < VMXNET3_MAX_TX_QUEUES) has become irrelevant, so it is removed. With this removal, per-queue stats for fewer queues is supported. Fixes: b1584dd0affe ("net/vmxnet3: support version 6") Signed-off-by: Morten Brørup Acked-by: Ferruh Yigit --- drivers/net/vmxnet3/vmxnet3_ethdev.c | 32 +++++++++++++++++----------- drivers/net/vmxnet3/vmxnet3_ethdev.h | 4 ++-- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 082ae17465..e60935f835 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -1470,42 +1470,52 @@ vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) struct vmxnet3_hw *hw = dev->data->dev_private; struct UPT1_TxStats txStats; struct UPT1_RxStats rxStats; + uint64_t packets, bytes; VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS); for (i = 0; i < hw->num_tx_queues; i++) { vmxnet3_tx_stats_get(hw, i, &txStats); - stats->q_opackets[i] = txStats.ucastPktsTxOK + + packets = txStats.ucastPktsTxOK + txStats.mcastPktsTxOK + txStats.bcastPktsTxOK; - stats->q_obytes[i] = txStats.ucastBytesTxOK + + bytes = txStats.ucastBytesTxOK + txStats.mcastBytesTxOK + txStats.bcastBytesTxOK; - stats->opackets += stats->q_opackets[i]; - stats->obytes += stats->q_obytes[i]; + stats->opackets += packets; + stats->obytes += bytes; stats->oerrors += txStats.pktsTxError + txStats.pktsTxDiscard; + + if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) { + stats->q_opackets[i] = packets; + stats->q_obytes[i] = bytes; + } } for (i = 0; i < hw->num_rx_queues; i++) { vmxnet3_rx_stats_get(hw, i, &rxStats); - stats->q_ipackets[i] = rxStats.ucastPktsRxOK + + packets = rxStats.ucastPktsRxOK + rxStats.mcastPktsRxOK + rxStats.bcastPktsRxOK; - stats->q_ibytes[i] = rxStats.ucastBytesRxOK + + bytes = rxStats.ucastBytesRxOK + rxStats.mcastBytesRxOK + rxStats.bcastBytesRxOK; - stats->ipackets += stats->q_ipackets[i]; - stats->ibytes += stats->q_ibytes[i]; - - stats->q_errors[i] = rxStats.pktsRxError; + stats->ipackets += packets; + stats->ibytes += bytes; stats->ierrors += rxStats.pktsRxError; stats->imissed += rxStats.pktsRxOutOfBuf; + + if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) { + stats->q_ipackets[i] = packets; + stats->q_ibytes[i] = bytes; + stats->q_errors[i] = rxStats.pktsRxError; + } } return 0; @@ -1521,8 +1531,6 @@ vmxnet3_dev_stats_reset(struct rte_eth_dev *dev) VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS); - RTE_BUILD_BUG_ON(RTE_ETHDEV_QUEUE_STAT_CNTRS < VMXNET3_MAX_TX_QUEUES); - for (i = 0; i < hw->num_tx_queues; i++) { vmxnet3_hw_tx_stats_get(hw, i, &txStats); memcpy(&hw->snapshot_tx_stats[i], &txStats, diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.h b/drivers/net/vmxnet3/vmxnet3_ethdev.h index 2b3e2c4caa..e9ded6663d 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.h +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.h @@ -121,8 +121,8 @@ struct vmxnet3_hw { #define VMXNET3_VFT_TABLE_SIZE (VMXNET3_VFT_SIZE * sizeof(uint32_t)) UPT1_TxStats saved_tx_stats[VMXNET3_EXT_MAX_TX_QUEUES]; UPT1_RxStats saved_rx_stats[VMXNET3_EXT_MAX_RX_QUEUES]; - UPT1_TxStats snapshot_tx_stats[VMXNET3_MAX_TX_QUEUES]; - UPT1_RxStats snapshot_rx_stats[VMXNET3_MAX_RX_QUEUES]; + UPT1_TxStats snapshot_tx_stats[VMXNET3_EXT_MAX_TX_QUEUES]; + UPT1_RxStats snapshot_rx_stats[VMXNET3_EXT_MAX_RX_QUEUES]; uint16_t tx_prod_offset; uint16_t rx_prod_offset[2]; /* device capability bit map */ -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-12-06 23:26:45.410171111 +0800 +++ 0039-net-vmxnet3-fix-potential-out-of-bounds-stats-access.patch 2024-12-06 23:26:43.933044828 +0800 @@ -1 +1 @@ -From d3a229dd493abcb29d5717c5ce37e0a0bc1777c4 Mon Sep 17 00:00:00 2001 +From 6a832ea8eef5041729951f20c670daaedfd29171 Mon Sep 17 00:00:00 2001 @@ -7,0 +8,3 @@ +Cc: Xueming Li + +[ upstream commit d3a229dd493abcb29d5717c5ce37e0a0bc1777c4 ] @@ -33 +35,0 @@ -Cc: stable@dpdk.org @@ -43 +45 @@ -index 79ab167421..619cfa21cf 100644 +index 082ae17465..e60935f835 100644 @@ -46 +48 @@ -@@ -1471,42 +1471,52 @@ vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) +@@ -1470,42 +1470,52 @@ vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) @@ -109 +111 @@ -@@ -1522,8 +1532,6 @@ vmxnet3_dev_stats_reset(struct rte_eth_dev *dev) +@@ -1521,8 +1531,6 @@ vmxnet3_dev_stats_reset(struct rte_eth_dev *dev)