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=1796385266; b=PjC1fwqUWxnjoG3ElrbUlcw05xLXwR3MqvwbPXpIyzpcZaekFFpUs9MnNmgZvAwRgYb/ IQYlI/k14Nv5ygRwluNkXwlBZs3ci1FWNzYeIz8Adky8fNts9l8FsPZbrmWu17HbC7fCK s2knfWcmOgXy8BSaiViUb/3D7O511OVldIvKKN+qFKZVXGl4XhxCT9VPGYV5Ggp0+CtkK 01pdfElxtgfslAXWVzvRbFOpGknD9rFHDO9DQo++UJzMV+cR05CO3fvYv2fi+Q9CaVrGq N7etn5jj0n3fpJrCzHxT27ox6kNd9bVqu9KYdhXA1Fhc0HI1K7VzfPvkuHZ6CLsPfRQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385266; 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=zZai9isqajSG8OCKbHunH54wqRVjqxSPgyk/r64Epew=; b=gzNeVi6xlN+ccVekwP3G86Y5mSyloTqJlGVf08B1uT4RDyD+3RBBHcCG8kvmGgbKlI+9 /7h9WWvJWzWKHOUvz+zqBYzp6ipDtnsgOLJotl04gQ5u1XPlQI+a3jYewiBf6ZH73dXmT SVDrsPSAco9pHxQuGFwLpzJKdZcpeO8gFElOw5MLxMdf5CA4wUkUz4fQEM+8xSyfPR2bo vejCU1JC61woQFu32l2WaRcHDW7EY2et+pty5j0TRdCLsgXvX5n/cy6dU5Ob2CnmdNE2f jgPB0KpWhqJRmEJf+/7mv/DJlQz0bP/iZYDTQxS/IrEhJxiT2q2isR7RhLJFTldEPmQ== 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="g/7TDlhU"; 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 33E3B606A32C; Fri, 4 Dec 2026 11:54:26 +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=g/7TDlhU Received: by smtp.kernel.org (Postfix) with ESMTPSA id A07B01F000C2; Fri, 4 Dec 2026 11:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385266; bh=zZai9isqajSG8OCKbHunH54wqRVjqxSPgyk/r64Epew=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=g/7TDlhUnKKDGaE2pcqwenMQfCu05aQWaYirsN6AFqOBL/M6K/AaFfgvpGVSLJArp BHQRQaaEfX67+OFz2kJFpf/RYaXAVeUWq9DEnZ84CPLXW8l1Rwps7EniocszvqKteq CwPPbmCz540X3dMi9rmepRp/rc3Ww66xiQs3rHZk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gal Pressman , Leon Romanovsky , Yael Chemla , Tariq Toukan , Fernando Fernandez Mancera , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0458/1167] net/mlx5e: IPsec, Fix out-of-bounds comparison of neighbour keys Date: Fri, 4 Dec 2026 18:58:05 +0900 Message-ID: <20261204100713.944495125@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: patches@lists.linux.dev 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: Gal Pressman [ Upstream commit 520631554a689d2cd52452578f3140f045730ee0 ] mlx5e_ipsec_netevent_event() keeps the L2 headers of offloaded tunnel mode SAs up to date: on every neighbour change it looks for SAs whose endpoint matches the neighbour's address. The compare width, 4 bytes for IPv4 or 16 for IPv6, is chosen from the SA's address family, with no check that the neighbour is of the same family. An ARP entry only stores a 4-byte key, so with an IPv6 tunnel mode SA offloaded, any IPv4 neighbour update in the system is compared as if it were a 16-byte IPv6 address, reading past the end of the object: BUG: KASAN: slab-out-of-bounds in mlx5e_ipsec_netevent_event+0x736/0x8d0 [mlx5_core] Read of size 4 at addr ff110001260a4ad8 by task swapper/8/0 Call Trace: mlx5e_ipsec_netevent_event+0x736/0x8d0 [mlx5_core] notifier_call_chain+0x97/0x2b0 atomic_notifier_call_chain+0x5d/0x130 neigh_timer_handler+0x35c/0x1140 call_timer_fn+0x164/0x490 __run_timers+0x5b9/0x960 run_timer_softirq+0xf0/0x1d0 handle_softirqs+0x189/0x8a0 __irq_exit_rcu+0x10d/0x250 ... Allocated by task 1015: __kmalloc_noprof+0x2e6/0x8b0 ___neigh_create+0xcc9/0x24c0 ip_finish_output2+0xfc7/0x1e80 ip_output+0x172/0x3b0 ip_send_skb+0xa5/0x1b0 udp_send_skb+0x852/0x10f0 udp_sendmsg+0x1333/0x2150 ... The opposite mix (IPv4 SA with IPv6 neighbour) stays in bounds, but only the first 32 bits of the IPv6 address are compared, so an unrelated neighbour can match. Skip neighbours whose address family doesn't match the SA. Fixes: 4c24272b4e2b ("net/mlx5e: Listen to ARP events to update IPsec L2 headers in tunnel mode") Signed-off-by: Gal Pressman Reviewed-by: Leon Romanovsky Reviewed-by: Yael Chemla Signed-off-by: Tariq Toukan Reviewed-by: Fernando Fernandez Mancera Link: https://patch.msgid.link/20261021064231.3466989-1-tariqt@nvidia.com Signed-off-by: Jakub Kicinski [ sashal: Replaced attrs->addrs.family with attrs->family because this tree's SA attrs struct has no addrs sub-struct. ] Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c index 13c143610d6cf..ee4c02fd0a840 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c @@ -855,6 +855,9 @@ static int mlx5e_ipsec_netevent_event(struct notifier_block *nb, xa_for_each_marked(&ipsec->sadb, idx, sa_entry, MLX5E_IPSEC_TUNNEL_SA) { attrs = &sa_entry->attrs; + if (attrs->family != n->tbl->family) + continue; + if (attrs->family == AF_INET) { if (!neigh_key_eq32(n, &attrs->saddr.a4) && !neigh_key_eq32(n, &attrs->daddr.a4)) -- 2.53.0