From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013031.outbound.protection.outlook.com [40.93.196.31])
	(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 38A9D342C98;
	Sun, 26 Apr 2026 08:38:59 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.31
ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1777192741; cv=fail; b=bEPRYSIyiPIg60lCE9MOToENDmlzze+5wDiHKlz+dja2qPRmsXktu1GIH/6PoXNSZiYIFA7dn/Cmt8kE+3SF/SUOo5Sy1CPsgjyy2k4X+n8aMzzI7ZMf0ELBP4634fxsnV2NoKPIzzwmX3pEpCegsYGMIJavkciUzFdbRRBlmR0=
ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1777192741; c=relaxed/simple;
	bh=RLgAWE+OZvKH+iY+OVjxd7PTEIFPGabSTvSkSKdYvA4=;
	h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=bVWqNA60Y3o1Szvxydte6sgQrDfb1U+0dWhUlDRHXTCtneEjTpi82CC8ROqTm3f4udoFdH2GaOJDpDpF3sAKiyiK9nASF698IxBbUz4qmiBj5+URjc7PzdJpcD5HgDRHGe+5CVcxX7RqWz902fHQfUoSfPXtcOU4spmsbB4uQMw=
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=IaugDa5o; arc=fail smtp.client-ip=40.93.196.31
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="IaugDa5o"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=rEoO5TQ1ZbghCv0sXGxp53o5aFKNW6gPJVLeSNJ/y2cPNSCIPr53OyCgGbBiylTYMdnQKSIR8+sH80+bJVnAJTPZdfmIJyshq1SZgNdjGRmt9/GcH+eofIaCU4QoucJQ8rDgO1RPPc8pLGtmiKr05xCrZwwg7tQBizvX+t41fzX/Cos5wzgPM/u8aaVy9mvqfqfwGJ23Yu+KpgcoxF9qqjDOQ0lGjTgcl9uLyRiSOVJDfz7WxLx5tvBxR086EyouJYWI3kr4sbToN8bkK2pWrvXY8/vBYmUjTo7YR2fIF1boTLm7lk1Ha5vpi+jn0JC2hSlZlZvWgfhx+3aZ6VDwOQ==
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=ASD5TSYm9Y9PwjbLUR7uHEmVZZH8chZyiEtv+0ypBfA=;
 b=nrvsxejzfkFJk8VKnPQTqLyX9oQIjTLR/RrzIJcSHRShp1LaFmEmzverd35ckUVFKycGeVX2saXKhfCUDbjO9PfMjGWOAVsLys7YhBLtJvrv3K1YBl9vQe5k3NE3Tkld+ZBpAq4dHJA5a5aOTbl8Z4b7X/Hob7EAoM5mKoS9PhEoehrzRYTPVWKMLrlMc2EjfYmltt2AdrPOkmLNC+kNjSnppaES8VPoEBt5AjH5uy9V5PUYM1qoDd5pRlKM4PYjuDZz9xPmbkrtc8i7Yvi503T0wXbh738dMjd3EhSIAvgk5VVIUcj0rDCar2O9pPiGFkehu7sSo11CEkTDcNkkiA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 216.228.117.161) smtp.rcpttodomain=google.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=ASD5TSYm9Y9PwjbLUR7uHEmVZZH8chZyiEtv+0ypBfA=;
 b=IaugDa5oNg+oWhvEI+BMYzyTooHTfZrJD4GqcEBaLN0aUCNPlR9BfVH9mythtnwJ8Dv4y2ZOnVVmLUcNcUFE7ii9YzKAYaupGAve4b5/be53eYpND3UEQ6W34MaOC01z+RxQ5N9ndGNNCuAxTcv1RKU3L0XrF1d2YsvX1JSCRs8AngftUyltKmHK5U5KLJx0bwnexo3Hj+a709aIgI+pBfAT6vjzMB8+LDgl8R7EUuKDa4JTXwukJzlf3LHEksNAFZLPGJVRJhyH1f29Le0qqR8zu8mY3KT57lw/UihL6+fiD460/gJC2oKO8Ii3aRTzyS7naHB3/JXHlt1C3ycAKA==
Received: from BYAPR04CA0018.namprd04.prod.outlook.com (2603:10b6:a03:40::31)
 by SA0PR12MB4413.namprd12.prod.outlook.com (2603:10b6:806:9e::9) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9870.14; Sun, 26 Apr
 2026 08:38:56 +0000
Received: from MWH0EPF000A6730.namprd04.prod.outlook.com
 (2603:10b6:a03:40:cafe::85) by BYAPR04CA0018.outlook.office365.com
 (2603:10b6:a03:40::31) with Microsoft SMTP Server (version=TLS1_3,
 cipher=TLS_AES_256_GCM_SHA384) id 15.20.9846.25 via Frontend Transport; Sun,
 26 Apr 2026 08:38:56 +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
 MWH0EPF000A6730.mail.protection.outlook.com (10.167.249.22) with Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.9846.18 via Frontend Transport; Sun, 26 Apr 2026 08:38:56 +0000
Received: from rnnvmail203.nvidia.com (10.129.68.9) 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.2562.20; Sun, 26 Apr
 2026 01:38:39 -0700
Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail203.nvidia.com
 (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Sun, 26 Apr
 2026 01:38:39 -0700
Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.8)
 with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sun, 26
 Apr 2026 01:38:34 -0700
From: Tariq Toukan <tariqt@nvidia.com>
To: Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>, Andrew Lunn <andrew+netdev@lunn.ch>, "David
 S. Miller" <davem@davemloft.net>
CC: Boris Pismenny <borisp@nvidia.com>, Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>, Tariq Toukan <tariqt@nvidia.com>, "Mark
 Bloch" <mbloch@nvidia.com>, Daniel Zahka <daniel.zahka@gmail.com>, "Willem de
 Bruijn" <willemdebruijn.kernel@gmail.com>, Cosmin Ratiu <cratiu@nvidia.com>,
	Raed Salem <raeds@nvidia.com>, Rahul Rameshbabu <rrameshbabu@nvidia.com>,
	Dragos Tatulea <dtatulea@nvidia.com>, Kees Cook <kees@kernel.org>,
	<netdev@vger.kernel.org>, <linux-rdma@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, Gal Pressman <gal@nvidia.com>
Subject: [PATCH net V2 0/2] net/mlx5e: PSP fixes
Date: Sun, 26 Apr 2026 11:38:17 +0300
Message-ID: <20260426083819.208937-1-tariqt@nvidia.com>
X-Mailer: git-send-email 2.44.0
Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
List-Id: <netdev.vger.kernel.org>
List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-NV-OnPremToCloud: ExternallySecured
X-EOPAttributedMessage: 0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: MWH0EPF000A6730:EE_|SA0PR12MB4413:EE_
X-MS-Office365-Filtering-Correlation-Id: 52e5d044-4be3-4621-0817-08dea36f410b
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam:
	BCL:0;ARA:13230040|7416014|36860700016|376014|82310400026|1800799024|56012099003|18002099003;
X-Microsoft-Antispam-Message-Info:
	 
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)(7416014)(36860700016)(376014)(82310400026)(1800799024)(56012099003)(18002099003);DIR:OUT;SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0:
	1dknxCvu17rYonwe9iqxJEuqc17pDhg3+RjNFR2P7WyHFv/GVWK+umOmhpJ5/oS8HReKmKqhvj6H3oeWmFe6XzxJ95Egpvcdo6e3rExtLx+l5fR8aSok9/DSUhzE395xIpQgbeQ4bd6i3TSMvvr8qhTpf8hMmvh1+GS1uwYEvqDaG9yp4wmKHFo3gVQxfELNoYNp94r4C4r3or5SwqSvBXJ6IZtZP9VkObrjEimuJWBDvah78ucC5g/CSix1xmU10C1sGS/g3nzIr0uBUZonPmMwIDUzTnH0ly7NwN6VP4pacBKa5E2s6OiXHiAKFiezkkrMynLJcgFTBHSjalT9ruAmHEtwvyPyJQ91KiHjrhoLGNRJhIphkcVyBFtY5NwghLEZ5RzF0MOY1vY1C0TDp7UQx2GJS5nKACacLzNxFVblMbdHtFoI+Ryzwn1p1ZB0
X-OriginatorOrg: Nvidia.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2026 08:38:56.0026
 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 52e5d044-4be3-4621-0817-08dea36f410b
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:
	MWH0EPF000A6730.namprd04.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4413

Hi,

This patchset provides bug fixes from Cosmin to the mlx5e PSP feature.

Thanks,
Tariq.

V2:
- Link to V1:
  https://lore.kernel.org/all/20260417050201.192070-1-tariqt@nvidia.com/
- Expand commit message in patch #1.

Cosmin Ratiu (2):
  net/mlx5e: psp: Fix invalid access on PSP dev registration fail
  net/mlx5e: psp: Hook PSP dev reg/unreg to profile enable/disable

 .../mellanox/mlx5/core/en_accel/psp.c         | 36 ++++++++++---------
 .../net/ethernet/mellanox/mlx5/core/en_main.c |  4 +--
 2 files changed, 22 insertions(+), 18 deletions(-)


base-commit: d40831b016b4986e70d20d0ad14e6a0c62318986
-- 
2.44.0


From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011018.outbound.protection.outlook.com [52.101.52.18])
	(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 14EAB342C98;
	Sun, 26 Apr 2026 08:39:07 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.18
ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1777192749; cv=fail; b=hxjnWOecvCrVB9CpN+dcJPrHF4o4RaGQqQ7Bwe49DY828RHPpWsvy4Uq7bj71da3Wl5sS66VzpMLtKdsuJzC1eXirLRKVU4Q05dkg5ASyAsqeWQBpbJNJD3ZkgNjnwdKrP8QzuOITzXL2I2yjYsu7df10xj5j/rtUUccJEEoT0M=
ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1777192749; c=relaxed/simple;
	bh=+HmZDxRxUqAkRjiEu+A4zMU5EQTuzl8gbitFxFB9/9k=;
	h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version:Content-Type; b=SkGSHDaMGkCfHXGX7Ln1U7yEUpC7ymD5k6R44mH/dRSjpcOi617O6cvtXd2RYPagYD1mQ76fv9XUMh84Q5x7uzeqrYv9IStNwAsR3SVDN+S/4iNLpPicpcT2i+R21lPttQHliOGcFozLoimoNAs58uRMbZ+44J9G7l1bJYtU+Go=
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=WqgNBCyW; arc=fail smtp.client-ip=52.101.52.18
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="WqgNBCyW"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=xMJdNKEgxvepCn/bjLRKgqFnVCEcc76NI92C1e3rtCasIlSGz57lsce4PEr8bqZ49q2xf8DKq+iA1a82TDbwPHVF7iFYzZ2ATEcXg6hGINYi1NIjMDbo685rnGIp8WECWWsqHkxXmnfcmpQbm5BhldGUVq5m2dcoKtp6LM6kCc1tv3f97g+Cte+DV/0m7uCb6MKS3yOcTjWIMzsFfZKU1Asmr1djrlQHBVxfIBiwIz5h7PyfJGrbj1nV1C+q83ZM8QAsm76CAY+d1IA76oFoAXI6q4jMH+y0lE9Hta75edSBK1uQ0EUfF54vwK3QP4Rn2GTus42dBV9if4muZmHMxQ==
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=IOeuLjfxdQCPgscV5obhoO9gJq4GjSycN1HLr3P+/Os=;
 b=a04mGKQzuAIbjZGlDrA5wEdKsUNpP7B+v7YNhuGzaIeqiJwoftJcWggm2kBD8wJfQFhdLbZiSODXt/LtF/op8J5muqFxnYCqXexSgTOl8RcmAXSvSKYkL7hLwzISSikmt++wEPJEE2/hmqZSHo+iHH3NJ8gb4mt9oUV1CrjrWwKuLhiv/pPk0JT57GZt7zCLmv1I7dvV2FGgTqIMxYUAopOsVajLRkKYjBOmY8R5ToT7vt0ts6CJFO8+tlXVNK7NZoVsC1Xym9eH8/Z55s/Fam5WCAUWj4hnBl11op0EyoRl7xGGOlb+V7ZcgeiKtYdrFdq1V0B/ytZmdDble+msZg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 216.228.117.161) smtp.rcpttodomain=google.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=IOeuLjfxdQCPgscV5obhoO9gJq4GjSycN1HLr3P+/Os=;
 b=WqgNBCyWKt71le5eaUg25eBMprL+SADG6rX3+BuMhOg40gv++ID/EiRO79Cv5AZGSErlevTBcrVlgOwvvY0QrWBvyMHoCTuXSfkixXabBg1OWrjzOg2GdRQxsx46zZU3bvXNd4N/TElrNZp+W4+6GPvjTKQ9fUQhNNw75IlQoqnvNopYGDTOOb5RsAL6skQqBuMxgX9yhr8WSPiBxV2PMmN/3lSUeHU4TO7PKn6VQuzV7gvmf/bP0B9VEKL04DPFbE5AvbM+NlgyajLrYKtdkrbctgkhYY7odgeK8ND+nCcF//cDG9Jwll75PLpOmup0Zxia+985A3CxRbsqFcOnBQ==
Received: from BYAPR04CA0036.namprd04.prod.outlook.com (2603:10b6:a03:40::49)
 by SJ0PR12MB7476.namprd12.prod.outlook.com (2603:10b6:a03:48d::19) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9870.12; Sun, 26 Apr
 2026 08:39:02 +0000
Received: from MWH0EPF000A6730.namprd04.prod.outlook.com
 (2603:10b6:a03:40:cafe::50) by BYAPR04CA0036.outlook.office365.com
 (2603:10b6:a03:40::49) with Microsoft SMTP Server (version=TLS1_3,
 cipher=TLS_AES_256_GCM_SHA384) id 15.20.9846.25 via Frontend Transport; Sun,
 26 Apr 2026 08:39:02 +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
 MWH0EPF000A6730.mail.protection.outlook.com (10.167.249.22) with Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.9846.18 via Frontend Transport; Sun, 26 Apr 2026 08:39:02 +0000
Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.2562.20; Sun, 26 Apr
 2026 01:38:45 -0700
Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.2562.20; Sun, 26 Apr
 2026 01:38:45 -0700
Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.8)
 with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sun, 26
 Apr 2026 01:38:39 -0700
From: Tariq Toukan <tariqt@nvidia.com>
To: Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>, Andrew Lunn <andrew+netdev@lunn.ch>, "David
 S. Miller" <davem@davemloft.net>
CC: Boris Pismenny <borisp@nvidia.com>, Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>, Tariq Toukan <tariqt@nvidia.com>, "Mark
 Bloch" <mbloch@nvidia.com>, Daniel Zahka <daniel.zahka@gmail.com>, "Willem de
 Bruijn" <willemdebruijn.kernel@gmail.com>, Cosmin Ratiu <cratiu@nvidia.com>,
	Raed Salem <raeds@nvidia.com>, Rahul Rameshbabu <rrameshbabu@nvidia.com>,
	Dragos Tatulea <dtatulea@nvidia.com>, Kees Cook <kees@kernel.org>,
	<netdev@vger.kernel.org>, <linux-rdma@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, Gal Pressman <gal@nvidia.com>
Subject: [PATCH net V2 1/2] net/mlx5e: psp: Fix invalid access on PSP dev registration fail
Date: Sun, 26 Apr 2026 11:38:18 +0300
Message-ID: <20260426083819.208937-2-tariqt@nvidia.com>
X-Mailer: git-send-email 2.44.0
In-Reply-To: <20260426083819.208937-1-tariqt@nvidia.com>
References: <20260426083819.208937-1-tariqt@nvidia.com>
Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
List-Id: <netdev.vger.kernel.org>
List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-NV-OnPremToCloud: ExternallySecured
X-EOPAttributedMessage: 0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: MWH0EPF000A6730:EE_|SJ0PR12MB7476:EE_
X-MS-Office365-Filtering-Correlation-Id: 8a12c326-e95e-4085-68c5-08dea36f44a4
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam:
	BCL:0;ARA:13230040|376014|7416014|36860700016|82310400026|1800799024|56012099003|22082099003|18002099003;
X-Microsoft-Antispam-Message-Info:
	 
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)(7416014)(36860700016)(82310400026)(1800799024)(56012099003)(22082099003)(18002099003);DIR:OUT;SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0:
	QABciH2+CI9p48FPxrpOBbEQLoQQ8/b1xVipqoTV/LRQrNW4ongd9YAK3poJ3uGfIFXS0PAVA9yNfsw/RigvwctBATc33PbVvN/DXJvMmA30zkiRZ5loxaEXZaEjMh5Olvhm0ew/1qRbR5InOzHLIGkOmDt4vaR+UrhYARbvMV4LpVwxTglotaOxSJRyxrjGOeyqYToppstRkXDXsPk91uES9JJAWdtPBMESnt+SU1dIJ2h6AgVNI4wWPAfCMXegdYprrrJJsiNNgkg5YDY/k5SJvGHhb8y7cecaFZtJjOCvi1/yhz1r0e4go0cd15lqUkzozr06L0+sdIzZshRZanzIcras2vaYcRnxNDtJCT4dpM4zU831qAxENwcHfLWTlPrRRDOnj1C0IrBKf+U+aJsVINmbsKufKjOto3JJG2LRDPBXRypGGsyQu1987lOd
X-OriginatorOrg: Nvidia.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2026 08:39:02.0577
 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 8a12c326-e95e-4085-68c5-08dea36f44a4
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:
	MWH0EPF000A6730.namprd04.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7476

From: Cosmin Ratiu <cratiu@nvidia.com>

priv->psp->psp is initialized with the PSP device as returned by
psp_dev_create(). This could also return an error, in which case a
future psp_dev_unregister() will result in unpleasantness.

Avoid that by using a local variable and only saving the PSP device when
registration succeeds.
Also apply some light refactoring of the functions managing the PSP
device in order to make them more readable/safe.

In case psp_dev_create() fails, priv->psp and steering structs are left
in place, but they will be inert. The unchecked access of priv->psp in
mlx5e_psp_offload_handle_rx_skb() won't happen because without a PSP
device, there can be no SAs added and therefore no packets will be
successfully decrypted and be handed off to the SW handler.

Fixes: 89ee2d92f66c ("net/mlx5e: Support PSP offload functionality")
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 .../mellanox/mlx5/core/en_accel/psp.c         | 36 ++++++++++---------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c
index 6a50b6dec0fa..d9adb993e64d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c
@@ -1070,29 +1070,37 @@ static struct psp_dev_ops mlx5_psp_ops = {
 
 void mlx5e_psp_unregister(struct mlx5e_priv *priv)
 {
-	if (!priv->psp || !priv->psp->psp)
+	struct mlx5e_psp *psp = priv->psp;
+
+	if (!psp || !psp->psp)
 		return;
 
-	psp_dev_unregister(priv->psp->psp);
+	psp_dev_unregister(psp->psp);
+	psp->psp = NULL;
 }
 
 void mlx5e_psp_register(struct mlx5e_priv *priv)
 {
+	struct mlx5e_psp *psp = priv->psp;
+	struct psp_dev *psd;
+
 	/* FW Caps missing */
 	if (!priv->psp)
 		return;
 
-	priv->psp->caps.assoc_drv_spc = sizeof(u32);
-	priv->psp->caps.versions = 1 << PSP_VERSION_HDR0_AES_GCM_128;
+	psp->caps.assoc_drv_spc = sizeof(u32);
+	psp->caps.versions = 1 << PSP_VERSION_HDR0_AES_GCM_128;
 	if (MLX5_CAP_PSP(priv->mdev, psp_crypto_esp_aes_gcm_256_encrypt) &&
 	    MLX5_CAP_PSP(priv->mdev, psp_crypto_esp_aes_gcm_256_decrypt))
-		priv->psp->caps.versions |= 1 << PSP_VERSION_HDR0_AES_GCM_256;
+		psp->caps.versions |= 1 << PSP_VERSION_HDR0_AES_GCM_256;
 
-	priv->psp->psp = psp_dev_create(priv->netdev, &mlx5_psp_ops,
-					&priv->psp->caps, NULL);
-	if (IS_ERR(priv->psp->psp))
+	psd = psp_dev_create(priv->netdev, &mlx5_psp_ops, &psp->caps, NULL);
+	if (IS_ERR(psd)) {
 		mlx5_core_err(priv->mdev, "PSP failed to register due to %pe\n",
-			      priv->psp->psp);
+			      psd);
+		return;
+	}
+	psp->psp = psd;
 }
 
 int mlx5e_psp_init(struct mlx5e_priv *priv)
@@ -1131,22 +1139,18 @@ int mlx5e_psp_init(struct mlx5e_priv *priv)
 	if (!psp)
 		return -ENOMEM;
 
-	priv->psp = psp;
 	fs = mlx5e_accel_psp_fs_init(priv);
 	if (IS_ERR(fs)) {
 		err = PTR_ERR(fs);
-		goto out_err;
+		kfree(psp);
+		return err;
 	}
 
 	psp->fs = fs;
+	priv->psp = psp;
 
 	mlx5_core_dbg(priv->mdev, "PSP attached to netdevice\n");
 	return 0;
-
-out_err:
-	priv->psp = NULL;
-	kfree(psp);
-	return err;
 }
 
 void mlx5e_psp_cleanup(struct mlx5e_priv *priv)
-- 
2.44.0


From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012039.outbound.protection.outlook.com [52.101.48.39])
	(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 98CC8348477;
	Sun, 26 Apr 2026 08:39:12 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.48.39
ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1777192753; cv=fail; b=hnTONef2s/r3zqw9gpNeLiConZt/iNI+Hhr/4KAkFKEB869UHEJVjNly7MAXI/2PMxgfqC2Y5HpDGD8Q7HghmARgmobMkpj6L6lU0quEhKyyTghvoCFTcGajHoLZBJl8mj0EnUpTYdehpcXw5yoRPC5sFPsHFh4bXNY47VLkTaM=
ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1777192753; c=relaxed/simple;
	bh=3byHFNC93gAfJOtDdU71buXfOsl1qA18d9jbQWI1Nr8=;
	h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version:Content-Type; b=oyuJBbrNuDpWmsntPtf9dH4uMk0vuQxJjnJ2sByk2ZiTGNSGSRbMgyzZNa4EetS5ozcZC+AUJZPhfyA323PVCnBGA27ryFHFz8GqlG6rprwApB2T6Nidp0X5kjRbRFZnTNdHzpRTQ3adfVNEk6XrOoX/y7UAmUR4aHmuqoy3DUo=
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=J0qC2Jzt; arc=fail smtp.client-ip=52.101.48.39
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="J0qC2Jzt"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=HXOGc5TASoj2Ktv6tctosaxJDPC6Vsv/EJKwDMMfklWOUQVZB/JZZ58NMWeVvrTkf6dszTZbn6Dd88Y7TNW3OOgsPZrn181+CQZ9+RBizFEu7+0Kz+loDABzWX2LsTfKzhIxSOqr42lhFfw55unjaebTRT59NjKkbfiFEBROemcM6/9btyDIOm2O5lX+ZLzt4ALsMLNdR0/0m2qUiIOZrbs9ZGCwyzmrQp2DZri8Hn7U71KyL904rE7Pjmf8GWzWmGlh1iMFuMq2YVMR+pzMza5L0iJBX1GZ9pNidv1c8HDT5heyQBfqoFSOYUfGaFJNyY+ZJWK3TC28UnSuSEcMqQ==
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=0Q/GigAVK00gM2QCf1u2hzP1KeoY3ZFSBiy+dTlMHXM=;
 b=ARenSlYkbeUUjIveuc5MaUCKXduf9wZBDfoIqmDhm0ADD/4X63RNixP16n4BxZixjY1nN5F5mjDXTN0TmfufVuobCaPwwnWUmr8InXPaCGgwSQ+a4jtlQSadYyjnHTcqw1YYrM2X0DW6tMEkVnBgwfgWn46pFqnDa6Y+wS5qeIzQ1ibZftR8Y372/R7As5rF5SFV9ALbihQB5co6oQDk5GNq1ourzGUwGPyIz10hqH186dVk5OHIxMZ5JGKEWxUgmr0gojm58QenoceJ+v0EX6yFGyq6MuP+ljCieThxfUap0uALTKIiwafzToA6gniPrLS903/WRL5vYYFuJcpcRA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 216.228.117.160) smtp.rcpttodomain=google.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=0Q/GigAVK00gM2QCf1u2hzP1KeoY3ZFSBiy+dTlMHXM=;
 b=J0qC2Jzt/9r6/dcccOBaLXoNNO88hZ/ct1AYu/dzWp5aJxpBAavCk8Tw7DsGiShEwIqw9RL+uLaZbBZ8kADWbzt5yZ7Y/3GGQR1RW4NyBVD2LiMxnj/TNDaL/SW1ljv/WLYE0XjXWH8Rd7WlOLqGSAqMHI8tYB01nlrK/PzUfDgUyVj8bYoDlt+CVkpZ0eh+WetvhksnLxTrM3/Mw7MLhWnjuocvsYDlHz9fA6IRxEXzhNGj5T6gSmsaVxUEP7kA6+hZ4vnU6fwGIuVvHncYNAXT1NrN8V+25j18zAjTsdBL3ULXH24qjZQ1/fTvqaEJFjkndY4Y1LBWF/ZH95qMWg==
Received: from SJ0PR13CA0065.namprd13.prod.outlook.com (2603:10b6:a03:2c4::10)
 by DS7PR12MB6021.namprd12.prod.outlook.com (2603:10b6:8:87::5) with Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.9870.12; Sun, 26 Apr 2026 08:39:06 +0000
Received: from MW1PEPF0001615E.namprd21.prod.outlook.com
 (2603:10b6:a03:2c4:cafe::26) by SJ0PR13CA0065.outlook.office365.com
 (2603:10b6:a03:2c4::10) with Microsoft SMTP Server (version=TLS1_3,
 cipher=TLS_AES_256_GCM_SHA384) id 15.20.9846.25 via Frontend Transport; Sun,
 26 Apr 2026 08:39:06 +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
 MW1PEPF0001615E.mail.protection.outlook.com (10.167.249.89) with Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.9891.0 via Frontend Transport; Sun, 26 Apr 2026 08:39:06 +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.2562.20; Sun, 26 Apr
 2026 01:38:51 -0700
Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.2562.20; Sun, 26 Apr
 2026 01:38:50 -0700
Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.8)
 with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Sun, 26
 Apr 2026 01:38:45 -0700
From: Tariq Toukan <tariqt@nvidia.com>
To: Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>, Andrew Lunn <andrew+netdev@lunn.ch>, "David
 S. Miller" <davem@davemloft.net>
CC: Boris Pismenny <borisp@nvidia.com>, Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>, Tariq Toukan <tariqt@nvidia.com>, "Mark
 Bloch" <mbloch@nvidia.com>, Daniel Zahka <daniel.zahka@gmail.com>, "Willem de
 Bruijn" <willemdebruijn.kernel@gmail.com>, Cosmin Ratiu <cratiu@nvidia.com>,
	Raed Salem <raeds@nvidia.com>, Rahul Rameshbabu <rrameshbabu@nvidia.com>,
	Dragos Tatulea <dtatulea@nvidia.com>, Kees Cook <kees@kernel.org>,
	<netdev@vger.kernel.org>, <linux-rdma@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, Gal Pressman <gal@nvidia.com>
Subject: [PATCH net V2 2/2] net/mlx5e: psp: Hook PSP dev reg/unreg to profile enable/disable
Date: Sun, 26 Apr 2026 11:38:19 +0300
Message-ID: <20260426083819.208937-3-tariqt@nvidia.com>
X-Mailer: git-send-email 2.44.0
In-Reply-To: <20260426083819.208937-1-tariqt@nvidia.com>
References: <20260426083819.208937-1-tariqt@nvidia.com>
Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
List-Id: <netdev.vger.kernel.org>
List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-NV-OnPremToCloud: ExternallySecured
X-EOPAttributedMessage: 0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: MW1PEPF0001615E:EE_|DS7PR12MB6021:EE_
X-MS-Office365-Filtering-Correlation-Id: bfbb4eee-603b-423a-4c1c-08dea36f4712
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam:
	BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|36860700016|18002099003|56012099003|22082099003;
X-Microsoft-Antispam-Message-Info:
	 
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)(82310400026)(376014)(7416014)(36860700016)(18002099003)(56012099003)(22082099003);DIR:OUT;SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0:
	DkD4ha2FkqEXtaCVU5u2NgPmv183bseJzy71cwhHldC103OiKPJ4wZLdDFM/LnV/JxtUlQXqQMni1m24Y6G8Mtf0ZI4stgzc7hWEEIzzyec/x+ZS1OPc5oKTgVT1YQ11wduuIFIDyOvO3tyK9jeM+hS09nIcqaopA9/Y92vE7N2/9ywvbqVgsR//YhxSWz1PqqMM9Bc5viQnABfQPF4Uzwi0PAckdRhYhz6PP6DA0wNub6/uaILi9Qp0WNG4YK0sl9VF4L/n4/aXWs9zTOhZncrIqNLZPnCkBgNztinhGyWWAgbYg7AsKvaOjL3fwqRjKpka1Ppzabq2KiuR7cwlpYcQVh/WF8WgNb62qyIjaPLkbV985xCizdbVH9iNoJ2JQxpUGbEKURE92x2RQHiKeRiyUSxGRJ4Ri/Xnao/4aMhN5pnIiE0AehIeq/uHcMBX
X-OriginatorOrg: Nvidia.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2026 08:39:06.1300
 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: bfbb4eee-603b-423a-4c1c-08dea36f4712
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:
	MW1PEPF0001615E.namprd21.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6021

From: Cosmin Ratiu <cratiu@nvidia.com>

devlink reload while PSP connections are active does:

mlx5_unload_one_devl_locked() -> mlx5_detach_device()
-> _mlx5e_suspend()
  -> mlx5e_detach_netdev()
    -> profile->cleanup_rx
    -> profile->cleanup_tx
  -> mlx5e_destroy_mdev_resources() -> mlx5_core_dealloc_pd() fails:
...
mlx5_core 0000:08:00.0: mlx5_cmd_out_err:821:(pid 19722):
DEALLOC_PD(0x801) op_mod(0x0) failed, status bad resource state(0x9),
syndrome (0xef0c8a), err(-22)
...

The reason for failure is the existence of TX keys, which are removed by
the PSP dev unregistration happening in:
profile->cleanup() -> mlx5e_psp_unregister() -> mlx5e_psp_cleanup()
  -> psp_dev_unregister()
...but this isn't invoked in the devlink reload flow, only when changing
the NIC profile (e.g. when transitioning to switchdev mode) or on dev
teardown.

Move PSP device registration into mlx5e_nic_enable(), and unregistration
into the corresponding mlx5e_nic_disable(). These functions are called
during netdev attach/detach after RX & TX are set up.
This ensures that the keys will be gone by the time the PD is destroyed.

Fixes: 89ee2d92f66c ("net/mlx5e: Support PSP offload functionality")
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 5a46870c4b74..8e9443caa933 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -6023,7 +6023,6 @@ static int mlx5e_nic_init(struct mlx5_core_dev *mdev,
 	if (take_rtnl)
 		rtnl_lock();
 
-	mlx5e_psp_register(priv);
 	/* update XDP supported features */
 	mlx5e_set_xdp_feature(priv);
 
@@ -6036,7 +6035,6 @@ static int mlx5e_nic_init(struct mlx5_core_dev *mdev,
 static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
 {
 	mlx5e_health_destroy_reporters(priv);
-	mlx5e_psp_unregister(priv);
 	mlx5e_ktls_cleanup(priv);
 	mlx5e_psp_cleanup(priv);
 	mlx5e_fs_cleanup(priv->fs);
@@ -6160,6 +6158,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
 
 	mlx5e_fs_init_l2_addr(priv->fs, netdev);
 	mlx5e_ipsec_init(priv);
+	mlx5e_psp_register(priv);
 
 	err = mlx5e_macsec_init(priv);
 	if (err)
@@ -6230,6 +6229,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
 	mlx5_lag_remove_netdev(mdev, priv->netdev);
 	mlx5_vxlan_reset_to_default(mdev->vxlan);
 	mlx5e_macsec_cleanup(priv);
+	mlx5e_psp_unregister(priv);
 	mlx5e_ipsec_cleanup(priv);
 }
 
-- 
2.44.0


From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AE4D36164D
	for <netdev@vger.kernel.org>; Sun, 26 Apr 2026 13:17:11 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173
ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1777209432; cv=none; b=Ovro4JIE2C+TlokAsQZ8vtcPbCyuLxVGtvJZaatjin4FpchnTocspVD+NhgJTOxZY/d/WLtypOMiAEqbksDjIZeic8g6cCq7W0RZ9H3e7ZQGJtsm3w1j0qoPPmByGPCOdfYmcTVhOazyu+0M1sUcN+T55rPZTw7kOb3Qbq4Y8cI=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1777209432; c=relaxed/simple;
	bh=x+YYTxWMWBTUs8+xGvsnwglC/8O2WZrLZrMExkdN7Ys=;
	h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject:
	 Mime-Version:Content-Type; b=rgwljfTYdRNaHUAJokQKs5vv+mgRBVh8bbKlsaW4tRTzdx53gO67Qcl131334gMzUp0WFViOMyX59z2pvkZQ+kEKrnOrzWgR074O6ocmKeDgnvUc8qPXkFIeBZL8EQJ6gfrC9hHXXmSs3n08yvETvZV2PszQjkA3JSjODFqt3Og=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gWXx/g9Y; arc=none smtp.client-ip=209.85.128.173
Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gWXx/g9Y"
Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-79ab3e26cceso84067067b3.3
        for <netdev@vger.kernel.org>; Sun, 26 Apr 2026 06:17:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1777209430; x=1777814230; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:subject:references
         :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date
         :message-id:reply-to;
        bh=dHs0YRZHBGD67vbxwSlbpv9/TtMO58IvmgOpPAVdTog=;
        b=gWXx/g9YJWzTr9dU5q1MVxVahov59zr2J5YpwlKpDyxmtfwWrv33G3VM0f6Sn1dtJi
         W+PTzQhqR8w0/8cDSPArNGCYtLWJNSX9h6tjmHOhRcjnI4Gka4Qt+42zMmb16/7L8OYJ
         DiDllHeFE12Xp7+nFJujHP/kuihUI0yRcI2uPC6wCagdlODdwwOKwzYng8d6e6NRS68D
         CXLp5pFi6QY3qqE9JN5ga8OFztLFg6OrXLrPZyiDQY23+l2SGZUsbFTd/ngy0TJBrYzk
         lKvwBKAzteKYaXFN6K2OqmQolI1AR07+0FBzXVXIs3fi92oqM3LIl7LN20MAMYFnIhxo
         FxJg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20251104; t=1777209430; x=1777814230;
        h=content-transfer-encoding:mime-version:subject:references
         :in-reply-to:message-id:cc:to:from:date:x-gm-gg:x-gm-message-state
         :from:to:cc:subject:date:message-id:reply-to;
        bh=dHs0YRZHBGD67vbxwSlbpv9/TtMO58IvmgOpPAVdTog=;
        b=Ylltqf8h01PajOKfcXs1qOqfZjTotAjjC5p+vjQjBRqlJKkcpPyZJYHCLq8mIDP0Ge
         3Ql0iA7JYL2YPVBbtVo0k+5JDEf9ZyFKLqUcV4aXgOzAQfcMJYAFhMkSrtYDgcQzS1LI
         jFvCp4I7mZ8dAakAcNTFAB0QICgN2/1cFpA594v/ttn20ClFJt6PE3FIVGyrs92o7zIb
         E37Q4+jWVJnHAt13JuZtIbM60AE7pwuxu3rKWheQGTE6Y5CHIO82LCQjb650dQAys1vh
         o9n320Ywd9LJtWuW3s8Ef64EUcFMXS1/k+uWRVPJPljyStmgga5Svi+xnUTG4WcGBFVl
         0AJA==
X-Forwarded-Encrypted: i=1; AFNElJ8WthM8/Gs9g0l8kJ/fav+6vvr+IImkGol7X6oZnzbAWW5vP2wQTDStiTxVrSI6U33RMOjNHF0=@vger.kernel.org
X-Gm-Message-State: AOJu0YzjnhT4GQKOflabl+F6Wc05k/xodCu/414gRFdUMKuwyXW+Dh0C
	Yq29kxQOrI7Kqu7RtcPnTQ+kQulQT9LPoOZnGScsV/roAkeMeR8DOdzC
X-Gm-Gg: AeBDietVbWIR6ypw92+tgW+83WAa+7bHH1KQSge0FhmY/2KUY80vmYwXgUU1Z43LQq6
	LpTmC8xcLg4NUbmij2dz+TUJsJttQzuL14dSqEslRD4BOvTFg3g3kuPwC3KiinX5JGr3brVnNYW
	uhGn1S2Xr86JA+p7AJOXbuKxTbcYU3+rWZZbkFj+v2xya09xo1XJqq3zhP8iP9hssdKyxjb0E3F
	/h/hb8lZKRgMKvMAaxuFdeZCa+AhO28GwVdt1n1yg5G6rv5ZdOaXOBIdFnUXVUQ9PQzpxYx9rzr
	FeE9WYOODNCcRQWVLl6vUmeUaxnAc22HBjZoeCJao1rYiqppIk8k5aw7KtzMyDVKz7nL45AreaW
	QKzZcaqGj+dMzW7VOxgL+cSPaUJ5/wcTl9zNgoVUkkF/2OmI3dPVc43oaQFUrN0Gi0PtxwuN+VK
	cKl2Gqcn0pFQlrxRHK59Warj3qZwKFU3TggmNKTkk02ph4JXlECGUzlwtyf1s26JpBDpYtZSG0m
	UIHn9AoveARjZc=
X-Received: by 2002:a05:690c:e3e9:b0:7b3:9175:30c5 with SMTP id 00721157ae682-7b9ecfdaf23mr390919617b3.35.1777209430402;
        Sun, 26 Apr 2026 06:17:10 -0700 (PDT)
Received: from gmail.com (172.165.85.34.bc.googleusercontent.com. [34.85.165.172])
        by smtp.gmail.com with ESMTPSA id 00721157ae682-7b9ee9b22e2sm113515307b3.34.2026.04.26.06.17.09
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sun, 26 Apr 2026 06:17:09 -0700 (PDT)
Date: Sun, 26 Apr 2026 09:17:08 -0400
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Tariq Toukan <tariqt@nvidia.com>, 
 Eric Dumazet <edumazet@google.com>, 
 Jakub Kicinski <kuba@kernel.org>, 
 Paolo Abeni <pabeni@redhat.com>, 
 Andrew Lunn <andrew+netdev@lunn.ch>, 
 "David S. Miller" <davem@davemloft.net>
Cc: Boris Pismenny <borisp@nvidia.com>, 
 Saeed Mahameed <saeedm@nvidia.com>, 
 Leon Romanovsky <leon@kernel.org>, 
 Tariq Toukan <tariqt@nvidia.com>, 
 Mark Bloch <mbloch@nvidia.com>, 
 Daniel Zahka <daniel.zahka@gmail.com>, 
 Willem de Bruijn <willemdebruijn.kernel@gmail.com>, 
 Cosmin Ratiu <cratiu@nvidia.com>, 
 Raed Salem <raeds@nvidia.com>, 
 Rahul Rameshbabu <rrameshbabu@nvidia.com>, 
 Dragos Tatulea <dtatulea@nvidia.com>, 
 Kees Cook <kees@kernel.org>, 
 netdev@vger.kernel.org, 
 linux-rdma@vger.kernel.org, 
 linux-kernel@vger.kernel.org, 
 Gal Pressman <gal@nvidia.com>
Message-ID: <willemdebruijn.kernel.2f90e0de4485b@gmail.com>
In-Reply-To: <20260426083819.208937-2-tariqt@nvidia.com>
References: <20260426083819.208937-1-tariqt@nvidia.com>
 <20260426083819.208937-2-tariqt@nvidia.com>
Subject: Re: [PATCH net V2 1/2] net/mlx5e: psp: Fix invalid access on PSP dev
 registration fail
Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
List-Id: <netdev.vger.kernel.org>
List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
Mime-Version: 1.0
Content-Type: text/plain;
 charset=utf-8
Content-Transfer-Encoding: 7bit

Tariq Toukan wrote:
> From: Cosmin Ratiu <cratiu@nvidia.com>
> 
> priv->psp->psp is initialized with the PSP device as returned by
> psp_dev_create(). This could also return an error, in which case a
> future psp_dev_unregister() will result in unpleasantness.
> 
> Avoid that by using a local variable and only saving the PSP device when
> registration succeeds.
> Also apply some light refactoring of the functions managing the PSP
> device in order to make them more readable/safe.

This is generally discouraged as it obfuscates the fix.

That said, the fix on its own makes sense.

> In case psp_dev_create() fails, priv->psp and steering structs are left
> in place, but they will be inert. The unchecked access of priv->psp in
> mlx5e_psp_offload_handle_rx_skb() won't happen because without a PSP
> device, there can be no SAs added and therefore no packets will be
> successfully decrypted and be handed off to the SW handler.
> 
> Fixes: 89ee2d92f66c ("net/mlx5e: Support PSP offload functionality")
> Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>

From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201])
	(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 5F8FC1DA23;
	Tue, 28 Apr 2026 00:05:15 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201
ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1777334715; cv=none; b=Cb/u2TnRPvA//2bTVPFjc8fh9Cmm7PiRUgDWSs9la3VOKWXkm28LTvCUjNce56luUrKVSQXoNxo+LfK6i9Z/e+Hr7cfcTOC4rtMtUiglECijj4b6GVMDNmVlgMaJIDFtaSeMEyYwwCO+udkyvEP7yFLoiJ9fF7TJzwuLuNZkTuQ=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1777334715; c=relaxed/simple;
	bh=+VPANvDgMOiP/9CCoh3IqXDmdQ2vvDPBVm15uDgS4u4=;
	h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:
	 MIME-Version:Content-Type; b=DoZHBlWIJnceoSoiTlHb4sS+69RrlX01/DUlXc45B3SzvP28dTSuipOOkaYKgUn4GqQi6iL92Re0aWmjnh0DZ0U34z4DoOXyeVSHC25weaZpf3IcaISMYlL9jfkNH0mRhpGbjBq/wtUBWLwfVhEmyFPkGUHI0XdTKpSp+vkGhqc=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bzQdbLBh; arc=none smtp.client-ip=10.30.226.201
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bzQdbLBh"
Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49FB5C2BCB6;
	Tue, 28 Apr 2026 00:05:14 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;
	s=k20201202; t=1777334715;
	bh=+VPANvDgMOiP/9CCoh3IqXDmdQ2vvDPBVm15uDgS4u4=;
	h=Date:From:To:Cc:Subject:In-Reply-To:References:From;
	b=bzQdbLBhZugdQU0bBWDb/Ztbb1C9bvWDPS7DD8xo99p4y9aUSEtlMUGxf6EVVFEDw
	 9EWxyepAzAbXqFXhPXFlPHr0zCjnj2i5QYttWpIWTLQqr5TpoU7p2uwsHxd7eB/qif
	 eIIbGMZDleADQbbCh0z15qaKj7HCvLgi5WXpn+vajEADXZiAMhKQ39tmQaFuGTCGi2
	 7AJ3uyubquEerYSwDa9QyDmCMPiFc41F+7gvAQBr+jmiu9JxIYC6IKeW9qNUmGAZ1d
	 xjUrDsnXcA7Xibl4hlDambhnAlJrCnxvQdf3VyfGoM15tIyNwdgvpD4hXljxwKfvH4
	 dY85Kx1xYgecQ==
Date: Mon, 27 Apr 2026 17:05:13 -0700
From: Jakub Kicinski <kuba@kernel.org>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Tariq Toukan <tariqt@nvidia.com>, Eric Dumazet <edumazet@google.com>,
 Paolo Abeni <pabeni@redhat.com>, Andrew Lunn <andrew+netdev@lunn.ch>,
 "David S. Miller" <davem@davemloft.net>, Boris Pismenny
 <borisp@nvidia.com>, Saeed Mahameed <saeedm@nvidia.com>, Leon Romanovsky
 <leon@kernel.org>, Mark Bloch <mbloch@nvidia.com>, Daniel Zahka
 <daniel.zahka@gmail.com>, Cosmin Ratiu <cratiu@nvidia.com>, Raed Salem
 <raeds@nvidia.com>, Rahul Rameshbabu <rrameshbabu@nvidia.com>, Dragos
 Tatulea <dtatulea@nvidia.com>, Kees Cook <kees@kernel.org>,
 netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
 linux-kernel@vger.kernel.org, Gal Pressman <gal@nvidia.com>
Subject: Re: [PATCH net V2 1/2] net/mlx5e: psp: Fix invalid access on PSP
 dev registration fail
Message-ID: <20260427170513.05bb02b7@kernel.org>
In-Reply-To: <willemdebruijn.kernel.2f90e0de4485b@gmail.com>
References: <20260426083819.208937-1-tariqt@nvidia.com>
	<20260426083819.208937-2-tariqt@nvidia.com>
	<willemdebruijn.kernel.2f90e0de4485b@gmail.com>
Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
List-Id: <netdev.vger.kernel.org>
List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

On Sun, 26 Apr 2026 09:17:08 -0400 Willem de Bruijn wrote:
> > priv->psp->psp is initialized with the PSP device as returned by
> > psp_dev_create(). This could also return an error, in which case a
> > future psp_dev_unregister() will result in unpleasantness.
> > 
> > Avoid that by using a local variable and only saving the PSP device when
> > registration succeeds.
> > Also apply some light refactoring of the functions managing the PSP
> > device in order to make them more readable/safe.  
> 
> This is generally discouraged as it obfuscates the fix.

+1, I should have said this during the v1 convo, I thought it's obvious
:\

