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 DBA1543E21 for ; Sun, 7 Apr 2024 13:43:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B69C1402BF; Sun, 7 Apr 2024 13:43:33 +0200 (CEST) Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by mails.dpdk.org (Postfix) with ESMTP id CAD594029A for ; Sun, 7 Apr 2024 13:43:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1712490212; x=1744026212; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Xr8WbupP/zd70vJ3kwbdxVVSwUsJ9ukayozEoO36Q2Q=; b=khxNEdGjioq4pgf0dZEpVvvkZKCKcCMIC2Rp6h4N4mbGBZA0L1JEOLog zRawmaX1JDjHUulbARDnT+wSdRrNJMp+MZJbGVoZC5Fh9WjT277uo4rbu 5WTyMZz5d7MIPQBs4Y9TG5xM5RW6K9AVWM6wDfYvViF1BWzQC3vgphOM+ I=; X-IronPort-AV: E=Sophos;i="6.07,185,1708387200"; d="scan'208";a="337452300" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-33001.sea14.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2024 11:43:26 +0000 Received: from EX19MTAEUB001.ant.amazon.com [10.0.17.79:6841] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.18.212:2525] with esmtp (Farcaster) id b95a15fc-001b-45a6-84f3-6351284b9992; Sun, 7 Apr 2024 11:43:24 +0000 (UTC) X-Farcaster-Flow-ID: b95a15fc-001b-45a6-84f3-6351284b9992 Received: from EX19D007EUA002.ant.amazon.com (10.252.50.68) by EX19MTAEUB001.ant.amazon.com (10.252.51.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Sun, 7 Apr 2024 11:43:24 +0000 Received: from EX19MTAUWB001.ant.amazon.com (10.250.64.248) by EX19D007EUA002.ant.amazon.com (10.252.50.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Sun, 7 Apr 2024 11:43:24 +0000 Received: from HFA15-CG15235BS.amazon.com (10.1.212.12) by mail-relay.amazon.com (10.250.64.254) with Microsoft SMTP Server id 15.2.1258.28 via Frontend Transport; Sun, 7 Apr 2024 11:43:23 +0000 From: To: CC: Subject: [PATCH 1/1] net/ena/base: fix metrics excessive memory consumption Date: Sun, 7 Apr 2024 14:43:18 +0300 Message-ID: <20240407114318.1694-2-shaibran@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240407114318.1694-1-shaibran@amazon.com> References: <20240407114318.1694-1-shaibran@amazon.com> MIME-Version: 1.0 Content-Type: text/plain 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 From: Shai Brandes [ 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. Signed-off-by: Shai Brandes Reviewed-by: Amit Bernstein Fixes: f73f53f7dc7a ("net/ena: upgrade HAL") Bugzilla ID: 1400 Cc: stable@dpdk.org --- 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 6953a1fa33..8ae7dcf48e 100644 --- a/drivers/net/ena/base/ena_com.c +++ b/drivers/net/ena/base/ena_com.c @@ -3134,16 +3134,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.17.1