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 7EBDC43E60 for ; Sat, 13 Apr 2024 10:23:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EE9840294; Sat, 13 Apr 2024 10:23:42 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2068.outbound.protection.outlook.com [40.107.244.68]) by mails.dpdk.org (Postfix) with ESMTP id 0433B400D6; Sat, 13 Apr 2024 10:23:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fUIy9XtwpwOfkGIC/aB0dOGJfOeplMnBTiHZu2T6gZaf2W0SJWZHGkgkkUwV5wSIlxUEdq+V4DYcNSDtCWLD+ObA2ApHOGq32Iiv3VPdMuWm6pvC86uedwpPOWH/hW6WhIA+SmycPYmPACw0nUfbLQ5a0dmlEVbEiJDHCv2eeY+V/3d2pjSIV0fIVsto/9rqBM9tkKKDeyEVQ9+H1dgYCygTXBDG0fVONwDXZVeUd8mbJI5geSiRDaNSJ3XP7CY1Pehww0a+lDUurwRtZwm2JcsHg1trrHbKjFHhYSnjcr0sgGEZrxSRo0+Gsg6+HTG6EhkVTxtbIw8jVENOFQzsLw== 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=cABKM1UX4EVvKPBemIZvcKIPok26e7ZQTobZcwPW9yg=; b=O0lmOLu8ZztOKezJIPf7Ol36KaDwv7/XkNeyshNk61k7U/DRtj8BjJrmWCTLOzV9YILuK5ifobVTjS1Js6xdHdJA0Nc8QFSw8CM0qMLGPWLpBidcP+goH4pQr5cA/69xBGyZL6tdAax7Y4xx1onSkmlDRhHLKzZXJrIReX2CIxRX5ghyy7cvQTSdpCnhB8GioWgYnImjZJbuQfnMbbdUzaz7mQ6XiHTPJrdRXYSnMMinHhXwj6Uv8SlP6Cs0mUZCxIhAoisvASorZEPkZMDQZG4wNnJ7Z5lWpUg2V4uWf1zBKM1nwFOYE7KsUIyfHyEuVwdmtot3uggo395VZIqLCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none 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=cABKM1UX4EVvKPBemIZvcKIPok26e7ZQTobZcwPW9yg=; b=hW7Pm58Y9hMOvl30CBU4tFs1qHoE3pioXbyXdSO7uAtoNS/ujvAAFnBIatHe1xkKhyJy88gzEk4gZJmbXj1D/C73ExdhL8kLD7aFY5e+lAwK0aTbPq4q6+3Ai17+62WQONBOuGUpoZqb7hvwgVw9RhnHwKHtb0485YAKoA4trozsQefsu8kFUre/ee7WU+OKtOuRwfab0Ud6X4QfC6bKffQdwDKGOcHqN2PlWkHOeQekd4tIBN7sJCd0qDY+fHL3n/8ehU4npxw13KmYcYwYYKoaTTGpOVhJ/7UmatzUhgnYdZy+/gz5Q63bD28huQ8xjKYXaZxlok0wfLhNEBhDNA== Received: from DM4PR12MB5373.namprd12.prod.outlook.com (2603:10b6:5:39d::14) by SA1PR12MB8985.namprd12.prod.outlook.com (2603:10b6:806:377::18) 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 08:23:37 +0000 Received: from DM4PR12MB5373.namprd12.prod.outlook.com ([fe80::630f:22c9:1d04:12d8]) by DM4PR12MB5373.namprd12.prod.outlook.com ([fe80::630f:22c9:1d04:12d8%4]) with mapi id 15.20.7409.042; Sat, 13 Apr 2024 08:23:36 +0000 From: Xueming Li To: "shaibran@amazon.com" , "ferruh.yigit@amd.com" , "bluca@debian.org" , "christian.ehrhardt@canonical.com" , "ktraynor@redhat.com" CC: "stable@dpdk.org" , "dev@dpdk.org" Subject: Re: [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption Thread-Topic: [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumption Thread-Index: AQHaia55MgQHOCG9tEiAqpxU2g7BN7Fl490g Date: Sat, 13 Apr 2024 08:23:36 +0000 Message-ID: References: <20240408121525.1906-1-shaibran@amazon.com> <20240408121525.1906-2-shaibran@amazon.com> In-Reply-To: <20240408121525.1906-2-shaibran@amazon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM4PR12MB5373:EE_|SA1PR12MB8985:EE_ x-ms-office365-filtering-correlation-id: e97f38f0-9512-4447-9986-08dc5b930435 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: l5hZ8vEtFu42js+bfCV1apW2012mBvCwYZvhBn3AbHMQPry/MLQWuun0AX3JOmnMx7Xa3vbHOhRGfVAHFbkURQfIcfefymYgvmkG0Ab3MDS1LA2J+lNfWfAEh/p60VTNREB310YmgAeNSnb086d2Cesbihl8VFMwIyM4pD6RcTH3XjXRUQ7f6QjUWZ4tlZ8ysYKjg162ne4CCsKrh/hXYRs/5IK7P9DxKKAfPGSOTB2kbsCdHXBg796D4wSNaNsHDzSr/mq2BL2slNJiPdoN7CS0T2dvOstLQ9RyrAZY3rr/JvYCLkagZGCakLSrshnD53if5ReiDbceWL+4ckSxCTfhhNoNoyNdVk1JPTaV28z26mLWVDztum30lEj2Y/NT9pQBFY436sLWACIYzuzoJqRi0IlKdCJeg9F7SQy24/rVGEZAvWcMDJMPsH/hQPXjXSmF7xC2MrqdZhNRMyv60E83MMNPYO6N5+0KwGiFGMzs27M53OOv/Y3E5+IFfNYKkBkM1oF3MK7up54atM/kedJnkHNML7uccY/JRVoDtoCRlt6Y8RDlnEUR60LImjbQ3+urKrSDzTrivCxBUNf970w4ZJKwzmghTEVbLj5/CHp/4jS5sBxyu5Z5q6Uub1/ZTD8uZZO3wdMvm/FK7rHxX104QS7BEXQSohV6SyaC5DLW+EaxeplGdV8lw2+sZz6tAlTku4VohFB2cai3OmUMFHV9ZhB367JZRbyfuXN7c7E= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR12MB5373.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(376005)(1800799015)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?6Fuh9GwPsEntBwv056ifGGpN7Y7cHpy35PWyf18+UwnrPZUHGKqiFLEFd2Ci?= =?us-ascii?Q?78UY7T1knDjJaxnP9/3wE6uoBSaQC43g19uSjVVww+GdX2txzJcYQQZn7Dzt?= =?us-ascii?Q?GO9szefzowMS2YdRCS91KoshYbl7SkhjpEL+rO0bOWBu7bFwBqI4pJLnGhCs?= =?us-ascii?Q?mXP3hXt+9nbni49ExPjS45hrODIvtQ5sfkRGxCcY1eI0wDbNXT1an0Upw1TN?= =?us-ascii?Q?Im8+y/VFwWXwwenWNM0ZSfnv9GMudWmfnMVDmYLFXRRk3/ClcDU0z87Rfcuu?= =?us-ascii?Q?C+tSPsdPcWPpMtu6bzrgVleDnBHrE32KsTfOVnhXl83aRFJrwGMmHACFhqAB?= =?us-ascii?Q?rcvLuChn5VxyqkHYqQvTvX6WXXsmrEjT91gepM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?Q?Gm3FFQ6dZBqOm+K/2/uiXv/773lmr0fnOHypNfl5LMNhHJWORRySzdc4nR50?= =?us-ascii?Q?N1i/V5bDz7EzFSiqvyButv60/6rEtEajws9XQXj7TgU0XkBzKA/GTOCAMj2q?= =?us-ascii?Q?uoX3VQWy0TVMwBt5wzK83+RRTMdt776JT0bEhloaSy7l0pjzyKbdseEu/EMN?= =?us-ascii?Q?IvijJY+aI+SHvKU6WFYs5+6hoTAqxFzxiHQQFXGcyYe7a8F2qouxPBIue7KL?= =?us-ascii?Q?sStBmFxer6hnIs6kTA0OY4miTLluriFjhq7beIz05Clc7E303gmK2cpxKz2F?= =?us-ascii?Q?GpEmOzWm2Z32nifiNUY7NgV+uGgGRbaZlCs7n5eX?= Content-Type: multipart/alternative; boundary="_000_DM4PR12MB53738AAD4654252A0E4E2A99A10B2DM4PR12MB5373namp_" MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e97f38f0-9512-4447-9986-08dc5b930435 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Apr 2024 08:23:36.8264 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: QYfdgUikqCVEdsj9yPepMCp+KJAIUz2zEZPXtVYAwiF4SFJQjQhjNLzO7g050tGOMfBs7PB+R37PtWyfMB1WXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8985 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 --_000_DM4PR12MB53738AAD4654252A0E4E2A99A10B2DM4PR12MB5373namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Shai, Thanks for the backporting, patch queued to 23.11.1 staging branch. ________________________________ From: shaibran@amazon.com Sent: Monday, April 8, 2024 8:15 PM To: ferruh.yigit@amd.com ; bluca@debian.org ; christian.ehrhardt@canonical.com ; Xueming Li ; ktraynor@redhat.com Cc: stable@dpdk.org ; dev@dpdk.org ; Shai Br= andes Subject: [PATCH v2 1/1] net/ena/base: fix metrics excessive memory consumpt= ion 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 =3D &ena_dev->custom= er_metrics; + customer_metrics->buffer_len =3D ENA_CUSTOMER_METRICS_BUFFER_SIZE; + customer_metrics->buffer_virt_addr =3D 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 =3D=3D NULL)) + if (unlikely(customer_metrics->buffer_virt_addr =3D=3D NULL)) { + customer_metrics->buffer_len =3D 0; return ENA_COM_NO_MEM; - - customer_metrics->buffer_len =3D ENA_CUSTOMER_METRICS_BUFFER_SIZE; + } return 0; } -- 2.17.1 --_000_DM4PR12MB53738AAD4654252A0E4E2A99A10B2DM4PR12MB5373namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Hi Shai,

Thanks for the backporting, patch queued to 23.11.1 staging branch.


From: shaibran@amazon.com &= lt;shaibran@amazon.com>
Sent: Monday, April 8, 2024 8:15 PM
To: ferruh.yigit@amd.com <ferruh.yigit@amd.com>; bluca@debian.= org <bluca@debian.org>; christian.ehrhardt@canonical.com <christia= n.ehrhardt@canonical.com>; Xueming Li <xuemingl@nvidia.com>; ktray= nor@redhat.com <ktraynor@redhat.com>
Cc: stable@dpdk.org <stable@dpdk.org>; dev@dpdk.org <dev@dp= dk.org>; Shai Brandes <shaibran@amazon.com>
Subject: [PATCH v2 1/1] net/ena/base: fix metrics excessive memory c= onsumption
 
From: Shai Brandes <shaibran@amazon.com>

[ 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 <shaibran@amazon.com>
Reviewed-by: Amit Bernstein <amitbern@amazon.com>
---
 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_metric= s *customer_metrics =3D &ena_dev->customer_metrics;
+       customer_metrics->buffer_len =3D E= NA_CUSTOMER_METRICS_BUFFER_SIZE;
+       customer_metrics->buffer_virt_addr= =3D NULL;
 
         ENA_MEM_ALLOC_COHERENT(ena= _dev->dmadev,
            &nb= sp;            =        customer_metrics->buffer_len,
            &nb= sp;            =        customer_metrics->buffer_virt_addr,=
            &nb= sp;            =        customer_metrics->buffer_dma_addr,<= br>             &nb= sp;            =        customer_metrics->buffer_dma_handle= );
-       if (unlikely(customer_metrics->buf= fer_virt_addr =3D=3D NULL))
+       if (unlikely(customer_metrics->buf= fer_virt_addr =3D=3D NULL)) {
+            &n= bsp;  customer_metrics->buffer_len =3D 0;
            &nb= sp;    return ENA_COM_NO_MEM;
-
-       customer_metrics->buffer_len =3D E= NA_CUSTOMER_METRICS_BUFFER_SIZE;
+       }
 
         return 0;
 }
--
2.17.1

--_000_DM4PR12MB53738AAD4654252A0E4E2A99A10B2DM4PR12MB5373namp_--