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 B260E43B7D for ; Tue, 5 Mar 2024 10:58:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ACD7442E46; Tue, 5 Mar 2024 10:58:22 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2050.outbound.protection.outlook.com [40.107.223.50]) by mails.dpdk.org (Postfix) with ESMTP id F00004026B for ; Tue, 5 Mar 2024 10:58:20 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L+Siyq3RKFDUjO+RFa/emaqBZLklfKate1cpHDwABMxVyrPa6RvPB5TrBDR33xyyraK04NKNjqslAS4zw+2EsQeyVTUtDYiQxyA5IVwixR0vwOF4bYsgj78r/+rT1/62JeYaLkOT71nk+ZnvKIZf8JPNSRi/t8OYgZrYqlKw3hZXMeLcYs7HhzAOhYGZePiWVUKjeE76K/4GhPOx0uvE2Qt0Tn0TkUIPAfX5OqUvN0zWVaQWj7H6iKvp7Z1H2yLRR+OxSt9a9H6NDHFEWWW5j5kMsjlwz7qJgOIIyfCmyWfO9nIFf5ROYXq9gKfYDZ7iBe4c2FBg+GN2U0IkpOMIwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=vDPZzN+/rtW0qmvGKQXRbVt9ygjj72cC8HirT/fgeA8=; b=FMKcOdGNiyvj8PgCJ5D5oEvVPNZx/y7BEB2dZ5hOcOWoFifOoFPXCC9Rzlna9p07Rb0FXXeMATyKhezQs0x0FHKvUtFqvQUjwJ9vA+J6cqUF31hMDUV4Qj7d9rJ6wd1YhIoWuzCUzHgRTRLnwEg4253JKwedbH23FYPYGRe/AU+MJLhy7AjxIYQ32iS4uvWkQ8LXtgD5tBbiw0vxTfzFin8TgQ84lFOA/6uh8Rg7a46kZNS2KbnhRZNWtDLFq/hCKW6oybwHLuR5E1g6+p6iu3LgwP0N5IUVP/uu1fhkVe/95qbPi4mCYZqs0FiJqyfBcnvQEUDE1quN0hhzWgn7Nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=broadcom.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=vDPZzN+/rtW0qmvGKQXRbVt9ygjj72cC8HirT/fgeA8=; b=PmwcVfJ515OOLdmkW9V2XESN/682xY2e29oxJBdgwhvRXJunzMTMaLFtaJhVNYUWvXw1hzpjpRFlRTrgePUrh1h9si4huOHFSSaZni0MjVvUT0TFKGDdFCUScJXdkqSochXypT8kSevS1Klw/bGuOODhjzVygnLYC+6Jui1BSO0ppfk0+oisgAtrFqH/c/8ryPm15IwBd2+ms4Ems4cOa/cvv6j03G6vjaAJYjurkm89UN8kCp8GG3Z8uvdv9ZztiN8L1ij46/hHeBYvsJuGWyn4tEH6p3eRt2IDXHmoiV3xtZVf8Ya7vJwEtVt9Jyk0ffu3zmVGHJPi0wzPGiHW+A== Received: from SJ0PR05CA0135.namprd05.prod.outlook.com (2603:10b6:a03:33d::20) by PH7PR12MB5951.namprd12.prod.outlook.com (2603:10b6:510:1da::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Tue, 5 Mar 2024 09:58:18 +0000 Received: from CO1PEPF000042A7.namprd03.prod.outlook.com (2603:10b6:a03:33d:cafe::95) by SJ0PR05CA0135.outlook.office365.com (2603:10b6:a03:33d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.23 via Frontend Transport; Tue, 5 Mar 2024 09:58:17 +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 CO1PEPF000042A7.mail.protection.outlook.com (10.167.243.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Tue, 5 Mar 2024 09:58:17 +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.986.41; Tue, 5 Mar 2024 01:58:04 -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.1258.12; Tue, 5 Mar 2024 01:58:02 -0800 From: Xueming Li To: Ajit Khaparde CC: Damodharam Ammepalli , dpdk stable Subject: patch 'net/bnxt: fix array overflow' has been queued to stable release 23.11.1 Date: Tue, 5 Mar 2024 17:47:34 +0800 Message-ID: <20240305094757.439387-114-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240305094757.439387-1-xuemingl@nvidia.com> References: <20240305094757.439387-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: 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: CO1PEPF000042A7:EE_|PH7PR12MB5951:EE_ X-MS-Office365-Filtering-Correlation-Id: 2b8b2651-aef5-42c6-c211-08dc3cfac82a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AaEz8DR7XKCGGwdD5YS6GAQcw4TMOZb6D7xdFwtWa80Ea7lD7nXMPzq7HKimj6GdWbeJdMynkczRTN0dogbBDvCwX5Orvzvk4BA1CSy3QXUFnXCmXD4/uLa5fS4Ysh9m+7GeIVgWbxCCgmr+m40Ls6Kq3qHYWEedTzeWcbK4j3ZcDv2Ot5vGfQdJK+da3kAAVxqOWpxpcqklENVevz5JX2xtAvDPwuXnYx0Kc2+YBpZSf5vzFFnUkcEjefaFtDmigUKUZ8N0LsV+XNjGtKtak54zzT4c1quwGgR2MGXKIvoPHBmVaDLdFFMrZ1IrF9ar3w5dL9mRo5vUOQVbl5cWsy1+RdwG0aDE+VWdJMLyml8fBvFpPfP3QzuvsoylR2eAcs66L2r8Y7jA1j948hd9K3StoAOKuPjdEy+z3FCujsKIcWdqvaKJ8tyf3O8wnnfy2YpfA7Ue9Ql1n+WzcfajU/RbG2Dw71GV11OSMV87GLn+DYFU6NSFVVXNqi9WDJfNOwzJN7S7EogJN8vtRyqMUZAZbMnGPtn3/UFXH/eENAFCfjyABeOCvnJAGkM0sPCht3eOVbkA9z2hi+lDdc0raeIbu4S7Wv+gY2P5OM2AxYzaKLylBYDSiPMhG290SPrhLKsv1wvxG3yX6xm55e56L/LzAGlPDqlAeyyoMTm7dV3+4+M7Quvk2/o1z/Ee8+JUjOeT5mKDBjQwZqaiya/RFSWQY8RJ02Bt88nrv9NP8dS6Q4LJagkDiWuOMQsHUQkv 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:(13230031)(36860700004)(376005)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2024 09:58:17.5941 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b8b2651-aef5-42c6-c211-08dc3cfac82a 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: CO1PEPF000042A7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5951 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.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/31/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=3fa018b15a6329237d9dd5066a5fac3c3bb53652 Thanks. Xueming Li --- >From 3fa018b15a6329237d9dd5066a5fac3c3bb53652 Mon Sep 17 00:00:00 2001 From: Ajit Khaparde Date: Mon, 11 Dec 2023 09:11:03 -0800 Subject: [PATCH] net/bnxt: fix array overflow Cc: Xueming Li [ upstream commit 4371b402c7bdbe821fff77e3c08e2faba67cb9b3 ] In some cases the number of elements in the context memory array can exceed the MAX_CTX_PAGES and that can cause the static members ctx_pg_arr and ctx_dma_arr to overflow. Allocate them dynamically to prevent this overflow. Fixes: f8168ca0e690 ("net/bnxt: support thor controller") Signed-off-by: Ajit Khaparde Reviewed-by: Damodharam Ammepalli --- drivers/net/bnxt/bnxt.h | 4 ++-- drivers/net/bnxt/bnxt_ethdev.c | 42 +++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 0e01b1d4ba..aab09e3edf 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -449,8 +449,8 @@ struct bnxt_ring_mem_info { struct bnxt_ctx_pg_info { uint32_t entries; - void *ctx_pg_arr[MAX_CTX_PAGES]; - rte_iova_t ctx_dma_arr[MAX_CTX_PAGES]; + void **ctx_pg_arr; + rte_iova_t *ctx_dma_arr; struct bnxt_ring_mem_info ring_mem; }; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index acf7e6e46e..9e63942a0f 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -4750,7 +4750,7 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, { struct bnxt_ring_mem_info *rmem = &ctx_pg->ring_mem; const struct rte_memzone *mz = NULL; - char mz_name[RTE_MEMZONE_NAMESIZE]; + char name[RTE_MEMZONE_NAMESIZE]; rte_iova_t mz_phys_addr; uint64_t valid_bits = 0; uint32_t sz; @@ -4762,6 +4762,19 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, rmem->nr_pages = RTE_ALIGN_MUL_CEIL(mem_size, BNXT_PAGE_SIZE) / BNXT_PAGE_SIZE; rmem->page_size = BNXT_PAGE_SIZE; + + snprintf(name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_pg_arr%s_%x_%d", + suffix, idx, bp->eth_dev->data->port_id); + ctx_pg->ctx_pg_arr = rte_zmalloc(name, sizeof(void *) * rmem->nr_pages, 0); + if (ctx_pg->ctx_pg_arr == NULL) + return -ENOMEM; + + snprintf(name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_dma_arr%s_%x_%d", + suffix, idx, bp->eth_dev->data->port_id); + ctx_pg->ctx_dma_arr = rte_zmalloc(name, sizeof(rte_iova_t *) * rmem->nr_pages, 0); + if (ctx_pg->ctx_dma_arr == NULL) + return -ENOMEM; + rmem->pg_arr = ctx_pg->ctx_pg_arr; rmem->dma_arr = ctx_pg->ctx_dma_arr; rmem->flags = BNXT_RMEM_VALID_PTE_FLAG; @@ -4769,13 +4782,13 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, valid_bits = PTU_PTE_VALID; if (rmem->nr_pages > 1) { - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, + snprintf(name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_pg_tbl%s_%x_%d", suffix, idx, bp->eth_dev->data->port_id); - mz_name[RTE_MEMZONE_NAMESIZE - 1] = 0; - mz = rte_memzone_lookup(mz_name); + name[RTE_MEMZONE_NAMESIZE - 1] = 0; + mz = rte_memzone_lookup(name); if (!mz) { - mz = rte_memzone_reserve_aligned(mz_name, + mz = rte_memzone_reserve_aligned(name, rmem->nr_pages * 8, bp->eth_dev->device->numa_node, RTE_MEMZONE_2MB | @@ -4794,11 +4807,11 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, rmem->pg_tbl_mz = mz; } - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_%s_%x_%d", + snprintf(name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_%s_%x_%d", suffix, idx, bp->eth_dev->data->port_id); - mz = rte_memzone_lookup(mz_name); + mz = rte_memzone_lookup(name); if (!mz) { - mz = rte_memzone_reserve_aligned(mz_name, + mz = rte_memzone_reserve_aligned(name, mem_size, bp->eth_dev->device->numa_node, RTE_MEMZONE_1GB | @@ -4844,6 +4857,17 @@ static void bnxt_free_ctx_mem(struct bnxt *bp) return; bp->ctx->flags &= ~BNXT_CTX_FLAG_INITED; + rte_free(bp->ctx->qp_mem.ctx_pg_arr); + rte_free(bp->ctx->srq_mem.ctx_pg_arr); + rte_free(bp->ctx->cq_mem.ctx_pg_arr); + rte_free(bp->ctx->vnic_mem.ctx_pg_arr); + rte_free(bp->ctx->stat_mem.ctx_pg_arr); + rte_free(bp->ctx->qp_mem.ctx_dma_arr); + rte_free(bp->ctx->srq_mem.ctx_dma_arr); + rte_free(bp->ctx->cq_mem.ctx_dma_arr); + rte_free(bp->ctx->vnic_mem.ctx_dma_arr); + rte_free(bp->ctx->stat_mem.ctx_dma_arr); + rte_memzone_free(bp->ctx->qp_mem.ring_mem.mz); rte_memzone_free(bp->ctx->srq_mem.ring_mem.mz); rte_memzone_free(bp->ctx->cq_mem.ring_mem.mz); @@ -4856,6 +4880,8 @@ static void bnxt_free_ctx_mem(struct bnxt *bp) rte_memzone_free(bp->ctx->stat_mem.ring_mem.pg_tbl_mz); for (i = 0; i < bp->ctx->tqm_fp_rings_count + 1; i++) { + rte_free(bp->ctx->tqm_mem[i]->ctx_pg_arr); + rte_free(bp->ctx->tqm_mem[i]->ctx_dma_arr); if (bp->ctx->tqm_mem[i]) rte_memzone_free(bp->ctx->tqm_mem[i]->ring_mem.mz); } -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-05 17:39:34.356474212 +0800 +++ 0113-net-bnxt-fix-array-overflow.patch 2024-03-05 17:39:30.913566498 +0800 @@ -1 +1 @@ -From 4371b402c7bdbe821fff77e3c08e2faba67cb9b3 Mon Sep 17 00:00:00 2001 +From 3fa018b15a6329237d9dd5066a5fac3c3bb53652 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 4371b402c7bdbe821fff77e3c08e2faba67cb9b3 ] @@ -12 +14,0 @@ -Cc: stable@dpdk.org @@ -22 +24 @@ -index 50f59552fa..dd08393b82 100644 +index 0e01b1d4ba..aab09e3edf 100644 @@ -25 +27 @@ -@@ -455,8 +455,8 @@ struct bnxt_ring_mem_info { +@@ -449,8 +449,8 @@ struct bnxt_ring_mem_info { @@ -37 +39 @@ -index b0589e2e49..762d863f14 100644 +index acf7e6e46e..9e63942a0f 100644 @@ -40 +42 @@ -@@ -4769,7 +4769,7 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, +@@ -4750,7 +4750,7 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, @@ -49 +51 @@ -@@ -4781,6 +4781,19 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, +@@ -4762,6 +4762,19 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, @@ -69 +71 @@ -@@ -4788,13 +4801,13 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, +@@ -4769,13 +4782,13 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, @@ -87 +89 @@ -@@ -4813,11 +4826,11 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, +@@ -4794,11 +4807,11 @@ static int bnxt_alloc_ctx_mem_blk(struct bnxt *bp, @@ -102 +104 @@ -@@ -4863,6 +4876,17 @@ static void bnxt_free_ctx_mem(struct bnxt *bp) +@@ -4844,6 +4857,17 @@ static void bnxt_free_ctx_mem(struct bnxt *bp) @@ -120 +122 @@ -@@ -4875,6 +4899,8 @@ static void bnxt_free_ctx_mem(struct bnxt *bp) +@@ -4856,6 +4880,8 @@ static void bnxt_free_ctx_mem(struct bnxt *bp)