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 0FA1143E57 for ; Sat, 13 Apr 2024 14:54:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0987940294; Sat, 13 Apr 2024 14:54:42 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2076.outbound.protection.outlook.com [40.107.244.76]) by mails.dpdk.org (Postfix) with ESMTP id 94F9240294 for ; Sat, 13 Apr 2024 14:54:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ibNA+1jYv/2LzkZpVxB0oQFtTPAayLJzcQnEDy3LZloFc0DZeXt6g/7I3LJ2/XHWeOPm1Y45Pt7VQc+5+7f6j9oIU9mLqGpGAKRANFSFz6VLfnA29qFRz4T6lmXFVM2dmkjr+ngcJt52qfmfDOqzqR7YkYpfSvwlo2wLE7v6Fxh4rIEnTdOicWCpBcljoFMIG4Tq7cHAA3C6jhIhWX3uTt2XjECfCvDeRhSxU12v4DN3rxaeL+fKZRh6cOQ/d2PR59NAwSPbwFNO7TGfnDImBS3mvVJN806C+U2V6OOlXlbMAa3PzDd2Be7ZirgJvs97NUFgV1ucXlGn/hlXsNMnlA== 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=l8/bRdMs6BR50GJQ0bqZG27P2kyVGnvgIoM0QVKjjGw=; b=njpEYy2dQCvwC2NBN8Eny6XVIybSOVSJeDs+3ToM+z2gKrU9O3QiMHhFI8T7deoQoHEMcLgqmuR1HTaxRn+lkZz/f0euuIVsy8jjzGLkAG2L9HbeyxjS+hAh/AQFADHLJYiO8vSd1y+erK9l2nJQJ6SSN6jUuzyK44LP73xCpgHiJ8dNjeFit9WJovQDpO5TjvaZStv7ew5qlTcjJ72Eh5cBpEEVCwtQTpIsUOQQURwPtZRyXJp2XEsoWHBlzui25RkPUXLBLmBeTuz8R09YbrEzDBEwTB5edZLmnOuH7SVPZpjdTaXwsRaYZBrD0pFTZjj8bWXgCPGgY4nUMWhUZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=huawei.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=l8/bRdMs6BR50GJQ0bqZG27P2kyVGnvgIoM0QVKjjGw=; b=PooRZ/9IHPqZU4mKnTIRiWRNODy6+y+JqpDntA0xdGSh+cpULDb4Z7kdaiq9m27QGWQ43VdQTZlCPn1ByVUwJEsh5Eenfc2jRQxh7iTQYD4LPAi3zPX0X6lUWlzzlG+NHOZE4F+TZP2xe8HV8NYhtEGGgOQrUElnYEedwUOvEmg0z+9Ihr4yeEHDy12Jqj0juRCBX8fHHWDnK8xrWY8zdv/tBnDcZPB9tcXIfO4kIVq2fNYvmLe053q4OhkoBynRyZgzdzeHpHImFBJmCmMlXix3m+dQOi8OMRoaszz7NFjnkqtpthGt6bDSFfLJZLvjfiSoRQEoLuzPYneaqM77wQ== Received: from SJ0PR03CA0014.namprd03.prod.outlook.com (2603:10b6:a03:33a::19) by SA0PR12MB4414.namprd12.prod.outlook.com (2603:10b6:806:9a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.43; Sat, 13 Apr 2024 12:54:38 +0000 Received: from SJ1PEPF00001CE1.namprd05.prod.outlook.com (2603:10b6:a03:33a:cafe::c7) by SJ0PR03CA0014.outlook.office365.com (2603:10b6:a03:33a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.31 via Frontend Transport; Sat, 13 Apr 2024 12:54:37 +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 SJ1PEPF00001CE1.mail.protection.outlook.com (10.167.242.9) 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 12:54:37 +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 05:54:24 -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.1258.12; Sat, 13 Apr 2024 05:54:23 -0700 From: Xueming Li To: Pengfei Sun CC: Yunjian Wang , Dariusz Sosnowski , dpdk stable Subject: patch 'net/mlx5: fix use after free when releasing Tx queues' has been queued to stable release 23.11.1 Date: Sat, 13 Apr 2024 20:48:48 +0800 Message-ID: <20240413125005.725659-48-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.231.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: SJ1PEPF00001CE1:EE_|SA0PR12MB4414:EE_ X-MS-Office365-Filtering-Correlation-Id: 539018e5-34e6-45b1-adef-08dc5bb8e028 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 89zNR+U9kIT7yHs4zBcg65Jjfv7x1m4K1Bug2awC1wJg/Fio8lh8Y89wjCld14aurkc2StCKiQSCtiTPx4RAbhz3wNVu1XNM9JNBw7ezemAHRhRYv2lewLdeR1YyhxCdld9s6a4PHzXNcw4Sn1v6x4/6TaqEoL28CN3D0mnHSi53UvSdpRPcXDQSnY9/hZVbTbwWNo54I46anrUEHNzfwdiqCPefPuXFMlT1B8faKHmKWD8NZ2v4yQP/HDgcktqGHwNxuf8AbLMx+Am8VoLbafn+OgQBB5PGZhOcUIJaQGyIBPMjihTqVQ9CsaStB/eZmoajpgJYhORsw5eVrfB5IzihlJyI4Ze2jD6fju58GOib8hcK2WL6uoquXsJJd4GjrEFqbcYDWy5Qpw0tm49Qm7Wf3P4I4ZcwAHeWsJEpfx/m/COulycC+TYND0hkupAvXpLi8pzqU/UlCUqsHqQl1yRHE22VjsZfiroZEuTaUo7Ps2QRAzhEe3Q3o+lqRpCeLlIC4PHD65U/khPkrF0w7hlFAhOLiP8RUaO7X+OzLQNDYiLk0DZ4z8lT9jedbYyY6olUw2iLW8ymWXoLZ42xuhXI83KAi33oLpUwnfzFkonQ2bJa8EVf1lgaIsIqx/G0bmTvqG9+vTzdqEhvhnoCMUhVPxp7e5ZvkNO1Gu3Szumdv7rj9rohJkYLjli3p/wmUWPSXHeQsifDI7hUypar+PQ4CxflCXHeelGrO62meEAIJ8ujJj1sjs/9E1rIbwge 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)(82310400014)(36860700004)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2024 12:54:37.2171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 539018e5-34e6-45b1-adef-08dc5bb8e028 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: SJ1PEPF00001CE1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4414 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=213cb8806857a4dad0b870c4b81b055e616eaa90 Thanks. Xueming Li --- >From 213cb8806857a4dad0b870c4b81b055e616eaa90 Mon Sep 17 00:00:00 2001 From: Pengfei Sun Date: Tue, 20 Feb 2024 17:31:39 +0800 Subject: [PATCH] net/mlx5: fix use after free when releasing Tx queues Cc: Xueming Li [ upstream commit b805b7c451f1ee5bafa5628ee67f3a495f6a8682 ] In function mlx5_dev_configure, dev->data->tx_queues is assigned to priv->txqs. When a member is removed from a bond, the function eth_dev_tx_queue_config is called to release dev->data->tx_queues. However, function mlx5_dev_close will access priv->txqs again and cause the use after free problem. In function mlx5_dev_close, before free priv->txqs, we add a check that dev->data->tx_queues is not NULL. build/app/dpdk-testpmd -c7 -a 0000:08:00.2 -- -i --nb-cores=2 --total-num-mbufs=2048 testpmd> port stop 0 testpmd> create bonding device 4 0 testpmd> add bonding member 0 1 testpmd> remove bonding member 0 1 testpmd> quit ASan reports: ==2571911==ERROR: AddressSanitizer: heap-use-after-free on address 0x000174529880 at pc 0x0000113c8440 bp 0xffffefae0ea0 sp 0xffffefae0eb0 READ of size 8 at 0x000174529880 thread T0 #0 0x113c843c in mlx5_txq_release ../drivers/net/mlx5/mlx5_txq.c: 1203 #1 0xffdb53c in mlx5_dev_close ../drivers/net/mlx5/mlx5.c:2286 #2 0xe12dc0 in rte_eth_dev_close ../lib/ethdev/rte_ethdev.c:1877 #3 0x6bac1c in close_port ../app/test-pmd/testpmd.c:3540 #4 0x6bc320 in pmd_test_exit ../app/test-pmd/testpmd.c:3808 #5 0x6c1a94 in main ../app/test-pmd/testpmd.c:4759 #6 0xffff9328f038 (/usr/lib64/libc.so.6+0x2b038) #7 0xffff9328f110 in __libc_start_main (/usr/lib64/libc.so.6+ 0x2b110) Fixes: 6e78005a9b30 ("net/mlx5: add reference counter on DPDK Tx queues") Reported-by: Yunjian Wang Signed-off-by: Pengfei Sun Acked-by: Dariusz Sosnowski --- drivers/net/mlx5/mlx5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 3a182de248..6b5a4da430 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2279,7 +2279,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) mlx5_free(priv->rxq_privs); priv->rxq_privs = NULL; } - if (priv->txqs != NULL) { + if (priv->txqs != NULL && dev->data->tx_queues != NULL) { /* XXX race condition if mlx5_tx_burst() is still running. */ rte_delay_us_sleep(1000); for (i = 0; (i != priv->txqs_n); ++i) -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-04-13 20:43:06.527472634 +0800 +++ 0048-net-mlx5-fix-use-after-free-when-releasing-Tx-queues.patch 2024-04-13 20:43:04.967753971 +0800 @@ -1 +1 @@ -From b805b7c451f1ee5bafa5628ee67f3a495f6a8682 Mon Sep 17 00:00:00 2001 +From 213cb8806857a4dad0b870c4b81b055e616eaa90 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit b805b7c451f1ee5bafa5628ee67f3a495f6a8682 ] @@ -40 +42,0 @@ -Cc: stable@dpdk.org @@ -50 +52 @@ -index 881c42a97a..f2ca0ae4c2 100644 +index 3a182de248..6b5a4da430 100644 @@ -53 +55 @@ -@@ -2362,7 +2362,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) +@@ -2279,7 +2279,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)