From patchwork Tue Oct 15 09:32:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13836000 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2087.outbound.protection.outlook.com [40.107.92.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63B3B1BF2B for ; Tue, 15 Oct 2024 09:33:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984792; cv=fail; b=drIy0qWFlsHh4a1Mrg+1BCFdI4rToTpeSmK10bBuQdT8PRlLd5y/aj7VCIlDuLkSTU0Bl2oq7t4Gz/OyKdFjyUoiyZYZs4PvQJV06nHxcufiMcLkcNxJ4YuVvRe2QVpKxb9wxWB7vIF5Xx9nVFCwLmSUVTk7vertTXTj6T+GBaQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984792; c=relaxed/simple; bh=Klh9tf+RKnq387o+GTRyyqGKQGIqG+vh/hTTw18ugNM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jiPF0jEG/mFV73zy9KNF7hFbl6eyL1qwsLehKR9hb6O5MQdf574wItMO9RXNHSrYJgf41JemSiqZiQdkWdymJIUFUGASFJ75xkwhWApCOMOP+qcdVEyHeTA3RhYMaNRzMW+JuPNAi3TixPNDDPBfpw8wstBVEWjXewV0ZrvIUNI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=LA6vtA5C; arc=fail smtp.client-ip=40.107.92.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="LA6vtA5C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QbZZVhX7s4XPkm4BQ9cCXgaxLEXcuy4TPnv6drYGRT+/XyF8LL1nj/StecT69TxflEopzHGJ3RhxZIEJax6zGeOy4NG8/RzVv6yJ5Wf+CpeBNWwk4ohzDgc+r3N9IIcT3CFo6ghL8WIAfHk5P/B9iSgZaxDWASLddX+a242QCW5ZT53aprzY7jAg9eEyXCacEJkv4/zx/tCvNkUp7HJJ1C6d5r8uwMd7yBfylkIIDjYchD8se8Xq5Hr7/zZSrcHebEpGzyt11twkMhYLe4IuhXTb7TM1Apx1bQpMTRn0eIDoEoAbnCMEJLAKPjfWgRnnioJuVOdf53yLkKf5nLutAw== 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=4/oTl0SYpjh8HWUL4ke9Ao1JPwf/fztrGvApNp5g4OA=; b=KpiolyRbfWDfNjTt5kibA3bq5tGYQRlYLbS+p5zGokU5OemYuSb5rVPU5pssFR6izsbc6J6R0itLEA/VFb1SExu1m6KIvgPeAyMf70J8AChmthKMpFDP3D4SUWlKboc0L4HVH5x4dW96zkeioVCY3I5rZNliGYGmLfT5M/Q2jOZT1+2dNqf0Y2F9Q6Zmn15LoIxOZNfXU+5WTsaP4pE1dtp6fYIH58ktL5EEOOrCyG2cWreMMSLS8daDtaXUpm+c3Jo+rKtoZaiC/FFyuBMSSGEoS/ZCMqav6UNc/Ta+rXgTVd+mjhVI8Alb76wp1/mxRu7rDxdinwSJE/M9xkj3yw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=4/oTl0SYpjh8HWUL4ke9Ao1JPwf/fztrGvApNp5g4OA=; b=LA6vtA5CNYawCmrSy63wJucZnl/0AFJpZdEChhS6QlaypVd5fYWyVHsxiFw5zTVTY/PzsOXxXfpknuq7Ehs7DNOlSsHubi3ANn6c9fclJbpeqfYKE01AQK+bjiqy+pPwky7buKPzcVc66oWg5KoHhelib/ANT8wkUDTDRr4V731DkkTfQ/ta4i/uEpMBJZiEDGApcoDvZGrntwDueQPFSOnJMh63ILuEkn+1QTkpzLF1CPmuEeqLTKtD8xScLf2/eZAAE+Blwq0VM6A01p/LFVLZA2snJidjFAdsGtKdIbpCiG4Bu6tOURIFPGRAJ03D2pQcpTFKOeVmF56W+oWmcg== Received: from SJ0PR13CA0201.namprd13.prod.outlook.com (2603:10b6:a03:2c3::26) by SJ2PR12MB8160.namprd12.prod.outlook.com (2603:10b6:a03:4af::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 09:33:06 +0000 Received: from CO1PEPF000044F5.namprd05.prod.outlook.com (2603:10b6:a03:2c3:cafe::17) by SJ0PR13CA0201.outlook.office365.com (2603:10b6:a03:2c3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:05 +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 CO1PEPF000044F5.mail.protection.outlook.com (10.167.241.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:05 +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; Tue, 15 Oct 2024 02:32:51 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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; Tue, 15 Oct 2024 02:32:50 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 15 Oct 2024 02:32:47 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Yevgeny Kliteynik , kernel test robot , Itamar Gozlan , Tariq Toukan Subject: [PATCH net 1/8] net/mlx5: HWS, removed wrong access to a number of rules variable Date: Tue, 15 Oct 2024 12:32:01 +0300 Message-ID: <20241015093208.197603-2-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241015093208.197603-1-tariqt@nvidia.com> References: <20241015093208.197603-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F5:EE_|SJ2PR12MB8160:EE_ X-MS-Office365-Filtering-Correlation-Id: 527aee9b-b574-4434-f762-08dcecfc5f59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: 7rewwdozX8cmUNuYCZ7g2zLVvtkmX6+oomzuEFLhRn7UKQFw2YV8P/rxBfZvTMe6Rhb6G7muc4yus+94th3q1qU9V5WHq5iNzpXIDOK+/zBQqkXn2jbMN7RXTphJXOsOuK9HJc5cAJ4dLlZRNhiGRHa98OAV0BqURUNEr6v3bzE/B1KOPdInq5rnOI7ZVrINwq50EvZJfHGtVRG5yUNnDWknZEvPZg6OrlFhCRzdP0vEjm2XJbcG218LnVY9vopw/RiQ2q7grTsVFSMI9RbxDJivujUQykNTPyilo+nHT9EvHBERJkCVO1IYfQgOWO4OIIlwLDfa+TngCWsq/ueTGy5+aLpyRqwzUfNQZFO7p+L6Wse4bEs0EhXsTOhotnTLA1Pl09h1/Y/4pyhaKX7gP84NPYCbmktjteldqKTJSMjfwBIOj7uSeracEFUURmz4EKqCBqioHbfmdl2raHwAeKVXSfYnRLdl2IybIEd0IIVayUlB2BE09KmxO2w/d7bqkZcASk06+syyqjh+EYFoB2dHIlrYr1VcPu9+qbJ/F6usVVeqj1EbY1UFq2x9+dicEbLylEyWc0tT+QBuY12dK+00BMuOzbOsuAfcR2PkxJpXQLeOqKf0v8R/l3Vu+WSgCCxi3s/LWaqRRf/RNJpxei+xA0jWYJoAHPzyeIxNjXCBrfjfyNdkP4ZP6EXd14+Oziz3d3mxklA3PTCVHIKnU6WbcdWFAR/7GPgkYuq0ohRmyXYZ+59urEMs1oBV+iIejMZJQ8Xa7zjanU4kYXmvjW3V87Dbs/+u8qSB/FFaa4xAXp/RPnlm9aFydYSuN4d+eyaXDTXpLN9Mdcu5uWWfq8AJSq9wZk1jSOnNzCCw+E3cWI4+ubbm7UY6kRNrYsSLwp5srq075iwseZf2VUty6mV9yBqy7bE78RytEox86j0SleHZNjbfbKLeq0nu/sPlfu60LR4zx9MnpAwhWMGR/PwMTrzYHQIp8k5jz/tq/eUM9UCfS/Pz7noTCX0ki/oqslgQLfvGJLagzxUKrxeur+Odw9ilUNecd9s9D855flY/h5lXlFa42W7hcRegX5aJkHE/Pp4vtSOnXFjZ9neMC++gjCTmqCd/yTUwfcxELX/T7/e5MP340DEWqbOCyJwDkIs0DDrzkNCSOaYUA5HKxVtERAST1Ox5NbA6gijwMXGXLWVo9yufrRdngVX7qSl7r90QHsd5Lcu75q6qviIblsH5VGgvxC40Wz4PtvN/Y30d4ltmfYcGE1410l7IQ++7gDVE4n4V0ZlaPgDPw8lL8rC1va8u5VPgm1QoNljLNvni+XlEFVppbciejn/Up7Up1p0A/NNW3lmm+5fLWUtbpIjJIJbLTnVCF/YozMAXH3EHdMA0LNOCcAVcXcQ6G4X8 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)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:33:05.3850 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 527aee9b-b574-4434-f762-08dcecfc5f59 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: CO1PEPF000044F5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8160 X-Patchwork-Delegate: kuba@kernel.org From: Yevgeny Kliteynik Removed wrong access to the num_of_rules field of the matcher. This is a usual u32 variable, but the access was as if it was atomic. This fixes the following CI warnings: mlx5hws_bwc.c:708:17: warning: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0 bytes) [-Watomic-alignment] Fixes: 510f9f61a112 ("net/mlx5: HWS, added API and enabled HWS support") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202409291101.6NdtMFVC-lkp@intel.com/ Signed-off-by: Yevgeny Kliteynik Reviewed-by: Itamar Gozlan Signed-off-by: Tariq Toukan --- .../ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_bwc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_bwc.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_bwc.c index bd52b05db367..8f3a6f9d703d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_bwc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_bwc.c @@ -691,7 +691,6 @@ static int hws_bwc_matcher_move(struct mlx5hws_bwc_matcher *bwc_matcher) static int hws_bwc_matcher_rehash_size(struct mlx5hws_bwc_matcher *bwc_matcher) { - u32 num_of_rules; int ret; /* If the current matcher size is already at its max size, we can't @@ -705,8 +704,7 @@ hws_bwc_matcher_rehash_size(struct mlx5hws_bwc_matcher *bwc_matcher) * Need to check again if we really need rehash. * If the reason for rehash was size, but not any more - skip rehash. */ - num_of_rules = __atomic_load_n(&bwc_matcher->num_of_rules, __ATOMIC_RELAXED); - if (!hws_bwc_matcher_rehash_size_needed(bwc_matcher, num_of_rules)) + if (!hws_bwc_matcher_rehash_size_needed(bwc_matcher, bwc_matcher->num_of_rules)) return 0; /* Now we're done all the checking - do the rehash: From patchwork Tue Oct 15 09:32:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13836002 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2077.outbound.protection.outlook.com [40.107.94.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDC881DD86F for ; Tue, 15 Oct 2024 09:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984797; cv=fail; b=swPjCYLC1sV6Kv0qgaHL/u+1jc6sK+qeiwCiUqCyO33yiWzFmJ9X0S1YxEYWwRKqpg9xaQjsZimaeBu+5joNtAuhno7a5UGncSkIXUYrKIzKMkzw0qglcNNuA9iS8qeSOIb4G8MIskw32qVQXzKJaRRWPKFHOHvAW5D4rTwem90= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984797; c=relaxed/simple; bh=dJhCLw46UoKGig407A7C7L7z4KrzUYKLhcsaJJAUBcA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l0kmaL4choOCo4n/GkuUEoUo8UEBqbgZ5uO6xoUPBJSkoBMTXu5YSp1r3v15voOzqLDwuYXlNPxuOr71T5rpxPNoQYspdbblbdKq0pb7qnrZs3QRuAZGQvLrhjvc60AS0fkwoPbhXKg2u7vodKbrX9z8pme1lJ/4CPK2qTHYMls= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=HXR0s+/A; arc=fail smtp.client-ip=40.107.94.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="HXR0s+/A" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WW7zdHYJMkUDKAym1fP9PFaYiAwQ0IT7z2d5wBY5hKFUD9VftdJtEuaBnwS9yhkzRdCPKih9Wz0bfk97AN83An3yi6jvixVkt5xIKVOcvTyfv3JyrGZ2DG0diBOA2cvbv14gF87qYarMg3qthpPuOoWukSlORBVDhGXAiaNcmovEpwVhQVT3/GmvpRynx+RFnPr6CgvmBL/elZJea1xFiJVnl+g/2/Bs3hD1YOgzuDYQErTvlcVP+oN7m48sQcmMKkjm23oxWIWksfyW/9lRtolBLpi87/MxaVFeEfP86pXLgZrCKx6elmzDnY9rlhO0egcI1yyhDjjMYiTjXyvrqQ== 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=Avu/WbCgMHj8qu3SX2hchGZIBQX4EdgppUAtD3VOby8=; b=K1Ff+IkDgnX3trUsfX48HjgoLS5CkWXBrh22m1ybHgSWZUsUlD+Q6m0/AZPLCVLybdyNwXhqQGM9LelHTYuPEWJQfVR47yf6u3Uc2ATlqqavqsH6htVVuCt9cyp6mLY/rD6krv/SWVDVAvRspmEPOZzGNsDktX+ZOQrmpoYAp80KfwocG9nje9wVJV+xP6yFj4tvI4L11qdkaj4RnqSXtp/tkrW6E54zO1hF8ac3EZwxr7xJ1tUqOa5KOar+KPXFMfNiMM/P+xPcI3fZ+7F4VfFjZjQFvpcKKNcbDDh+DSumucumqlsMoUjHxq7hN91thAkVVwAReQvZAeyJNm4KaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=Avu/WbCgMHj8qu3SX2hchGZIBQX4EdgppUAtD3VOby8=; b=HXR0s+/A9d37Q4LdCJn0CQf2XgIzB6nzNDy8woIyayFkv7s7oY+o47VZcE9V+G6ytEDErh4I/eTVHN2wcEQRmVKM/5PbVqZljncosNDU9wsJvICLO2cOZPeNyr9a5mlQnKMld0H9/TZmm7xe8NqSRar/lWnY8vj0sC13uwiaqn5DIdzDDhu6xFmvw5OxQ8msInlkDM2AZoHA49N1CLIYJ8VauXovSJIyEoAEk+bz6HeDr45edCq1mBSmQiX4Gyf+034vxPNoMi5FDAYcEyw5AihWZ8hcVE/qpGuoTw7XSvVPhW18uUK7pn+xM0cUvVr+4vnoLQ806X1tJNr6zofMjg== Received: from SJ0PR03CA0207.namprd03.prod.outlook.com (2603:10b6:a03:2ef::32) by MN0PR12MB5956.namprd12.prod.outlook.com (2603:10b6:208:37f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Tue, 15 Oct 2024 09:33:10 +0000 Received: from CO1PEPF000044F1.namprd05.prod.outlook.com (2603:10b6:a03:2ef:cafe::44) by SJ0PR03CA0207.outlook.office365.com (2603:10b6:a03:2ef::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 09:33:10 +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 CO1PEPF000044F1.mail.protection.outlook.com (10.167.241.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:09 +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; Tue, 15 Oct 2024 02:32:54 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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; Tue, 15 Oct 2024 02:32:54 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 15 Oct 2024 02:32:51 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Yevgeny Kliteynik , Itamar Gozlan , Tariq Toukan Subject: [PATCH net 2/8] net/mlx5: HWS, fixed double free in error flow of definer layout Date: Tue, 15 Oct 2024 12:32:02 +0300 Message-ID: <20241015093208.197603-3-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241015093208.197603-1-tariqt@nvidia.com> References: <20241015093208.197603-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F1:EE_|MN0PR12MB5956:EE_ X-MS-Office365-Filtering-Correlation-Id: 131c1ced-1db1-4a4e-6c89-08dcecfc61b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: 6/xiOWFbrz9xhgWG6Ebv8kf+Z6Gc29TXekBHPVUuvleTtYK+d6FzrduC0szv2yabVepkF7Q+BJN9grE4EmdcXluJNFccTeuJfC0KzQY7t9t/Vjo7g80oq0AQpjJRJYtzPSSwzH7vWwoJSecMGwbvQ3GaMP1lT7jiUzLexdCkA8GwSrSAbuWWMsaUElprxqBAU21rfc526hAuLib8WK6OFNdeVBbT+wZvYUY5m0/Z2Mcb6+0HeQFyeuCuJS2iMTkxGNZuHC97dErnJCMDHFUYfYF7gmx2e4a7fq1CH1cHQWtZHu8ml1OyhOlKItCh+I2fvEsvnIdUpUVqjgxlm6X56/Mpy6gxFzl00qyrVyth8grHp0TQk25JuMIwsq2PKglNHIaIyalKAe/chXn64rlBMg7bOdE4d5vF4LTc9rZjMMF5SvY5QzC2PVQkc2VQTVwvyhJT5G0FviM184frURd/wYjAIoQSyN4BNeR1X8d+rLuK6sdFYkYflM4PS7Isf6QyESK0V8SxW8Jnr+vcZWJ96glih3CZfwNeXIe1sP+r+UgQgPUx2o/teQJ0ufwpCAR2wGL9bucvhxbDMWpw1gF6BS8PrGzdazQ3r7X2Mh7NAcooFXnWaiP90Fc3csMEHq+qshSuAHime6e7KT5V8N92jH/YUBVoFAKyUJxd9Tukuk/JeU3xnNHHgbZNAq2+5wR81hbhChpw1SjcaoH5+fWqNgy8roObK6DUgkP6oKwE3XYrRzkl1PTME11LR9by3ZEN3FSTjCByJI+xmYMnF4aOT5yVqH43EFFK/Ss6Hk98IgH/jVG0INAAo9uGH1XXKCGqfXjqJuTkJYRJ30e8wJY8YiD+iZMaJNiWvAXW33jxtlTbFzOpPGQK77XnnUq5IxL/y2o1DuZKHevDdxtyQPP97xt2wAM8HLYX8wTL1iJEF2sHR5xuBpmsb+qkCNmiOAgdus+t7laYwzTlE2NaLDuXGH9rJX/fijIAsTT9onnsK7PbRdtTWuVftL4qMDQealoOrBuFhbpMUFpwRkCI7AP1S+ZgwXHZAICkL4YkQ8Q80LKqkoPNGTaa03V9ZDJchcVY7o7JxbImTq7WM47hxsR47t3MYf/ab2IgqOYANrUueCbklQ27DNbCduIK60bBWxRfHK6lVW9pM0snuw62mWdywhbzK7PNHBVqZWtXfnUeK91Qp8TRgqb6JbrBD/FN2yopQSJ05J7mFgvItCqXO97yXsuuy1I5mexwR/vK2kNJUMTefuP5upTkWHQ0CKjtzmmtSueZbeqMGiM+0hoBb4Nady18sorL5uAXsk3H0drIPwXpl0/76QFLKNB1qsxJFi5Q5k/DKbA48Jie2qg8NGpqHbbja9becQvNR3o6VBLGZ0E94sYnD8T7gipSt+dhdOCa 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)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:33:09.3292 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 131c1ced-1db1-4a4e-6c89-08dcecfc61b1 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: CO1PEPF000044F1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5956 X-Patchwork-Delegate: kuba@kernel.org From: Yevgeny Kliteynik Fix error flow bug that could lead to double free of a buffer during a failure to calculate a suitable definer layout. Fixes: 74a778b4a63f ("net/mlx5: HWS, added definers handling") Signed-off-by: Yevgeny Kliteynik Reviewed-by: Itamar Gozlan Signed-off-by: Tariq Toukan --- .../mellanox/mlx5/core/steering/hws/mlx5hws_definer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_definer.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_definer.c index d566d2ddf424..3f4c58bada37 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_definer.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_definer.c @@ -1925,7 +1925,7 @@ mlx5hws_definer_calc_layout(struct mlx5hws_context *ctx, ret = hws_definer_conv_match_params_to_hl(ctx, mt, match_hl); if (ret) { mlx5hws_err(ctx, "Failed to convert items to header layout\n"); - goto free_fc; + goto free_match_hl; } /* Find the match definer layout for header layout match union */ @@ -1946,7 +1946,7 @@ mlx5hws_definer_calc_layout(struct mlx5hws_context *ctx, free_fc: kfree(mt->fc); - +free_match_hl: kfree(match_hl); return ret; } From patchwork Tue Oct 15 09:32:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13836001 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B7241BF2B for ; Tue, 15 Oct 2024 09:33:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984796; cv=fail; b=Lvdhx/OBq6E3WRfD6wrx/Tuo1WfRz+tgisozrFLMYnYirnkOvYz4bYOrtZu90zDHgBHZAQqz0OpMvcRugJFNae7675L91N/GUOqjuWUEisu8M43j5kpWiknc4g19YupOk/ZgUOwQMl0xgEY4Ryb3ElqxJvrEpFUB301BgQL8ZKk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984796; c=relaxed/simple; bh=RIgNXzUDW1tmaBaaaSw6YFgAL7dCEPn9cmWmfLKxyf0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CxPVFfzla76QtLOd+OwchglQrqHl34L5XCsqTbVAbZjJcttO/TvikRGIITTqp0PpdBpGqP7YV52MOL3Wr8Umt1IEMWs0Qfw0a2FTnA5L+oc07svGA4R1y18Ac9JMhed7iKqcO87t+4F96zatHPmiiajT+xcb1ouLaAbDAStd3VY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=MyvQgkGt; arc=fail smtp.client-ip=40.107.92.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="MyvQgkGt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t6lGUNUCNpQ7lSIC7ZGic1b0dHC49P0wr6G1XtTOZuX+tL5Y46OGK2VeuBIe9xNR3a6s4bl88eSAhANywQNHZLWIz8EXpELiwWCpS6UIpcjlPHryxvJ+GkmFz8NPhHml5GWpU4xGrbRmva13DRBcWDdhGZ485iGTbGMkF96dA7icObk9Ytv4ow3tIERMVEZRbbNAwhCdBDMcdsw6Qd+YdbbLVGiS2JSlXga/2tq4K/E84Q/krcryVlNrJrTq7wTI99GXbruoXylsWejAilinqDvFvwUwi56wyAtdtzuh+VY8dTUkCUIv3pY7zuXoscWvZwE1mQN7KX08xHPQbRx9sw== 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=wWhvuN1/izxpBald5CzQXQE8pPPOlTsUYXCfDfRxB3Q=; b=xwJl4y7YI1t+ymxeT0blPl26W6rJ8Ez9VeCpssF92tdOGDyhhT9Vir502/Mf2meh3ickxlfPiFNR9Sbq+FEQ3JeOHryDC88j9CY4OL1Ff2gUwihw/QmPRSsKvZ2SXQ+tnhQDm98jc4y6GURyl/SVshCfGmjOdkdHJVZ+ShmRPofnq/D610PLv5EpcQrD8AZvADii82jHxUcQa1UvICiHbBx2vcTtZXf9/ZpOoYzks+WSN4K0jCNOGj8HWEpgb6c7VrUHY8KHMiIuyazHtBHH1FTwjxHuoCAK5+sVrB8PIUk6C86S7SVunXUajzYhJ7xag4KM6ZC57idNdpZQYkbDtw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=wWhvuN1/izxpBald5CzQXQE8pPPOlTsUYXCfDfRxB3Q=; b=MyvQgkGtQJEMsM7UyCzK9cKo9UWdMiO3zaSwGIXhjb9YZ698XoL/QG4O//qj1GmnOtlQ/z2PImfFNHRvvkmfcuru20Hcj2hMwRba380RGPgcNJbAbtuiBWWpkSeGwVrIiQEj49ArX6MrSc/EJq5qrvLBG/4u92gxiWKZdaG5jUUUvkWEeSS5smI9N3ppdkDjGuJXFYMZJAkImI73qrv/TapjYCN8es+g7ncYBMWLoiHP6tsbBJeuIKIYrco4r0y9TJGgCgCB4HDPdqYsvNJCD8olXlzIMmD8mMLjLNKYSrlAF7RKFc/Xqucy5L1NBhZdLIvamVeeisL1hLI5+pSzPw== Received: from SJ0PR13CA0210.namprd13.prod.outlook.com (2603:10b6:a03:2c3::35) by BY5PR12MB4308.namprd12.prod.outlook.com (2603:10b6:a03:20a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 09:33:11 +0000 Received: from CO1PEPF000044F5.namprd05.prod.outlook.com (2603:10b6:a03:2c3:cafe::d8) by SJ0PR13CA0210.outlook.office365.com (2603:10b6:a03:2c3::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:11 +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 CO1PEPF000044F5.mail.protection.outlook.com (10.167.241.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:11 +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; Tue, 15 Oct 2024 02:32:58 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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; Tue, 15 Oct 2024 02:32:57 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 15 Oct 2024 02:32:54 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Cosmin Ratiu , Yevgeny Kliteynik , Tariq Toukan Subject: [PATCH net 3/8] net/mlx5: HWS, don't destroy more bwc queue locks than allocated Date: Tue, 15 Oct 2024 12:32:03 +0300 Message-ID: <20241015093208.197603-4-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241015093208.197603-1-tariqt@nvidia.com> References: <20241015093208.197603-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F5:EE_|BY5PR12MB4308:EE_ X-MS-Office365-Filtering-Correlation-Id: 943269eb-1488-4a98-cd45-08dcecfc62fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: vob+QhkIoBfrTYlakF1aiZ3ESkatb3+ABb+bZZa5o1ZTUCkkGdcG3vXBz4qQY124pdvNw3J6iessfiD8Q7nuumujxnWmeZaerartA9/p5tXII7gqasBJczpHEu08McwDfbUJmjhfRE+ucdwBO+pM8G7rM9bCToC/nMlx8WcDfFI5jElKOF7rDAfE0Q+UCLdftUrOgUnRR5fSw7rFNMgRTLOsRfGA8wTnZfKx5eHjq17EaEffGzoIKs7JCtR95Zsmc7wgkBGZJEziXgoC3NdDcCcFI1B8bsUggMmChrd/0dbmaq9inubzDB9HOxF2ksDmZEAP+G6LJ9pBaPHLFNF2QiKCQmHe4LX/v1yGV5YktNR3T1CSP+dvWGPBB+W4QpDPx92SKQK4doEM+gpGNXPxa7mK3RpikgHMJNTS6Xp/mMqU9oK4FctwSoC6J177UtqenkgfyKf0ZoVR46r24B9K1dtjllY/RczyD+O+pPYhWaSOVVS9wY0DrMGXQk21xXtPYi7xcypzZBHk1bntmPASK8bbALnksMnrw9aNvDQcf5pxclNtJ0KiCCU1EZtDYd97Kyq4Y8mhBO9yoZGznsFkd8Sa7sSigLDez12yp5+F4YhQm5DrW9oPFPAX3XE73PEgqYOTaBGxVvKqC+XHCluMLJHeKaCLgPlWPhb+mpBRG/CgMuxhXBvfDGV4N9Avwr//IwHRgKasNgdSQW4XpX12xZb1CoVNQeI6PnT5KfhC2JqU7l4cp2vmcbToa99b80MkcLduuRAfkND0Q24r4nbCqrzXowleoCJWzgDxBOoc+rUb2BLeuidIAXKDUlgqFurHkTdg5M71YN3Phqz66rToTByhnSt7UTmzmLGTqM3WlRUmMx5fiRn7BMj5g11+tbmn9XADe7dzHPXOgD0iOnOWjFIfyg9jjANVBjYfxocf5Ol27qBL2f6ZjffVmhdGYgr19hQhsdlJl7KRNgV3E94NHg+8Y+fRLl4qN0iLRufwRrU2GCcxiDisBwmpqqfbO/qZZDRuGNFQx0ho8lwLWA+llcNaHZ5AGU9qh4qCLklAX4JX5xrwqc2g+v1wzMSNqI+RMHnZ/U1dUgcIafJz+zZdZMeq0tIL5DTZKaeRvKG7cChic7TeTG3YisV1ixaa0qt2iDuBgwjeBWr8WaRlylD2ywgc1Iq8jeb6juRPxKnACP53mXNeit4x/0DnhCFhl9s8KqOwy57Eur/lcOiWMDLOAK+FWUbgOat3h1LLwakzCs6pOY57qwA7PmwljUK8EseqXOkMaOb9qQPHBvzeKEsNSyt7XSg9iGqOYI69W+h1ti81jpZtj3X24w/Xuol50D6AKSR2FfxTb8Fijleozf9Dnz2pCieN50OXtntyjpH8nky9J7Bd/dy3mRpTUSBhaAEO 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)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:33:11.4944 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 943269eb-1488-4a98-cd45-08dcecfc62fb 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: CO1PEPF000044F5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4308 X-Patchwork-Delegate: kuba@kernel.org From: Cosmin Ratiu hws_send_queues_bwc_locks_destroy destroyed more queue locks than allocated, leading to memory corruption (occasionally) and warnings such as DEBUG_LOCKS_WARN_ON(mutex_is_locked(lock)) in __mutex_destroy because sometimes, the 'mutex' being destroyed was random memory. The severity of this problem is proportional to the number of queues configured because the code overreaches beyond the end of the bwc_send_queue_locks array by 2x its length. Fix that by using the correct number of bwc queues. Fixes: 2ca62599aa0b ("net/mlx5: HWS, added send engine and context handling") Signed-off-by: Cosmin Ratiu Signed-off-by: Yevgeny Kliteynik Signed-off-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_send.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_send.c index 0c7989184c30..e101dc46d99e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_send.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_send.c @@ -941,7 +941,7 @@ static void __hws_send_queues_close(struct mlx5hws_context *ctx, u16 queues) static void hws_send_queues_bwc_locks_destroy(struct mlx5hws_context *ctx) { - int bwc_queues = ctx->queues - 1; + int bwc_queues = mlx5hws_bwc_queues(ctx); int i; if (!mlx5hws_context_bwc_supported(ctx)) From patchwork Tue Oct 15 09:32:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13836003 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2052.outbound.protection.outlook.com [40.107.93.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45A421DE2CE for ; Tue, 15 Oct 2024 09:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984801; cv=fail; b=EN1HvaBdWdn83lEoxZmj+DzdqK/U5LNPoP/8d8tjhYrEw2wGUTUBx8zJROhz+UY7mhNNflCIQwqvw0X2cLKYMj79R5q4dx56+gIekT+f2TMzl1FGe+vTS0HcGzMKBR4fThCMAW9DeSe8tJ9lrt/YX2PiA+5n47rvPYfTlT3HJz4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984801; c=relaxed/simple; bh=h4SBvKqh0csXw5x0ih7TmcIj/ZVhkXNuq8xwBv8f9Ls=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ts3DYe5apOJV1Psd0CvK4+5cHaHNfOV1SyUkBtez+HA257gMLkPmEPyk3saErFCXD2woTJVon0mN6f4ocYT1NJhUEI+ei/tsyGR7lz/vWzh7LD+JpZf6z0fjuDPraHo97NxaqVI6aNAkh4pN/O6L2g0eHR1KFfxSdrWNs1uo2ag= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=omcIE7eI; arc=fail smtp.client-ip=40.107.93.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="omcIE7eI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CWGORxCEKY3uhfrUHjTFte8VRJQ2wUfvkuBp1z6sHpFDwqhRtwDAouBfsO1P3nfGd8uGLVQ7mjvPUQVP3KcmTWVb7l4JL0i7dcG19SChKeRl3FCRiE89+AUxifdIUL5JcX++SoozCDXbgtSHXH4t9z5qvPEojYEYarbWSbzbOGprzrpP2wxJydVjpxKI0PfVtCQ4JBwrN6poI+VsOy1cNOvlgJ++iVUYjhP6LWtkN1Xb3TKwIqYPmsV/p0/m6h9Uc+OD7ABxWa6N5PWfgdoQ2t15iOgU++ZBeW/EQoqcnP/cnXPZUmdFAMijzv2wWiYo8Ro/W6Jy4MJPWiW2K0e5qw== 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=+QRpRKzOk6Z5AM2krmjSrA78W4K89O6nh3Cra52YaUE=; b=MkADJv7tKVRcZnS4Tt8q/6agZYcC5RLLwz9xgIvw3vRSmBNJ/ILPJzcxKa2ENQpxMItA8s53xphhFXSosgL5SWkbi1a6X+t4H0WOf344j6wqVy5CUz0iPKXFB4v8FKqYCWgw3/D1Rx8a3DLRo6/MqRHy4qGX1ksvzcTghLzCC0dHYStms3bbx7KZUEzD1shxsg6gOEt9iQGKn8UqQdes/g8hK+kfsnGmmA30Jaw+bK/y8tB5bFWRgB60jfr03tH7sAYiS2AvLCY9JP0pST9kYRXyuEsV3xe/rdCTwfgl9Ob1tOF8Z3O9ZCGVP6x6iXolqzjNlRz+T3NSXWn4zyoW6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=+QRpRKzOk6Z5AM2krmjSrA78W4K89O6nh3Cra52YaUE=; b=omcIE7eIm46Vyrpaul7TEe9LwFHJxtvzVrn4YdZjqLkqyFXT4r9IdVGku/jgSYCE77TyUGKtKNyLYLZotR56Y9W6/VGbPAdfDfkkkAseuw8Qi8glmZHQugxM/TYu18lFbmKoyDHs6ujxa1U+N+jKh7AnhKuaq7DA/rBkFIMiRP58wIX9qsVimKhK/AIMB0hp28qo0eL20ObsKLsU/Hh+S6o7t309auJ+b39TA7GkoicvIG5QrokFIQxGSlC8Kz8TsUxcwSt7oKu6VGPoAVZeJzOrmPaCMCKGZ1lMkDHtfUknUo0Q0tHPyDI5Stmo6iJuOiH6lPncQb1NJBcC4v9j0w== Received: from MW4PR04CA0147.namprd04.prod.outlook.com (2603:10b6:303:84::32) by MN2PR12MB4096.namprd12.prod.outlook.com (2603:10b6:208:1dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 09:33:16 +0000 Received: from CO1PEPF000044F2.namprd05.prod.outlook.com (2603:10b6:303:84:cafe::cd) by MW4PR04CA0147.outlook.office365.com (2603:10b6:303:84::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26 via Frontend Transport; Tue, 15 Oct 2024 09:33:15 +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 CO1PEPF000044F2.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:15 +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; Tue, 15 Oct 2024 02:33:01 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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; Tue, 15 Oct 2024 02:33:01 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 15 Oct 2024 02:32:58 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Cosmin Ratiu , Yevgeny Kliteynik , Tariq Toukan Subject: [PATCH net 4/8] net/mlx5: HWS, use lock classes for bwc locks Date: Tue, 15 Oct 2024 12:32:04 +0300 Message-ID: <20241015093208.197603-5-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241015093208.197603-1-tariqt@nvidia.com> References: <20241015093208.197603-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F2:EE_|MN2PR12MB4096:EE_ X-MS-Office365-Filtering-Correlation-Id: 0eddb625-df52-455d-9bc3-08dcecfc656b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: T9EBSuV3bYoMEJjelSWMJJpDF4HXumnTYCY5oFrR17T1m+H9UjA1C9fqFkHKPuRqeVBHnqEkWdRu8esZUii+oCfnejP7UIHqNAO7qA5OrrdPqYZk3wUD29nehxtMrTnKWMZPiTKP7lmHQ5+Y6tnHSAizVy08s8y17z4EUFigE9OJkVRcEIWG1nwHH6uMcPY2MhsrfZe+XeV27QOpPQjX99hPJ5bR9oqcdSqDTP3U1YN12ogBDYcHCo1uXBK+aqm9jftmSE9jSSlETBJvymy1OK+SHFkvR0+nucMXPXk8M+qgtwCd8R0j4dufWnD2DN9UKQ/oPMxjMHjpy0+1iOzZWiEHRVs1FyZW0JZaQLj7u4r0gWbB+pQitq1nHkppZFYonPaD31bzApN133PLKL152mX4FoYXsetoP40ZakocLmRXWADsGepFjH2MiBgnzVO3BG3P9fOTqtgjwOU+LrkIDOSdwcTUgZpNIuszE1mJvFtMVFXQWSGbcoE5rTbmjcEV+7pho/3538dZEnJlb+l7oiyi+WfyF3DHklt6DqTM7wUk6K5E6G8xQO/zkgID5jROLV+ojuGy71Mux3DPxRrnMbuUVstZQwIEj7XsCGrfQYRfLtUyNH6KcL199eilwWkTiKRWvVv3rMOcgqKIXNAOGEndSsG5F4+urFezxjiN9LIDQQq5AiGfGXxgTH0/EpP2EfdreGL4pxNQSJtK0VvuZVVsFt5AyLGS/BdIQu/6fQFbDtsZtCkEDrD/az7iFdkn6ESz4GBwzAiX9e+XvKus3tPGWqnRdZBZ3y1+Oz3zc9mpIlbbIsXHwJoMPQUyHLtSHpKeweWFafpuCYADvBZP5dP+OyMlKLjLpwa2FahtbMdBT8jOk1J6ccPiizcmGy3xAXqUSdoDc4A1g54+1w6znEw8Pam/qTvpwl3cGzTeQ41TYAI18pQKThj/YRmZmaq9JlPmx6DWJV6floZ2kpwG3yzLEwGOVmbIbXDYaopEVegEIJpEYDLqD64d2+DuIkHUdIvsZJ7emSuHMI2URsLlIDAAsSOQ4OVDzJN5oRv4i7ez0FkwoI6lEwxZRbMh7CYF6VSyiodZwSpc8XFWct7dHMIskw7ffhn+iS1oIOlkmlN9GyQ0U2eXBLEa/O0TjiK8hxv9uqXYiglafLVNhORbwnCl+ZgfN/dib8fSNd2MX8/rjLUB+dJyGVZr3YjBRgEW8o2BeMPSxnxFcTAwuQBi7V0KKaZUtfayWJMRZr6dZP5qQwkon+5ObFI8yXIAu+h2yMg6KvKpP4wzBZvmgNemGXuCZ8mvZfq0pbZCg8rESwbvyyQ5XG82YLa2IdZJF6UAdcyNk1HldnxyD21xfH08D7dCzPa5aB7eHbDawSN0dt1ivz6im9JSZ5GHlUD5qNX3 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)(36860700013)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:33:15.5670 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0eddb625-df52-455d-9bc3-08dcecfc656b 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: CO1PEPF000044F2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4096 X-Patchwork-Delegate: kuba@kernel.org From: Cosmin Ratiu The HWS BWC API uses one lock per queue and usually acquires one of them, except when doing changes which require locking all queues in order. Naturally, lockdep isn't too happy about acquiring the same lock class multiple times, so inform it that each queue lock is a different class to avoid false positives. Fixes: 2ca62599aa0b ("net/mlx5: HWS, added send engine and context handling") Signed-off-by: Cosmin Ratiu Signed-off-by: Yevgeny Kliteynik Signed-off-by: Tariq Toukan --- .../mlx5/core/steering/hws/mlx5hws_context.h | 1 + .../mlx5/core/steering/hws/mlx5hws_send.c | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_context.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_context.h index e5a7ce604334..8ab548aa402b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_context.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_context.h @@ -46,6 +46,7 @@ struct mlx5hws_context { struct mlx5hws_send_engine *send_queue; size_t queues; struct mutex *bwc_send_queue_locks; /* protect BWC queues */ + struct lock_class_key *bwc_lock_class_keys; struct list_head tbl_list; struct mlx5hws_context_debug_info debug_info; struct xarray peer_ctx_xa; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_send.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_send.c index e101dc46d99e..6d443e6ee8d9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_send.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_send.c @@ -947,8 +947,12 @@ static void hws_send_queues_bwc_locks_destroy(struct mlx5hws_context *ctx) if (!mlx5hws_context_bwc_supported(ctx)) return; - for (i = 0; i < bwc_queues; i++) + for (i = 0; i < bwc_queues; i++) { mutex_destroy(&ctx->bwc_send_queue_locks[i]); + lockdep_unregister_key(ctx->bwc_lock_class_keys + i); + } + + kfree(ctx->bwc_lock_class_keys); kfree(ctx->bwc_send_queue_locks); } @@ -977,10 +981,22 @@ static int hws_bwc_send_queues_init(struct mlx5hws_context *ctx) if (!ctx->bwc_send_queue_locks) return -ENOMEM; - for (i = 0; i < bwc_queues; i++) + ctx->bwc_lock_class_keys = kcalloc(bwc_queues, + sizeof(*ctx->bwc_lock_class_keys), + GFP_KERNEL); + if (!ctx->bwc_lock_class_keys) + goto err_lock_class_keys; + + for (i = 0; i < bwc_queues; i++) { mutex_init(&ctx->bwc_send_queue_locks[i]); + lockdep_register_key(ctx->bwc_lock_class_keys + i); + } return 0; + +err_lock_class_keys: + kfree(ctx->bwc_send_queue_locks); + return -ENOMEM; } int mlx5hws_send_queues_open(struct mlx5hws_context *ctx, From patchwork Tue Oct 15 09:32:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13836004 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2065.outbound.protection.outlook.com [40.107.244.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21F761DF731 for ; Tue, 15 Oct 2024 09:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984807; cv=fail; b=gptN1aF1+/oN9FPFHXb3Lz7Q5pJq5iQPfqpH+GADjpTr7qB7kH+VnkP4IsPYibrsc6vFyuoo0QFnb4Tc6oRjOFdf0NigiRL26LDzX1AnX/BOHFOopYqZ5peIIAHXRbUfBgI47unO0F+J/WwePuXfNl3Ek7yw8zW88JkuoOepsG8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984807; c=relaxed/simple; bh=IHryUYKqh1trjxg08vqLC2waSTyOYAWvL+P1LTokP9k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R4V9gWKEMgqHiVEU1HY1NlwtNMUW9Ek7nNVy7FOuhleEwmOM4X1Zf5APUMMVbd+j7aPe+8EzEFfwI9lJRXHHOXXz240aXipj0wd+TX0fvM/qmwm/E96x1qiZp1NVTJxeQjSFjBGRjTvtlSGPL+K5ZNvht/Ej+95LGDPQlhKPSow= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=frytr7QN; arc=fail smtp.client-ip=40.107.244.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="frytr7QN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RQzcXZHiWdB4zagdf5FO29nc5ExZXckI6HtedIKXiKydtnLK5tHvuAd6ALtI0ryTbWOWwLvnRBjfjXC6odnWlCtkiVp2phvUCWxL4kD1YHWz17YghSeDoYtxPW77KMK8M4G44RgUuFIyktFQCLi9bBXhILmke2Ixxhf31cHERSgBxXD+rVsiyQiv/HePid05f+UvsSAWv+8DWCEsj+WsirV8Z+RNK8ji0Wic9xhtHpgqmCND7Lr3TFXqA1AGbtIt7saSLLRdZWbsGdDGDn8s5V1QshzvS9eyA8J1mWOZXsI0yZc5ZdUPlSLT+anpu5uC7HUmfc/ouSxQeCnZr1emGA== 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=nuGlx8KXf6pz317HQ5azBOlTCo10KSWefuSbDDwo878=; b=PZPOa82hlS8yWbrsEvD+JJA+dtc335X4wbtIFZn5iOiUlSFw5KPyOJwHCHIrfGQirU/eJtZ4Esd4FmqxdUaP+buSjT6pKWQE/sU1McyP2L9H89wVe4EGxtAl/BPDdCP+7WgCjGmXEShX6HUdAtSZfWbWLE6aHb9E6LXUDetz3FxAEthNFuShWjum2L9KvLWgd2K/cR0SReJsH/WYnaDr5Hy/s8OsQ0jcPwbpHajE0VlNMiaxsMdG00INlnvvjWp6A0ewaZwr0C7s7OQtuhF64n0RzMsnKorXCEycwrgzTCrYPz/oZUXrJVy2HtakRGmvIR6mXwhlC68GekCdqB8vgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=nuGlx8KXf6pz317HQ5azBOlTCo10KSWefuSbDDwo878=; b=frytr7QN1y/5L8USpn+n/ZY55UTj9WYGG5QM+ve32Q4beOXU8PxkpAA5ZjaCHKf8KDv8QWa9LEzMBeR3pCv2ZvBQ3HnWoZ2M/3oXTz5MYj1Jj/yWtJX0dGZLrHWDFYRXcboYHFxPpMfeSTlv/zeXsCeG+W1m7T01yMBjyqGmvH9x/u0aOCppL8rABP48ht/oxpb9UEAfsefpVRcxqDKA9QvhhlvcKdF7C2my6cRBjTCsLNODUUDWpLUyfH1XSMcIwYoI0ZlBlnLzIHc4HQEzH+uzL3oWoTwOZF9lEYAADDiM89FHaXGRVoOgHf+PfCvHIi5m0otdopZ21eFwEZo99g== Received: from SJ0PR03CA0107.namprd03.prod.outlook.com (2603:10b6:a03:333::22) by SA0PR12MB4382.namprd12.prod.outlook.com (2603:10b6:806:9a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 09:33:23 +0000 Received: from MWH0EPF000971E4.namprd02.prod.outlook.com (2603:10b6:a03:333:cafe::2b) by SJ0PR03CA0107.outlook.office365.com (2603:10b6:a03:333::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26 via Frontend Transport; Tue, 15 Oct 2024 09:33:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000971E4.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:22 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 15 Oct 2024 02:33:05 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 15 Oct 2024 02:33:04 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 15 Oct 2024 02:33:01 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Maher Sanalla , Tariq Toukan Subject: [PATCH net 5/8] net/mlx5: Check for invalid vector index on EQ creation Date: Tue, 15 Oct 2024 12:32:05 +0300 Message-ID: <20241015093208.197603-6-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241015093208.197603-1-tariqt@nvidia.com> References: <20241015093208.197603-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E4:EE_|SA0PR12MB4382:EE_ X-MS-Office365-Filtering-Correlation-Id: c37d66ca-9705-47e7-eb9d-08dcecfc696f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: D4bIAT+4CwlZQgVy8EQpWwC+oTabJEexdTOJ+663OI6Bp8ljdhdbz7uiug9jhqSzYiZay24X01CY5rJq0keO4Vl9jN5D+0J+XrLxBS5UMUNGBP/Bqz8i53ZysrSGgBuxe0vfzZAXeFiPQrxUw+gPT2A9OJvloAR+vpo268vLnpi8OfstPGVf+2YkfVMfmd1Zaoj3RkbartgPUsIDYJsplFR5WUjWYyzGTo63cD92yVTkjArjvZdlNwZ22MBPe5+wxxj2xIBQB6wOKWdyNXQ4ro2CpXct7t06ZQRm2R+i2WnOqWilaszFViZ8PvFK8R8vXMOsYGiBsGIY0RKdp1KffpqK8jaC0txtqkhqKmRrQYJ+0TolzcCwGaUvqQ9P84QSL7VI1X4c0cRhbxzrFg0VAIelnjVq3G+jRw1PTxCJX7SM8NbfCyHtmS31n5QEO6reariAhb32pXvYeWunzV5mo3m3GM12xPi3Zvj/WUD6KouQvy5qDIthrT7tPOK4QuuO/xNrLiQFlZ7m0UBo4RpdRqsQthGQ8jRRmxRbvRExjD4iWY4DInHj0JkviZaVxa4myQGJ3IyKK0V3NiP9GhC2/Rm/tGASpjacBEBzdcYk7UHEf+SWvZACLLPQxfc9c972AH7I4KSCX99s5rlUIwvebd9OKb7SFzMRdDwmKNmIERyF2aJUEeGrY6xszcvDIN9Ro2AGq5I83bl7/+G0rf+1SK5KqsWNTBGv/o3j4aqOQskKuNGCkGfCSSTon4JqHwiIh1bOYpDlYrr7HGkTOokdwtOB3di8gR/OdIEUBQ08onbbIT/GW5iV3lkI7sA4XMcjx+NnN+CUHLXIqetUZJ61bPyrs5Id4QMOsDFsOXVVy6fAb58FwN4GNNb5vg7lf/VTtR34KKGbcCTzENmy8LUsZvkQrEnqU4ipV8uoRxq63KfMny0HSeuWIFFYMKHWKmLuMd2msGQt8udz7+6fJjtD/L693K0m0iosjuKdT5S2F7sACZ4OT2wk4x32Bb4lUkm8T1HYh05u33qyKJUaause4HJss2Pl5MXHKCITQCP69R1LmlNvSjdruccAiQPibRzvJs8xuPAmksyB2Qrt5gfWRh7ett85e0NDmYm5JcUEfgCgiNXzxm6VkkLQpFeEejAMJnum8Vor9+WBO5Lu3U7y1b676b6WkUNLQSvYNmGqkO0G4PrOd5pUD59RgwJ0zUU3pZlNHhCzvAw4QRMF065OcnnwQ2tEkKuh5GfzIHEm0iOTCmwslbGRwdBq9mrrtyv4cl+0CMnWbbAJNVQzbliKgV1v5BQI+HDcrG7PbA459moWn/Ifsha8ytFkotd4eHslNm/DV3HoWuhB8DLZcx2dduqJu4UcSLyZwPUEGp5NlTDFA1aOJ5PnXflKrur92oCw X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:33:22.3217 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c37d66ca-9705-47e7-eb9d-08dcecfc696f 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.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4382 X-Patchwork-Delegate: kuba@kernel.org From: Maher Sanalla Currently, mlx5 driver does not enforce vector index to be lower than the maximum number of supported completion vectors when requesting a new completion EQ. Thus, mlx5_comp_eqn_get() fails when trying to acquire an IRQ with an improper vector index. To prevent the case above, enforce that vector index value is valid and lower than maximum in mlx5_comp_eqn_get() before handling the request. Fixes: f14c1a14e632 ("net/mlx5: Allocate completion EQs dynamically") Signed-off-by: Maher Sanalla Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c index 2505f90c0b39..68cb86b37e56 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c @@ -1061,6 +1061,12 @@ int mlx5_comp_eqn_get(struct mlx5_core_dev *dev, u16 vecidx, int *eqn) struct mlx5_eq_comp *eq; int ret = 0; + if (vecidx >= table->max_comp_eqs) { + mlx5_core_dbg(dev, "Requested vector index %u should be less than %u", + vecidx, table->max_comp_eqs); + return -EINVAL; + } + mutex_lock(&table->comp_lock); eq = xa_load(&table->comp_eqs, vecidx); if (eq) { From patchwork Tue Oct 15 09:32:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13836005 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2057.outbound.protection.outlook.com [40.107.212.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2339E1E3796 for ; Tue, 15 Oct 2024 09:33:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984810; cv=fail; b=pRqV1Zakxv7n5bovDYyQy0wVldEQ+/pFH02DTagXs6Ksr6YRAeCLd26P2n2YA/6L0p/ttMrAkrrYfs3F1l0hbJUg84AQEJ+kdRQle0inEA7Oppw87vluRseLT8S8Ijz1Hx56ouJYnpJMXltel4jm5OK5GgATSoJtGyDifopW3ig= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984810; c=relaxed/simple; bh=5SpAKHEu1C8CJ3OByvrDyaeojkyDTkE1RxfgU4dhBzU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O8lO3tuUdZaVFPIpB/ZYqV2EUwgjUzMkldy+UGJijoejZOxFwrEUeAELBKD34+vBHJGzXqaFRhbd9pT3cYkAvuGX0FYEdFivzXS5BuXiY2YoqPxMAMTA2jUGFsJmoQXLx+oN3eGBMyIYMGzUQrWhGWIhX5wdeC3EupfkYFoauyw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=tEvUf7bT; arc=fail smtp.client-ip=40.107.212.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="tEvUf7bT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C7qFwPyBYtTcfR2JDaqqE5ITYRTXO8r2pe2OaSs65DQktvrAzt02fku5NK1+2R1FMaTGSf2F5UsRGT7O2cGmyT/tcNYplYlY5ULYAw2g10iNNPIRG5u+7W1vYvTV+sRzSbrUEmkgUhbrx8e10f1AyQRVqvgLlM3cSuaS/jpwTKYj086VvCohWx7YTfP0aiYl2S3V57FQ+doX/R1l2KkQLMJihpKnhPO4jPvNMkQWvLPMIw4NbNbAGnrFcCIzFQF6sfXnnpiZliYVbZMat61k0G7irn3bMyQNzuewvb392YFnB4R7k3sUV90D6u69xZoUOmFPW5eJ+/99Shque/Kmyw== 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=vy4nE7HIIcXC7o6mulFfTE90fexUD+/ES/V0qjTOnqw=; b=xi1UNdqXZEDWZYwkNtnS0WaLfQzBr8ik1c2/NlBENJCtqeENsmpFZN+xik3W5A9CL7fLvvGS63ScMRFiCseUHrwWVUhSFbHcgvui9EV5euy61tp1Z1rudJW/of/T71gSyMsyxKBrABYL1q+KaZOSa0ytXhf5l+NOQQsHyocQZEq2RhsQdOOZcrHynGKxqsP1mPyhftXe/8cCiFcFHQxVg0TQ2OXb/5cep6sB3oJWL4ClKsxR3MVzOLxe3h8x3LS34BxkhhZWtK5a4WYc/dJwDGuW36edjtzG5DTCa5ukJuu8jWuPCnVG7Rvc15THDoXrVLfXwiHp3FKZWaqZpZZmNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=vy4nE7HIIcXC7o6mulFfTE90fexUD+/ES/V0qjTOnqw=; b=tEvUf7bTZ89m6ZTgifEGkJdpoHi/iYD2QrlGN0tEXUpNi5AF79kWtKeBZQI1NOVHU9GzSuHqaKMntlFIMkSFIIoU7bEy0RtQduasn1kQn4C6cwNhfiaZ2dWFui82eqdIxl/eeJHxUoBPp9Lrj1av0R8VAGYGZ2HN0wZ73RrWPdC2fgKhKS4FAKHW3QUyXTAhFsSWlPOIEgj5jopJTrAY4n1JUeku2MmPnA/IsUEptwLgeOBXW2uJT3Pkl3ybxD7nl197Zjum3wGVS99zUsLVWgDVgadGA9NuJQnj7WF4Uacrdm44PHiZmVvkRr0gfSuC+G9Dc6XRSh/E3rK+vejQwQ== Received: from SJ0PR03CA0343.namprd03.prod.outlook.com (2603:10b6:a03:39c::18) by CH2PR12MB4165.namprd12.prod.outlook.com (2603:10b6:610:a4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 09:33:23 +0000 Received: from CO1PEPF000044F3.namprd05.prod.outlook.com (2603:10b6:a03:39c:cafe::4e) by SJ0PR03CA0343.outlook.office365.com (2603:10b6:a03:39c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 09:33:23 +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 CO1PEPF000044F3.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:23 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Tue, 15 Oct 2024 02:33:08 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 15 Oct 2024 02:33:08 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 15 Oct 2024 02:33:05 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Shay Drory , Moshe Shemesh , Tariq Toukan Subject: [PATCH net 6/8] net/mlx5: Fix command bitmask initialization Date: Tue, 15 Oct 2024 12:32:06 +0300 Message-ID: <20241015093208.197603-7-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241015093208.197603-1-tariqt@nvidia.com> References: <20241015093208.197603-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F3:EE_|CH2PR12MB4165:EE_ X-MS-Office365-Filtering-Correlation-Id: d395e572-58e1-4237-98c8-08dcecfc69df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: 0yCXKTckXaBoN7CY8L5lbxDPz7BtDEp/+UO4nQhj9kN7Gaz9ash+ifN3AdF6OMS/Rg9Zh3OPfZI34BeUOjHJD5npzngGSsT9o+QTxQJPJTVBQyLcqDBj5nJzR8Xj1hzWrEz5vmgPmUhPSF/eq3hHEXveCKI3wFJ67m8eNm67gGMRknCfh0sBzrPZh1Viaq4845xJC3Ff45U8pCe2oWnZJQ5uqfki/EZQQfOB3OZX3iryDcQKH8yA6+WxzNmrvuoFkfBQsMna1apMpk3RtNf3dUGARjrvJ4CbeW/kGmrtkmO/AHvYrh7/3QOdJxJfaGCBs8mpJsprAYWL8Zh+frT82l3GzZcZf2pbIsoJMDrbFN4cOcmDoDlJGg8V6sr5ckBktui1FYSFNrYVfZw1Bre6kao1bpcXHQTROl7mR7+VFv7v1hpSyXxbQan07fqx8zvZ9uqYxxiEa5bqZWAwRzobSxV08vPdDJ42+uxfRboytVfeM3Y+UU45wAy6QLYMzpjKpdBhEmyBRRxQhG8z2PeVFj1783i4Gj1kROVM/WEDmiB7iWqcI7apcgxO2U5t2RcgtLO4D2k7Qx/oXL6Nm1NoDjO+v0MxjuEvbXH6uf+C2y4qDSaHhQskqaQUYdQZPRu8hzjHqIrtSVyjPPl/6uDIzoZef6UT+sI9nJDVZoIMxwE3Pmaeq19QnBkM/IhaNUxwmiIXF45Upul8E5f+vhp1D/wlkYdm0qTj+wuxvMFzjKWPnYZ+TXUQTtECd1d/xn4VILzdN2i7xgDe/tSJDPowp2BIKy0MvkQG5RF48clzbd1q95ubptgUD4W9HJkClZKeI8PYm2aAZPkwh6XM0sgQn2ZwU96hahD07o/dPb/vRmxfMGbN3y9XEzyJ/X/c7DBzu/kx55XONbptpAO1kdQGsFBKSY6mO98+qvToeR6ia7X8eiBGE0Jxlk9ZrsiNcv5idNzrM4enhN6s3pOoW9rXXjj6QJnSk8a+QjNIpNkDeaMBa+SHnbsJcFDyO7foVQvMvd6/kwXgy1nbRyo1DuNHigpKS4gx6d+vasL4JgUFqFRjaWeYx4xtZkqW7EyybMVNA+EE8AZrc8wcfUxp2cq9WpG+86sOTUgWOLfjS8RPcMm1Zf5/meiAk+SK2qDc6VpZRFcwYdh/sN+xpVSoKi4b+JmrTM1yLx0Fu6ZBOxLRDVB5/tvPKkumX/x1/JkQ3JknO4ZY0WCHeibioUuu7SUNKSgNa/1p07+0ZZghTLddonPojNC0km4eRIER3FmS6Rbhv1DsK/eQMwHVryZY3dBSsGED2cr9xTGX6pEtrgWsXOjW+XAiQecRaMzJWgIxMeZ4QN+0aNq/zIH9oi2QSzgZoCDeMkRHDAQznUePo/nEJecCKQkO32QdlOWx34D+txwm 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)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:33:23.0536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d395e572-58e1-4237-98c8-08dcecfc69df 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: CO1PEPF000044F3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4165 X-Patchwork-Delegate: kuba@kernel.org From: Shay Drory Command bitmask have a dedicated bit for MANAGE_PAGES command, this bit isn't Initialize during command bitmask Initialization, only during MANAGE_PAGES. In addition, mlx5_cmd_trigger_completions() is trying to trigger completion for MANAGE_PAGES command as well. Hence, in case health error occurred before any MANAGE_PAGES command have been invoke (for example, during mlx5_enable_hca()), mlx5_cmd_trigger_completions() will try to trigger completion for MANAGE_PAGES command, which will result in null-ptr-deref error.[1] Fix it by Initialize command bitmask correctly. While at it, re-write the code for better understanding. [1] BUG: KASAN: null-ptr-deref in mlx5_cmd_trigger_completions+0x1db/0x600 [mlx5_core] Write of size 4 at addr 0000000000000214 by task kworker/u96:2/12078 CPU: 10 PID: 12078 Comm: kworker/u96:2 Not tainted 6.9.0-rc2_for_upstream_debug_2024_04_07_19_01 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Workqueue: mlx5_health0000:08:00.0 mlx5_fw_fatal_reporter_err_work [mlx5_core] Call Trace: dump_stack_lvl+0x7e/0xc0 kasan_report+0xb9/0xf0 kasan_check_range+0xec/0x190 mlx5_cmd_trigger_completions+0x1db/0x600 [mlx5_core] mlx5_cmd_flush+0x94/0x240 [mlx5_core] enter_error_state+0x6c/0xd0 [mlx5_core] mlx5_fw_fatal_reporter_err_work+0xf3/0x480 [mlx5_core] process_one_work+0x787/0x1490 ? lockdep_hardirqs_on_prepare+0x400/0x400 ? pwq_dec_nr_in_flight+0xda0/0xda0 ? assign_work+0x168/0x240 worker_thread+0x586/0xd30 ? rescuer_thread+0xae0/0xae0 kthread+0x2df/0x3b0 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x2d/0x70 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork_asm+0x11/0x20 Fixes: 9b98d395b85d ("net/mlx5: Start health poll at earlier stage of driver load") Signed-off-by: Shay Drory Reviewed-by: Moshe Shemesh Reviewed-by: Saeed Mahameed Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c index a64d96effb9e..6bd8a18e3af3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c @@ -1765,6 +1765,10 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force } } +#define MLX5_MAX_MANAGE_PAGES_CMD_ENT 1 +#define MLX5_CMD_MASK ((1UL << (cmd->vars.max_reg_cmds + \ + MLX5_MAX_MANAGE_PAGES_CMD_ENT)) - 1) + static void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev) { struct mlx5_cmd *cmd = &dev->cmd; @@ -1776,7 +1780,7 @@ static void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev) /* wait for pending handlers to complete */ mlx5_eq_synchronize_cmd_irq(dev); spin_lock_irqsave(&dev->cmd.alloc_lock, flags); - vector = ~dev->cmd.vars.bitmask & ((1ul << (1 << dev->cmd.vars.log_sz)) - 1); + vector = ~dev->cmd.vars.bitmask & MLX5_CMD_MASK; if (!vector) goto no_trig; @@ -2361,7 +2365,7 @@ int mlx5_cmd_enable(struct mlx5_core_dev *dev) cmd->state = MLX5_CMDIF_STATE_DOWN; cmd->vars.max_reg_cmds = (1 << cmd->vars.log_sz) - 1; - cmd->vars.bitmask = (1UL << cmd->vars.max_reg_cmds) - 1; + cmd->vars.bitmask = MLX5_CMD_MASK; sema_init(&cmd->vars.sem, cmd->vars.max_reg_cmds); sema_init(&cmd->vars.pages_sem, 1); From patchwork Tue Oct 15 09:32:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13836006 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2063.outbound.protection.outlook.com [40.107.92.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDEBB1E1A35 for ; Tue, 15 Oct 2024 09:33:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984814; cv=fail; b=u1ABQkKlDAQLV7Hyeome9r/7isK5zileyv7u9uLSaykOvt+ys1sZHNTbeWDnWWwICu7fBX/XJvlsj65SkIN6jenYxsCfxeJmTjxIyIgOiFvRNHvWy17715rc0ITC1+2fwX6Melb6gNDEJn9jewzSvV/DY/kygr/VWWbBddYrtWw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984814; c=relaxed/simple; bh=ESkEyyNo9zedSr0d0hCc13wdLkt8K6EOw/20NqbT3dM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l3758BloLAls8fRdxA0GjfO2yYkJfVkanmlBLtYlH8BTsBrZz4d2in2dEHwDG1ePtpzRtA7cE/9r4o6LzJP/oWondIoN05+tYh6QfdiRhjZWzRzPePoTT2RP/aBy1KJbC/tG0oCYQGC9AFQquojxS6tXRN88mVl/SVBUXTgSklA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=lLzoyOnT; arc=fail smtp.client-ip=40.107.92.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="lLzoyOnT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Vuzh4U8gQ6LYPMpgsByM1FKMdBYbAGfocnlN2aJMAqtvglP8+0YFQ8i+S7YUbsjMfVRceEORdq+T5oii+vzhwf+/u0ONqSqgnbRhO7QaeKyDnKd0HgOEe1vYc298iFcmxM8tICKrg19nR3ylqJGcZYwO59YwZIdB9QJhU/9vQIr2jS4P8IfWZy6X66avV5Cl+Bh1rwUmPLXnofIpiWya8t4FTvK0CXsgTHnuizqBzpyNV492iEE85ZhQ7Tl5BX9NhLIC2iB0+7uJEuAGh8d1prX6B2BdecksBjL0Fib6Eiz/fIEhtvr5kOVFDB8LaWb3VZJypTe8+M6lIUiwGtRI7Q== 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=wFv33Li/caZiaRCEoJIQ36lKcIABBNFkKo9pP490l7Y=; b=AEOXw0Fc1ODI0AMJHhPp7dOV4Q/R78DQKbBBVTmvnaapmlIpp5c00DJ5uNOHq0OEV6zhkard0Z90l/ZeB5cb2XM4LmFJI8XN/6ATFOYTV40Fb5FfAjLvnBiDCgrdobaihjox2Cr5RatpMfWR6iinSmykbZ4SA/7JEnQQ+AKLjVU0bPAZw3QGGSrImzWbRLhJUUIrMGkfu3MYo+/qQy8XwVwfdM5sWQUUOc/QVsyOA9v+PdxCmIfFL7C8I/nXWrtMFXcqpNCJmHCR83zrF0NF4vlvGCcMiYy0Mjpt56b4NOb8KuJdYCRRNyqraukz1UYFSmkkQMXgztN8a7yp4IRmYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=wFv33Li/caZiaRCEoJIQ36lKcIABBNFkKo9pP490l7Y=; b=lLzoyOnT4iQet3mgPs+W7yb8zEerW4JN40Psog11xcmAgPBDF+5Mq2npRUE6Cofn9VUh6AumoImidqoGrXTxlrzpj13Wgc+rxMp841MtiHQFR1yOTOKfgWuI5bFZVtzVamYW5lE/mnFUTObML5dURPpwKLRFSH8mzZFOJlzS+OJJu6AjkKcRod21ZUgbW3PboZLN5ldMr+H2+478Dv1Vtqo5svjTtih6AbTlcN8sbImEmY73CRulflifmGDpglgbyyZeAFaPZ74nEEqvPzome551l5yOFm11Y/O51GCQ4XNdNcNAX6up/4UgtiiSgV7EojQlFn7Ni3WvtUnuwhh8Zw== Received: from BYAPR11CA0045.namprd11.prod.outlook.com (2603:10b6:a03:80::22) by MN0PR12MB5980.namprd12.prod.outlook.com (2603:10b6:208:37f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 09:33:29 +0000 Received: from CO1PEPF000044EE.namprd05.prod.outlook.com (2603:10b6:a03:80:cafe::3e) by BYAPR11CA0045.outlook.office365.com (2603:10b6:a03:80::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:28 +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 CO1PEPF000044EE.mail.protection.outlook.com (10.167.241.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:27 +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; Tue, 15 Oct 2024 02:33:11 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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; Tue, 15 Oct 2024 02:33:11 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 15 Oct 2024 02:33:08 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Cosmin Ratiu , Tariq Toukan Subject: [PATCH net 7/8] net/mlx5: Unregister notifier on eswitch init failure Date: Tue, 15 Oct 2024 12:32:07 +0300 Message-ID: <20241015093208.197603-8-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241015093208.197603-1-tariqt@nvidia.com> References: <20241015093208.197603-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044EE:EE_|MN0PR12MB5980:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f62af6b-3a91-4ea1-463c-08dcecfc6c9b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: O9Op9Ni2rbpYk3Db8ng/76FwBHKoxt7AI2XDC05PKfYrjJYWmGHa2ySvcfuTRsq1BdrfLkcpp2HBE132jmsVge4BWh//brmVmw0OqXYRAPOQv7wEhnmq+m4xecRCmlAbaRIzlNsvgIV68X52aX4sK2LZf4ox6Pf+tqafO04G56OueDHofxyQtCZNGVpZDM0VFzRbvRFZE5SKq/R8OBMo/A7x7+rxvxpP0o6yFueZow1MIEneiW8qpr/Srdm6FR8UyT6pqQpOmfdclpiK2+QaJ2oW+1GzQEvnPkspJVn/jCHNUX0eCwsW3KqlWqycbeYS1+if9YaKnrMJu42Zs0Hn5kCvEQ9O+uz+4rx8Li/D8jTGQvdFkEMPaO8BrJKox7TRbI97mRQXck7jjQ/0otVFr4P2fsZR7s+pVpU+mZCL6ZOLIuyQ05lESkErVQWp+nZ6Ml8YgbvERinHVE3E1riu6kfcXPf3dxUsT0/FRmbNtH9T+YOdc5Ot0eiD3oiQh7Nv90dL14w0mqu+Mz1ceCtZfA8zWAmBZfTEYGeLYBZelhnIKxGSAoxBa36J+JFWI3ADA9R9HsTwBBn2/dFbCZ7YhTW/jdv5ISurQh5lqu0BCFlBkBChNB9dSvRsDBdZ2WJ38G2ECbbuMjjVjM5UwTKLFxXPmmOhibgSLbzoJBWXbrsubYP7tEzDG4VDVhqg9tqaspNSlp8gSDgOpZu7nqHbzof6vW6RPfVD7pmqT8GzuCWcZRMrtpbxRecgR9tIG0MzQsDcfzfSW799XyoYrV5WXKiAowfP6aXLKjSND9UfOuxpsISNVm4WAz+bXsl6QvFtOnMZTUwpFFBD/acKoOn9Rm6gPT9lyX2/7TY8USdE/2Zl7/TelMwsDAvPmpPozYKj96hpCODdKDSOt3d/NwB64Ljz2APhNBDWjNkQENSwrhz6b9+fnLYfraxkAaJIGPRW0gGXonpMe2A0zkvSWm/Qd/Mk3fcJt1z7MQCMh9aHaOhseH4JNDJw0O6PKszt7wZKOZX+atAKF9dLilICMDNC9wQ4FfZONLt+aZCghttNBkzOv5gBTLcPTCKX7sLABa45gsD3tssb5rUTRKwNFfYWKpOb7Q1q3eE0awpsrCDk5rIDHN/tYczU7klJLrLmts4wtCMIvbXOz62eBPB3ukPuoyB2XYmORwNkPqZse+aeBFuWbWe1avLI0o3dB7JnOhq4mgJpzHxWGMs3DJMHCcdrVucu8R8N6X1V6MLe/MRL+TAsgFRWBz5gnKMnGUZPoNwFF5fGicdsjUCeenJW8aWx7u9/IrJbIpZLIBci/0p0CwoRuC/fxyMqG6HSE+S7rV2am6H68AdnLSJhKUITgd5jXx3inIhXNQbykUXkEe4FkKc= 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)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:33:27.5296 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f62af6b-3a91-4ea1-463c-08dcecfc6c9b 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: CO1PEPF000044EE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5980 X-Patchwork-Delegate: kuba@kernel.org From: Cosmin Ratiu It otherwise remains registered and a subsequent attempt at eswitch enabling might trigger warnings of the sort: [ 682.589148] ------------[ cut here ]------------ [ 682.590204] notifier callback eswitch_vport_event [mlx5_core] already registered [ 682.590256] WARNING: CPU: 13 PID: 2660 at kernel/notifier.c:31 notifier_chain_register+0x3e/0x90 [...snipped] [ 682.610052] Call Trace: [ 682.610369] [ 682.610663] ? __warn+0x7c/0x110 [ 682.611050] ? notifier_chain_register+0x3e/0x90 [ 682.611556] ? report_bug+0x148/0x170 [ 682.611977] ? handle_bug+0x36/0x70 [ 682.612384] ? exc_invalid_op+0x13/0x60 [ 682.612817] ? asm_exc_invalid_op+0x16/0x20 [ 682.613284] ? notifier_chain_register+0x3e/0x90 [ 682.613789] atomic_notifier_chain_register+0x25/0x40 [ 682.614322] mlx5_eswitch_enable_locked+0x1d4/0x3b0 [mlx5_core] [ 682.614965] mlx5_eswitch_enable+0xc9/0x100 [mlx5_core] [ 682.615551] mlx5_device_enable_sriov+0x25/0x340 [mlx5_core] [ 682.616170] mlx5_core_sriov_configure+0x50/0x170 [mlx5_core] [ 682.616789] sriov_numvfs_store+0xb0/0x1b0 [ 682.617248] kernfs_fop_write_iter+0x117/0x1a0 [ 682.617734] vfs_write+0x231/0x3f0 [ 682.618138] ksys_write+0x63/0xe0 [ 682.618536] do_syscall_64+0x4c/0x100 [ 682.618958] entry_SYSCALL_64_after_hwframe+0x4b/0x53 Fixes: 7624e58a8b3a ("net/mlx5: E-switch, register event handler before arming the event") Signed-off-by: Cosmin Ratiu Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) Hi, Patch is expected to conflict with net-next. Resolution is trivial, by taking the net-next version. Thanks, Tariq diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index 17f78091ad30..7aef30dbd82d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c @@ -1489,7 +1489,7 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int num_vfs) } if (err) - goto abort; + goto err_esw_enable; esw->fdb_table.flags |= MLX5_ESW_FDB_CREATED; @@ -1503,7 +1503,8 @@ int mlx5_eswitch_enable_locked(struct mlx5_eswitch *esw, int num_vfs) return 0; -abort: +err_esw_enable: + mlx5_eq_notifier_unregister(esw->dev, &esw->nb); mlx5_esw_acls_ns_cleanup(esw); return err; } From patchwork Tue Oct 15 09:32:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13836007 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2055.outbound.protection.outlook.com [40.107.94.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F33F1E202D for ; Tue, 15 Oct 2024 09:33:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984818; cv=fail; b=OkcPrE3Qk8IFU/bkWUFMhYqnq6TswZNu0gKwsoy9QiQSraTnq8TaVJ3W8S72Zbfnxvh1oFs/XF8yQd3OHso1RaNez1rezzQSYt8MJP/gJm30FTzKQMMpCgf5+Tj60/vbn/miLN6mmK296AimhIWxYLfxC/FR0MozgHPgLpIlkN0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728984818; c=relaxed/simple; bh=ChgkT48E5QCDr4Y7q5GapL5GPNVl7FWAIf+tL1Hfktg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T4iRmput2Ax8DMuPiYPzlIgIfuQYQEu4Bnj2OZkeUrVfN7zX+eSRiqd3099B78J15o7eNiRc5CqmbNq1jatOeotN+dBFlq6Ne1wmH9q6RpegLOWygd8bpPrVNsOBjL3qOjDWJdQCwpCatpft6fx4Cca9c0QGjpnio+auZA3wCC0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=sLVRBWKA; arc=fail smtp.client-ip=40.107.94.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="sLVRBWKA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RE5Bg/LNe+I2Wm2RVaydErPI6ikK2LRnnr/VtkiQK74Fi1HX3oEbF98jugLuueZsq16uLtWvnGuYZnpB4/ULUeal9DC5DI+NaM+ulivGsi93fkj37d5U62CsQFpDB9e7Cut7v8DOIc2az4Q02iQtln9jzwGzIBmeGkPkGpdhW8XNn4C9if1KX37Ipf/XUar/Owc10VaVl8awbwT65eLpE3uxFNDH3jh9Fg/QJ9P7Ru/xDeZMq6nO8S2V4emmyWARnMIuePJqf3PLF+LEquOU2ovKduj+hJpFssFAqZoUAb7uY27eY61JO7niEoAAcZwHLp4Yr4hKf+Y4/wu3JKtPKQ== 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=7RnNPqLEllT1jEcqTOIvZ35unUd9vI/Fv6uWjWnez7Q=; b=EUveuq4aoijMi3WYrlaZbAwP2y+W+oixBO7WquiNbppSGTTzEUi8EQsJm0RPy+QkHhSMnsXyNgeBnX/mTdVA2K/A1oqPmmAMf0MsWtNVnr+pzOgwiNagsbwW/DMEoZFA6GrXaZQ2og7Ujvp9MJgElxzGlCap5UPBG02Ty/wxPF+vHn1UhKFjjD2N1IaVSduVlhHkSDFzZQRGg+vn19X8M8DhI0K3hB/TNnFeejqGblB5zyceKPRibRbn+dR0g0Ha41+Qe5DeNU7ZMbFErn7q3vEt5jU3pRij052jeX0guG3hjlmQSdjN3Joa7ItiHKm20n51OjjcTeCtz7xZEqhEHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=7RnNPqLEllT1jEcqTOIvZ35unUd9vI/Fv6uWjWnez7Q=; b=sLVRBWKAMkHDSpwk7DyDRElFHxlPNtbc0hvZKtVsdbF2Us8feWnjwLdC0u7emmXcw1eydJyLh5o0CK+Lv7mmWLQYnAwumk/I5dUoFD1kXm+JRrjN1xhadvZLYEdu3N2LkBhJcAqDS/GstJxKchkleFve+yBqbjeU1gVYufiHVceRhuzwN38+7K+iLhqYDXabsOwqNVYtghQ5Adp4o22G/jh1pMjVh8MDMurWlGi4sDFbcW5CvyQB+tWDZ718zCk6+hLf/X5cUaqsUSfy1FfkvMzA2iVsh7p15986lh7DMmePQa2iKWetWZBn3xuyb+xEX0smPY9cN6CjmLsHk9FkWA== Received: from SJ0PR03CA0087.namprd03.prod.outlook.com (2603:10b6:a03:331::32) by DM4PR12MB5867.namprd12.prod.outlook.com (2603:10b6:8:66::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 09:33:33 +0000 Received: from MWH0EPF000971E7.namprd02.prod.outlook.com (2603:10b6:a03:331:cafe::94) by SJ0PR03CA0087.outlook.office365.com (2603:10b6:a03:331::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000971E7.mail.protection.outlook.com (10.167.243.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 09:33:32 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 15 Oct 2024 02:33:15 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 15 Oct 2024 02:33:14 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 15 Oct 2024 02:33:11 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Cosmin Ratiu , Dragos Tatulea , Tariq Toukan Subject: [PATCH net 8/8] net/mlx5e: Don't call cleanup on profile rollback failure Date: Tue, 15 Oct 2024 12:32:08 +0300 Message-ID: <20241015093208.197603-9-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241015093208.197603-1-tariqt@nvidia.com> References: <20241015093208.197603-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E7:EE_|DM4PR12MB5867:EE_ X-MS-Office365-Filtering-Correlation-Id: b1b3311c-4da5-4b89-3577-08dcecfc6f4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: tRW5ZOMYceJSR614btPI0eBw7Gjc1J3BptTpFg3CIWfxAqc10q2V7xD5yAoF0sS3izsJ82CDjQjBtujyQkWpP912FgCSzeYYyYDswmYsqIjNVr7ULKFn3/JwtWM8o2VLQlQcIqDTcxAgmfL7IaSHNJglMKa6JuXSMcM1/MjwyaGLc1/+YpK7rQLTLNT3FRe4h8WK+Ub22GcVLQoZa1I1nrQ7+EM1g/cmkJTd9BC9V581KRPjge0mhpLcwvICvhbiUf1qA5CNBy/QjN6uA3CWkIYeSTZYPQWgjI8PA6Ur2reWloG78A0k2+STb0zD5aBi9WoxtwZLr1c1Y2yfiv3xDKVj0UXIxaD4Sie5d6EQpzvF+57I0CvQiPqbPPQ8+M8cdTTGR9bTWqnjy1DiWTnf6tTOH1hbZdH9xRQTyJDfZE02S56s9FL3sGbFnnLn5rq/8K6Cjq6O9is3JgCAXJblNtxkgy1P/uh8iSH9L8pWh5NLTokgHo+O1tH6b4YwqMC7ZLoqKXkqK1MkIFz/cuKmBlIMaJhbRgsSHHyHNBeUZUKpTT1cz1uL2R67tZQ7UiyBtD+CrLXcnwgwn+e4oaOZD2dP+jCr0mW9MWE3r1DPmgOl4Raj+Jy92ifJgiaRu7tMaeFIcDYeMiB1ok7uCZlee7SiOTHKnrUf0oR/OkoxFDBoQ6Zm3mfC+NIxjPI+8FrSydOAPjOwADevNuHCb2TTP6p67Z4xTeWVpW4OlmD48SZEZ7PROh8m41T70E5sHsOhKjFizFain3jNT9glA6HooD8mM9LMDTFMe3X1Fc4lFgZCqaB+8jBfebIAvgMtiz18bFPsG14h+XDPagdxUZquCAPcto/xHdlHcehSeGs/NfSrQF2rgGJKQ6uo45tbGLKZBR2fkIbbCIj5ap3o6v4G5uF3QyUxN4qnDFR9FJndUYvGQl10po5rVqtRxpKCGJqoLXks45XQtwJ7uc9tEs4zK2aeHmBYNAWTxgrnRyQgmYdsd2qEtJnw4p4DXiKhbZsagpj77xHuYQh5iD4XQX87orhw+4il8f6vooGza2UpPtRz7SrdEEc8rgOrYTKsU7LTA/4IRvlRN1VXvijBaACi7AZj7Tp2ZXX+13L9fIoC/G0P0Acs8S2Fq8I5xJ2YRPmE15RAwhg2JS5NgM5IbhAz2n890lrYIu6A12afHzCHN3jcsYm321cBaPBB0fFgsxAvtiNmley79s/wIWMDUwNx1n37Eb3Z1h6WfqPoC4IFrvwD5Xk33icmguo7QUEK6G4deR6KxtUYtqvp5kKFHzpzCLTyXFhZAurm8vQPMe2ft38XBkM/9+4yduLjj79wmd/CPjgOxL7c2aJ7jHzlO2AymJvYnAKlEXGoSqQCyOJya6wyRDPs3pp/ICz7EgnsoZLv X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:33:32.1581 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1b3311c-4da5-4b89-3577-08dcecfc6f4f 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.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5867 X-Patchwork-Delegate: kuba@kernel.org From: Cosmin Ratiu When profile rollback fails in mlx5e_netdev_change_profile, the netdev profile var is left set to NULL. Avoid a crash when unloading the driver by not calling profile->cleanup in such a case. This was encountered while testing, with the original trigger that the wq rescuer thread creation got interrupted (presumably due to Ctrl+C-ing modprobe), which gets converted to ENOMEM (-12) by mlx5e_priv_init, the profile rollback also fails for the same reason (signal still active) so the profile is left as NULL, leading to a crash later in _mlx5e_remove. [ 732.473932] mlx5_core 0000:08:00.1: E-Switch: Unload vfs: mode(OFFLOADS), nvfs(2), necvfs(0), active vports(2) [ 734.525513] workqueue: Failed to create a rescuer kthread for wq "mlx5e": -EINTR [ 734.557372] mlx5_core 0000:08:00.1: mlx5e_netdev_init_profile:6235:(pid 6086): mlx5e_priv_init failed, err=-12 [ 734.559187] mlx5_core 0000:08:00.1 eth3: mlx5e_netdev_change_profile: new profile init failed, -12 [ 734.560153] workqueue: Failed to create a rescuer kthread for wq "mlx5e": -EINTR [ 734.589378] mlx5_core 0000:08:00.1: mlx5e_netdev_init_profile:6235:(pid 6086): mlx5e_priv_init failed, err=-12 [ 734.591136] mlx5_core 0000:08:00.1 eth3: mlx5e_netdev_change_profile: failed to rollback to orig profile, -12 [ 745.537492] BUG: kernel NULL pointer dereference, address: 0000000000000008 [ 745.538222] #PF: supervisor read access in kernel mode [ 745.551290] Call Trace: [ 745.551590] [ 745.551866] ? __die+0x20/0x60 [ 745.552218] ? page_fault_oops+0x150/0x400 [ 745.555307] ? exc_page_fault+0x79/0x240 [ 745.555729] ? asm_exc_page_fault+0x22/0x30 [ 745.556166] ? mlx5e_remove+0x6b/0xb0 [mlx5_core] [ 745.556698] auxiliary_bus_remove+0x18/0x30 [ 745.557134] device_release_driver_internal+0x1df/0x240 [ 745.557654] bus_remove_device+0xd7/0x140 [ 745.558075] device_del+0x15b/0x3c0 [ 745.558456] mlx5_rescan_drivers_locked.part.0+0xb1/0x2f0 [mlx5_core] [ 745.559112] mlx5_unregister_device+0x34/0x50 [mlx5_core] [ 745.559686] mlx5_uninit_one+0x46/0xf0 [mlx5_core] [ 745.560203] remove_one+0x4e/0xd0 [mlx5_core] [ 745.560694] pci_device_remove+0x39/0xa0 [ 745.561112] device_release_driver_internal+0x1df/0x240 [ 745.561631] driver_detach+0x47/0x90 [ 745.562022] bus_remove_driver+0x84/0x100 [ 745.562444] pci_unregister_driver+0x3b/0x90 [ 745.562890] mlx5_cleanup+0xc/0x1b [mlx5_core] [ 745.563415] __x64_sys_delete_module+0x14d/0x2f0 [ 745.563886] ? kmem_cache_free+0x1b0/0x460 [ 745.564313] ? lockdep_hardirqs_on_prepare+0xe2/0x190 [ 745.564825] do_syscall_64+0x6d/0x140 [ 745.565223] entry_SYSCALL_64_after_hwframe+0x4b/0x53 [ 745.565725] RIP: 0033:0x7f1579b1288b Fixes: 3ef14e463f6e ("net/mlx5e: Separate between netdev objects and mlx5e profiles initialization") Signed-off-by: Cosmin Ratiu Reviewed-by: Dragos Tatulea Signed-off-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index a5659c0c4236..e601324a690a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -6509,7 +6509,9 @@ static void _mlx5e_remove(struct auxiliary_device *adev) mlx5e_dcbnl_delete_app(priv); unregister_netdev(priv->netdev); _mlx5e_suspend(adev, false); - priv->profile->cleanup(priv); + /* Avoid cleanup if profile rollback failed. */ + if (priv->profile) + priv->profile->cleanup(priv); mlx5e_destroy_netdev(priv); mlx5e_devlink_port_unregister(mlx5e_dev); mlx5e_destroy_devlink(mlx5e_dev);