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 BC4AE43DCA for ; Mon, 8 Apr 2024 14:15:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AD37A402D9; Mon, 8 Apr 2024 14:15:41 +0200 (CEST) Received: from smtp-fw-80009.amazon.com (smtp-fw-80009.amazon.com [99.78.197.220]) by mails.dpdk.org (Postfix) with ESMTP id 57C4C40041; Mon, 8 Apr 2024 14:15:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1712578538; x=1744114538; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=CIkHVy0IwmuMGVR09lXEPNYyVLtnnQq/a5Fjbec3Zg8=; b=Oq9qHts2CP4Z1uoLDtQvQ057fY84Ywqnh2Lk6uwb0W3VB1aHMNBcJw4K LvKQyAkAkd2eKwvHs3kb9DO/TXC8Y/y8riGzRBLTxw0O0LaUSJJBffnBO EQna3u1D2L18cr4Fv3t9AM7y0PU69T5Lb5YtqrE24gJWxxuy0cnZjnc7M Y=; X-IronPort-AV: E=Sophos;i="6.07,186,1708387200"; d="scan'208";a="79526608" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev) ([10.25.36.210]) by smtp-border-fw-80009.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 12:15:34 +0000 Received: from EX19MTAEUA001.ant.amazon.com [10.0.43.254:39368] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.32.21:2525] with esmtp (Farcaster) id 20fa19c0-335e-416e-a12f-a5ab9894c23d; Mon, 8 Apr 2024 12:15:32 +0000 (UTC) X-Farcaster-Flow-ID: 20fa19c0-335e-416e-a12f-a5ab9894c23d Received: from EX19D007EUA002.ant.amazon.com (10.252.50.68) by EX19MTAEUA001.ant.amazon.com (10.252.50.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Mon, 8 Apr 2024 12:15:32 +0000 Received: from EX19MTAUEA001.ant.amazon.com (10.252.134.203) 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; Mon, 8 Apr 2024 12:15:32 +0000 Received: from HFA15-CG15235BS.amazon.com (10.1.212.52) by mail-relay.amazon.com (10.252.134.102) with Microsoft SMTP Server id 15.2.1258.28 via Frontend Transport; Mon, 8 Apr 2024 12:15:30 +0000 From: To: , , , , CC: , , Shai Brandes Subject: [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption Date: Mon, 8 Apr 2024 15:15:25 +0300 Message-ID: <20240408121525.1906-2-shaibran@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240408121525.1906-1-shaibran@amazon.com> References: <20240408121525.1906-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. 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 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