From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384274; b=VNlmwMr0sjQbgnw7M33cKNW8e0+SN6jqEergg0lgSujjMseDGo39sfARhg/XlaQPshlt AvsaJ5UGj9bbhNWLILfCIi4Iq3+nZ0UsERZJlc5bGc+mkZkOqAGwArQYc1MdqJIWkw8c0 6q+Qq1FMwvPsmAStZQTUsn6+jloDsaeX0p+l7kGAtMto5ozTS2o1/qOs2DDRI/MPS6XcC fAoVX9BgLlnoJ419hVnS1z7/TLnQO8HgjCoSdDCS7HT3KWA1ENXEmyc4Kned/G7jJURkI SqqpsJpWTRBjaLEM6t35knYoMwfhEI4kKprtcMygbpFvKewRswhjbLnZspQj/XjebhQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384274; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=pnqqMJECaPmVk1j1H+uXqK2SbQz3utsGu2uG/39pnVk=; b=a6zXvrz9Pj+zB0xKHbfC9oSg6vGhpL/WUFRNx876jw7h/cbbXiqrOxXex9eKjiuUPf3q MzkOh0RKxN03HpQpVMZHNgBgiS+LcGoXx6BEYdT43NHy0pAkJ/lvb83CuH4npYybhRtib 8MxLwaKDdFZEUFuFHt+/eOoaCbyoZI/Wm+hKlMuT5jXxDuq2gQ8D4B7vMxbSjByWTio5x GaS0Xpg0204uGIlAbVXUAAVze3PfzVZtOVAF7upkfYonYS5M2OS/eCO9X+Etmh/PsEImJ E/gxYzEcQXUaqzwLusOTgDkvFmsGYePIAUwApAjdQB6JTbIjr2onCqQwjUEDJRXFcKw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=MmdhSjwe; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83DA0606A322; Fri, 4 Dec 2026 11:37:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=MmdhSjwe Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA32F1F000C2; Fri, 4 Dec 2026 11:37:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384274; bh=pnqqMJECaPmVk1j1H+uXqK2SbQz3utsGu2uG/39pnVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MmdhSjweJni+5r43PKx61hyTo89V7c8/577JLg0nCnUUuTTkc5Y8w8bFUYo5a4Ln/ hcPbrjCPJHaR6RM92RRP3pYVE7xsGv5FUf5lzbMK65VqGmu5qpvmyMsQkiCWtX2Eal FycLfRK4qszWXvlKvxP8/fMDMc4ZS8NeFtpIhORE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joas Antonio dos Santos , Simon Horman , Dave Miller , Sasha Levin Subject: [PATCH 6.6 0082/1167] net/mlx5: macsec: free struct mlx5_fs_id after an RCU grace period Date: Fri, 4 Dec 2026 18:51:49 +0900 Message-ID: <20261204100704.224242669@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joas Antonio dos Santos [ Upstream commit 902407bc588575af0ceae5de4f635fe1e024f258 ] macsec_fs_id_del() removes a struct mlx5_fs_id from its rhashtable with rhashtable_remove_fast() and then frees it with kfree() right away. The TX (SCI) table is read locklessly from the transmit path: mlx5e_macsec_handle_tx_skb() and mlx5e_macsec_tx_build_eseg() call mlx5_macsec_fs_get_fs_id_from_hashtable(), which does rhashtable_lookup() under rcu_read_lock() and then reads mlx5_fs_id->id. A transmit that looked the entry up just before it was removed reads freed memory. Before commit d4ece08f4b1d ("net/mlx5: Maintain fs_id xarray per MACsec device inside macsec steering") the SCI table held struct mlx5e_macsec_sa directly, and mlx5e_macsec_del_txsa() freed it with kfree_rcu_mightsleep(). That commit moved the table into macsec_fs.c with the new struct mlx5_fs_id, but frees it with a plain kfree(). Add an rcu_head to struct mlx5_fs_id and free it with kfree_rcu(). The same issue was flagged by the Sashiko AI review as a pre-existing problem while reviewing the HW-GRO for PSP series. Fixes: d4ece08f4b1d ("net/mlx5: Maintain fs_id xarray per MACsec device inside macsec steering") Link: https://lore.kernel.org/all/20260909065542.4B80D1F00ACA@smtp.kernel.org/ Signed-off-by: Joas Antonio dos Santos Assisted-by: Yaga Agent HackerSec Claude:claude-opus-5-5 Reviewed-by: Simon Horman Signed-off-by: Dave Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c index 4a078113e292d..3d2473d9f3eac 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/macsec_fs.c @@ -98,6 +98,7 @@ struct mlx5_fs_id { refcount_t refcnt; sci_t sci; struct rhash_head hash; + struct rcu_head rcu; }; struct mlx5_macsec_device { @@ -688,7 +689,7 @@ static void macsec_fs_id_del(struct list_head *macsec_devices_list, u32 fs_id, xa_erase(fs_id_xa, fs_id); - kfree(fs_id_found); + kfree_rcu(fs_id_found, rcu); if (macsec_fs_is_macsec_device_empty(macsec_device)) { list_del(&macsec_device->macsec_devices_list_entry); -- 2.53.0