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 CB30D45610 for ; Fri, 12 Jul 2024 13:03:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C496D42E6C; Fri, 12 Jul 2024 13:03:59 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2083.outbound.protection.outlook.com [40.107.244.83]) by mails.dpdk.org (Postfix) with ESMTP id 1331240261 for ; Fri, 12 Jul 2024 13:03:58 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pGJARRiubxMQNllxbHQOIIZdCKbRW0uwz8dEUmtRAGdOyx6mDjO7+QrkRcrPboihmyhlVUuq98/cFlRBY9bU6gMtyAwwdjqiBJY9E4ePN16meXUUHcs6om+8+V/jvrmmsaZYWC11Ss3iNopNgbF06nM74hXxPw+Vh0Xt7XCKl9lLACMPeby1sNPtQ/UTl3GMHX2DZbr+ReQcfRv6dfUZcqDCsTzKM82S4MrNa2KcoMp2GMKt4iLKBTS2bV5HX8jB3j596CdBkIVaqSNMOVvT8bhGcKT4PdZacfIDW2C3nBcfEBgZhtajgP6pmwjR3BAsgIStQXWAirpcn/xVxpC1ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=tThL7UPyBXn81blf242fQC8lWc1bG0HhN0e9YIcnLDU=; b=Qsyq1cJdWpiRMUZNqeXy+jo+XW7+Opy/SSYxOdzMF7k2PQ49pOhIRWE4LM/RJyJlj8YyP+tSuezWO1t3tTUdF5JOShUP9nrIlaNFscxyuYGpmjjl4rF1fmvhYIO0uEws9WohqtoOqv4tma4vTY58OElB2M0OO+g41R8Fm94fg0q3jSLl7vHzRdEvanCp75MK8SZxpxDskQfhHvT9wiDJPGrLmIHO+V9Le0cv5d4nUao7ffO3Z91Q3pzxYPcJFcl0+DV2e3/Q5HfEMtcM27yYZMbWFjFT1sr2KpP29jyznzpFrvaSoPkBSG+9l+r/BtaiaBlT9914AHmrsIDseVG28Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org 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=tThL7UPyBXn81blf242fQC8lWc1bG0HhN0e9YIcnLDU=; b=hRC95j/cfaBax3uplk8i2BLwgluS++h0w8ija1v0ka04JCX8wzrh/fczUnABlGBbxXRoP1rakgkuWgEEwhBoeTAfdS1R72qPOBNCj54f953h9JxVdYIgkX/6117ZOMnDQX0eE9fCRJTd1JEsf3Bqzuu1GMLgPO3mz9EzVvMwUnzXqdj1k1RKEWCoj4kI5by62UxTIK80S2x8Q4utM/tqPKiR9pdV9r3WQ/jx6H75OcVdBjgzKTbReCrvnm1vrMnLB2ISX+IgDhjQ2hscSEeSYO0rY/JlxuWttSmXMcmTO+UveggAwGBzsZQF0W9M1fmvDT7VI7jEtpWpvZvJKCwztQ== Received: from MN0PR04CA0026.namprd04.prod.outlook.com (2603:10b6:208:52d::17) by PH7PR12MB9151.namprd12.prod.outlook.com (2603:10b6:510:2e9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Fri, 12 Jul 2024 11:03:55 +0000 Received: from BL02EPF0001A100.namprd03.prod.outlook.com (2603:10b6:208:52d:cafe::5c) by MN0PR04CA0026.outlook.office365.com (2603:10b6:208:52d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23 via Frontend Transport; Fri, 12 Jul 2024 11:03:54 +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 BL02EPF0001A100.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.17 via Frontend Transport; Fri, 12 Jul 2024 11:03:54 +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.1544.4; Fri, 12 Jul 2024 04:03:37 -0700 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.1544.4; Fri, 12 Jul 2024 04:03:35 -0700 From: Xueming Li To: Maayan Kashani CC: Dariusz Sosnowski , dpdk stable Subject: patch 'net/mlx5: fix crash on counter pool destroy' has been queued to stable release 23.11.2 Date: Fri, 12 Jul 2024 19:01:46 +0800 Message-ID: <20240712110153.309690-16-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240712110153.309690-1-xuemingl@nvidia.com> References: <20240712104528.308638-1-xuemingl@nvidia.com> <20240712110153.309690-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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A100:EE_|PH7PR12MB9151:EE_ X-MS-Office365-Filtering-Correlation-Id: e5be5fbf-2cd5-4d61-9926-08dca26251f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?v5PfIeqrL8lUC2QDtch5s+qRJL/kDdLWiqObY7Jj48t845f1ysiy03e1rEAg?= =?us-ascii?Q?egX5jtfL4iHmR06/RcxKUbue4mj8XRgbHty3RUx6VP+f40KQpcMnc7OU+PtS?= =?us-ascii?Q?LU8ReYBfI7fFYpyuuNZWQstcp+VeTmMmRTVj601JF7ahXL3cA3Ulg1w+4C0o?= =?us-ascii?Q?Z+OImzPEry+Oyd7/clpbUqxbFt740t8ZRYj63otFyZhZyn/QIGkprK9pjJC5?= =?us-ascii?Q?vBPRlprKbUZRetZFN9vJpIERtESKNjOCisyOiRS6GJKDrwqAg0XkZy2CYcOk?= =?us-ascii?Q?cnorLdKIovSYJhuot9u8d5Cf+jxu8dYCyokrD4Xu2vfCe3UfLAVuHPb/XQBF?= =?us-ascii?Q?BN5XxHe4xUFTZ0iW8BOWkZwrAsgYW9Az25rQ9tnJ4vVmE8ME38mpzMggpHYM?= =?us-ascii?Q?56Xg505Nf2lLXPqSad575yPx+XTEIhq5PACzIshWQRQEc6jLY3fG18Hr22Oi?= =?us-ascii?Q?UEKIOR+BGKe9raHOoZY1CTErK7P05fcchSxQjzj2Zke9RvcpdYE1ppnN5Evy?= =?us-ascii?Q?nnJOGc2BpFW37dOBUC+7kFCu5ZIDV93ExHpYSD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eawAs8pt47AkspvcBUjx+?= 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:(13230040)(82310400026)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 11:03:54.3150 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5be5fbf-2cd5-4d61-9926-08dca26251f3 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: BL02EPF0001A100.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9151 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.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/14/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=160e8f583bea1ed2de9bc8d5081b98633596b53b Thanks. Xueming Li --- >From 160e8f583bea1ed2de9bc8d5081b98633596b53b Mon Sep 17 00:00:00 2001 From: Maayan Kashani Date: Sun, 9 Jun 2024 14:01:02 +0300 Subject: [PATCH] net/mlx5: fix crash on counter pool destroy Cc: Xueming Li [ upstream commit 3331d59551cdecd2db3a2064a7d6e4bf9396b849 ] If the counter pool was not added to list, and an error state was reached, on attempt to destroy the counter pool, segmentation fault was received during list remove action. Added a check to verify the list is not empty before trying to remove the cpool from the list. Invalid state, leading to segfault, can also be reached in the following scenario: 1. mlx5_hws_cnt_pool_init() does a zmalloc and initializes most of the fields of cpool, but does not initialize the next field. 2. mlx5_hws_cnt_pool_dcs_alloc() attempts to bulk allocate flow counters. If this fails, we skip straight to 4. In HW, this can fail simply if FW doesn't support bulk flow counter allocation. 3. Right before the goto error, we insert the cpool to the hws_cpool_list. This is where the next field is initialized. 4. mlx5_hws_cnt_pool_destroy() assumes the cpool's next field is initialized and SEGVs if not. So, added a guard against cases where the entry was uninitialized (checking le_prev field is not NULL). Fixes: 6ac2104ac125 ("net/mlx5: fix counter query during port close") Signed-off-by: Maayan Kashani Acked-by: Dariusz Sosnowski --- drivers/net/mlx5/mlx5_hws_cnt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c index c31f2f380b..41edd19bb8 100644 --- a/drivers/net/mlx5/mlx5_hws_cnt.c +++ b/drivers/net/mlx5/mlx5_hws_cnt.c @@ -719,7 +719,9 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh, * Maybe blocked for at most 200ms here. */ rte_spinlock_lock(&sh->cpool_lock); - LIST_REMOVE(cpool, next); + /* Try to remove cpool before it was added to list caused segfault. */ + if (!LIST_EMPTY(&sh->hws_cpool_list) && cpool->next.le_prev) + LIST_REMOVE(cpool, next); rte_spinlock_unlock(&sh->cpool_lock); if (cpool->cfg.host_cpool == NULL) { if (--sh->cnt_svc->refcnt == 0) -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-07-12 18:40:18.361890816 +0800 +++ 0095-net-mlx5-fix-crash-on-counter-pool-destroy.patch 2024-07-12 18:40:14.336594199 +0800 @@ -1 +1 @@ -From 3331d59551cdecd2db3a2064a7d6e4bf9396b849 Mon Sep 17 00:00:00 2001 +From 160e8f583bea1ed2de9bc8d5081b98633596b53b Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 3331d59551cdecd2db3a2064a7d6e4bf9396b849 ] @@ -31 +33,0 @@ -Cc: stable@dpdk.org @@ -40 +42 @@ -index 36d422bdfa..a46a4bd94e 100644 +index c31f2f380b..41edd19bb8 100644 @@ -43 +45 @@ -@@ -718,7 +718,9 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh, +@@ -719,7 +719,9 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,