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 5EA4043E57 for ; Sat, 13 Apr 2024 15:01:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 59BF240EDF; Sat, 13 Apr 2024 15:01:42 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) by mails.dpdk.org (Postfix) with ESMTP id 2244540ED8 for ; Sat, 13 Apr 2024 15:01:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EYP/BX/Rt4QVTHhbAvh6SKXsHyavmHvhNtMFGlCL4taAEFO20frkcvr4mFK88S49EAeFYHCBnpYF3XG1VNGxWSs4xK71Ll4xnhqb3uaQfWvvVMUjQ30bsy1XQIio+Cwp56/8wHjQXF+XAruwvy4WTc8LdbU6H4tQnYr1rU/kbMsokyS/jwsBQJOUgtg2SxoC8VEPd2gDZg5+bUGK5FdxEui9wVoxn+cWyChxc89sc+Gkp3k3W5lfUfT4T7USJ5xZJa9CQNoqA7W47DEl3VaumeJBSVdhr8qxfJ7mY53BbPZreCsNufs+UEKfifvdW8adUI9P/m/DmuC3E9TrYx1j0w== 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=XhzzobHchrEIYOUAOtPi8UgN7CC9dluMptUHXOHgkHo=; b=QI+zw9XQq7/I4/eLwEcrjhYfLxuDm2+EmF6kQrVKS6GRAlWNOWmuQi5htKU/n7QadXvrSdWIZEpqljIQnGFbbt6dFl8LFlnXODaca3V9SHr/AWjiz8/8lG3UHw9rsaIm/oBjoFtuOpKwh6yoFC9XGIEu8mdkXqzx68JbKaa75cNXGsh03kSps1tdVlFFTrY7FlJ8nj+NdPdlJejEsAM/R8y4m0XQ5oPE9dLiOrVy77D7cuxAfV0fEjlYaYmF38WTBElK9K9BVQIOV0+1LcnxwcIf1v2tdy5TWLGG2aF2oZMaGQD2qteYjJMhuTlKmFteEbELZ+RUV/ze9GNSyRAaqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=amazon.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=XhzzobHchrEIYOUAOtPi8UgN7CC9dluMptUHXOHgkHo=; b=b8qY1CMy84HYm7Cj9wwgFqiz68DeCy7T9q2ZGE7kf7R05WmvGGzHhYLArMlmtmUaB+03XRqMME6wfSEh8bPuyrIZ+UbIM10c91marRH7ewel9RcW+Q6dpQvVTXyB8RKts2zns7Cx1gslbfg/DUm4SewvuG2exIWTD95+XYhh+yzHqp+qHm/rLB3qdGRiTp86i4mEbhaS+u5EZhMGjxkapiDKHLWC2+w/p9Vr0ez9D6hWPm2/O3zRRgfWDrkcEW2dOl7HUjlHMuaOu5L1b6Qsti0OWIO0aNrFmS1p4AdazL5Z95fW6HIsLkF1oFEJYEzutt9xDp56Fh4pKAgif14aVQ== Received: from SJ0PR13CA0099.namprd13.prod.outlook.com (2603:10b6:a03:2c5::14) by PH7PR12MB9104.namprd12.prod.outlook.com (2603:10b6:510:2f3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Sat, 13 Apr 2024 13:01:37 +0000 Received: from MWH0EPF000A6731.namprd04.prod.outlook.com (2603:10b6:a03:2c5:cafe::80) by SJ0PR13CA0099.outlook.office365.com (2603:10b6:a03:2c5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.15 via Frontend Transport; Sat, 13 Apr 2024 13:01:36 +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 MWH0EPF000A6731.mail.protection.outlook.com (10.167.249.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Sat, 13 Apr 2024 13:01:36 +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; Sat, 13 Apr 2024 06:01:17 -0700 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.1258.12; Sat, 13 Apr 2024 06:01:15 -0700 From: Xueming Li To: Shai Brandes CC: Amit Bernstein , dpdk stable Subject: patch 'net/ena/base: fix metrics excessive memory consumption' has been queued to stable release 23.11.1 Date: Sat, 13 Apr 2024 20:50:05 +0800 Message-ID: <20240413125005.725659-125-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240413125005.725659-1-xuemingl@nvidia.com> References: <20240305094757.439387-1-xuemingl@nvidia.com> <20240413125005.725659-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: 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: MWH0EPF000A6731:EE_|PH7PR12MB9104:EE_ X-MS-Office365-Filtering-Correlation-Id: 01e1d60a-2f9a-49a9-fb43-08dc5bb9da4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UmkpoT6t4irzjXBQTaCDvkK3MAucvflH7hpd6j6QwDTf3XxMtOny9QVuy+slMoPezjvt+8a2sO/nDp8CYBXCKeAVYNhuT+dNzkLZtslWX7rWGEoqL+nig4J5Oc8tvVWOeDIkWM8MsKGoHbP9kROF3QT/EkyjFzC83HH2bm2uiohIxFr1WdgrAElfRUhfaLz0+53qOjH7UHYakOWYqXSLR13cZPobapeYfGBxcFr+SQxfUICtNokBRRFFFiV08luHa+5kkiUeZs0S9QB1yFTnEQ0I9CcG5dBTRSY3WNJOM470kohJFr+2VV6EQ7VwmeDqHNSMbq0vc4HWug1u9B34BsJv4o4xBhOwJguIPKVMY0L3BsU0JsUXMYuPmLc2LMI21a0oR5FaHZRocM+kL1yb0J98kB6w1fjgSyB8Lz1ciXTWf7tJ9k/ZoTnkYU5HLBO8Tuimk4jQ434PbtAioOeSbt9unzbdte2I7jjzWnu03XtG1wggh1JMyinR8SuI65FYmvhbF9gSWCHk8mG0gAZ3GmPBssyfebf2KYdISC2sI7NpVUm4ftnaEXQFQ9IbseDlF/cdiR2wZb/4/YshcFNKaR/aIdCJ7TA3355pk67TTU4TwqorMZkuuWWBOQ8J1NEz+xWX5uH6Ry/pHoL9By6XidFF89YL9OqGYVm7SQrZq8C4vSrFeieilxqSt4ITFDZhv+N1ONtMevHAJkfVRb/zLC0B1IkvoThg8q2rmIcBMgfEM/U21onf88/bpZt0IwjV 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)(1800799015)(376005)(82310400014)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2024 13:01:36.8582 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01e1d60a-2f9a-49a9-fb43-08dc5bb9da4f 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: MWH0EPF000A6731.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9104 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 04/15/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=cfa8a4cb909e07cbb34941358f4d912c879dca34 Thanks. Xueming Li --- >From cfa8a4cb909e07cbb34941358f4d912c879dca34 Mon Sep 17 00:00:00 2001 From: Shai Brandes Date: Mon, 8 Apr 2024 15:15:25 +0300 Subject: [PATCH] net/ena/base: fix metrics excessive memory consumption Cc: Xueming Li [ upstream commit c8a1898f82f8c04cbe1d3e2d0eec0705386c23f7 ] The driver accidentally allocates a huge memory buffer for the customer metrics because it uses an uninitialized variable for the buffer length. This can lead to excessive memory footprint for the driver which can even fail to initialize in case of insufficient memory. Bugzilla ID: 1400 Fixes: f73f53f7dc7a ("net/ena: upgrade HAL") Cc: stable@dpdk.org Signed-off-by: Shai Brandes Reviewed-by: Amit Bernstein --- drivers/net/ena/base/ena_com.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ena/base/ena_com.c b/drivers/net/ena/base/ena_com.c index 57ccde9545..2f438597e6 100644 --- a/drivers/net/ena/base/ena_com.c +++ b/drivers/net/ena/base/ena_com.c @@ -3141,16 +3141,18 @@ int ena_com_allocate_debug_area(struct ena_com_dev *ena_dev, int ena_com_allocate_customer_metrics_buffer(struct ena_com_dev *ena_dev) { struct ena_customer_metrics *customer_metrics = &ena_dev->customer_metrics; + customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE; + customer_metrics->buffer_virt_addr = NULL; ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev, customer_metrics->buffer_len, customer_metrics->buffer_virt_addr, customer_metrics->buffer_dma_addr, customer_metrics->buffer_dma_handle); - if (unlikely(customer_metrics->buffer_virt_addr == NULL)) + if (unlikely(customer_metrics->buffer_virt_addr == NULL)) { + customer_metrics->buffer_len = 0; return ENA_COM_NO_MEM; - - customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE; + } return 0; } -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-04-13 20:43:08.830253026 +0800 +++ 0125-net-ena-base-fix-metrics-excessive-memory-consumptio.patch 2024-04-13 20:43:05.157753723 +0800 @@ -1 +1 @@ -From c8a1898f82f8c04cbe1d3e2d0eec0705386c23f7 Mon Sep 17 00:00:00 2001 +From cfa8a4cb909e07cbb34941358f4d912c879dca34 Mon Sep 17 00:00:00 2001 @@ -3,2 +3,3 @@ -Date: Tue, 12 Mar 2024 20:07:09 +0200 -Subject: [PATCH] net/ena: improve style and readability +Date: Mon, 8 Apr 2024 15:15:25 +0300 +Subject: [PATCH] net/ena/base: fix metrics excessive memory consumption +Cc: Xueming Li @@ -6,2 +7,12 @@ -This patch makes several changes to improve -the style and readability of the code. +[ upstream commit c8a1898f82f8c04cbe1d3e2d0eec0705386c23f7 ] + +The driver accidentally allocates a huge memory +buffer for the customer metrics because it uses +an uninitialized variable for the buffer length. +This can lead to excessive memory footprint for +the driver which can even fail to initialize in +case of insufficient memory. + +Bugzilla ID: 1400 +Fixes: f73f53f7dc7a ("net/ena: upgrade HAL") +Cc: stable@dpdk.org @@ -12,3 +23,2 @@ - drivers/net/ena/base/ena_com.c | 13 +++++-------- - drivers/net/ena/base/ena_plat_dpdk.h | 2 +- - 2 files changed, 6 insertions(+), 9 deletions(-) + drivers/net/ena/base/ena_com.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) @@ -17 +27 @@ -index b98540ba63..2db21e7895 100644 +index 57ccde9545..2f438597e6 100644 @@ -20,28 +30,2 @@ -@@ -1914,15 +1914,14 @@ int ena_com_phc_get_timestamp(struct ena_com_dev *ena_dev, u64 *timestamp) - - /* PHC is in active state, update statistics according to req_id and error_flags */ - if ((READ_ONCE16(read_resp->req_id) != phc->req_id) || -- (read_resp->error_flags & ENA_PHC_ERROR_FLAGS)) { -+ (read_resp->error_flags & ENA_PHC_ERROR_FLAGS)) - /* Device didn't update req_id during blocking time or timestamp is invalid, - * this indicates on a device error - */ - phc->stats.phc_err++; -- } else { -+ else - /* Device updated req_id during blocking time with valid timestamp */ - phc->stats.phc_exp++; -- } - } - - /* Setting relative timeouts */ -@@ -2431,7 +2430,7 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data) - timestamp = (u64)aenq_common->timestamp_low | - ((u64)aenq_common->timestamp_high << 32); - -- ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrome[%x] timestamp: [%" ENA_PRIU64 "s]\n", -+ ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrome[%x] timestamp: [%" ENA_PRIu64 "s]\n", - aenq_common->group, - aenq_common->syndrome, - timestamp); -@@ -3233,16 +3232,15 @@ int ena_com_allocate_customer_metrics_buffer(struct ena_com_dev *ena_dev) +@@ -3141,16 +3141,18 @@ int ena_com_allocate_debug_area(struct ena_com_dev *ena_dev, + int ena_com_allocate_customer_metrics_buffer(struct ena_com_dev *ena_dev) @@ -50 +33,0 @@ - @@ -51,0 +35,2 @@ ++ customer_metrics->buffer_virt_addr = NULL; + @@ -58 +43,2 @@ -+ if (unlikely(!customer_metrics->buffer_virt_addr)) ++ if (unlikely(customer_metrics->buffer_virt_addr == NULL)) { ++ customer_metrics->buffer_len = 0; @@ -60,2 +45,0 @@ - -- customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE; @@ -63,2 +47,2 @@ - return 0; - } +- customer_metrics->buffer_len = ENA_CUSTOMER_METRICS_BUFFER_SIZE; ++ } @@ -66,6 +50 @@ -@@ -3285,7 +3283,6 @@ void ena_com_delete_customer_metrics_buffer(struct ena_com_dev *ena_dev) - customer_metrics->buffer_dma_addr, - customer_metrics->buffer_dma_handle); - customer_metrics->buffer_virt_addr = NULL; -- customer_metrics->buffer_len = 0; - } + return 0; @@ -73,14 +51,0 @@ - -diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h -index bb21e1bf01..9e365b0f3b 100644 ---- a/drivers/net/ena/base/ena_plat_dpdk.h -+++ b/drivers/net/ena/base/ena_plat_dpdk.h -@@ -40,7 +40,7 @@ typedef uint64_t dma_addr_t; - #define ETIME ETIMEDOUT - #endif - --#define ENA_PRIU64 PRIu64 -+#define ENA_PRIu64 PRIu64 - #define ena_atomic32_t rte_atomic32_t - #define ena_mem_handle_t const struct rte_memzone * -