mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fernando Fernandez Mancera <fmancera@suse.de>
To: Tariq Toukan <tariqt@nvidia.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>
Cc: Boris Pismenny <borisp@nvidia.com>, Gal Pressman <gal@nvidia.com>,
	Jianbo Liu <jianbol@nvidia.com>, Kees Cook <kees@kernel.org>,
	Leon Romanovsky <leon@kernel.org>,
	Leon Romanovsky <leonro@nvidia.com>,
	open list <linux-kernel@vger.kernel.org>,
	linux-rdma@vger.kernel.org, Mark Bloch <mbloch@nvidia.com>,
	Prathamesh Deshpande <prathameshdeshpande7@gmail.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Simon Horman <horms@kernel.org>,
	Sridhar Samudrala <sridhar.samudrala@intel.com>,
	Yael Chemla <ychemla@nvidia.com>
Subject: Re: [PATCH net] net/mlx5e: IPsec, Fix out-of-bounds comparison of neighbour keys
Date: Wed, 21 Oct 2026 15:41:22 +0200	[thread overview]
Message-ID: <5eb0f607-5cc0-46aa-a51d-9cdacea3fe3d@suse.de> (raw)
In-Reply-To: <20261021064231.3466989-1-tariqt@nvidia.com>

On 10/21/26 8:42 AM, Tariq Toukan wrote:
> From: Gal Pressman <gal@nvidia.com>
> 
> 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:
>     <IRQ>
>     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 <gal@nvidia.com>
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> Reviewed-by: Yael Chemla <ychemla@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>

      reply	other threads:[~2026-10-21 13:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21  6:42 Tariq Toukan
2026-10-21 13:41 ` Fernando Fernandez Mancera [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5eb0f607-5cc0-46aa-a51d-9cdacea3fe3d@suse.de \
    --to=fmancera@suse.de \
    --cc=andrew+netdev@lunn.ch \
    --cc=borisp@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=gal@nvidia.com \
    --cc=horms@kernel.org \
    --cc=jianbol@nvidia.com \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=leonro@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=prathameshdeshpande7@gmail.com \
    --cc=saeedm@nvidia.com \
    --cc=sridhar.samudrala@intel.com \
    --cc=tariqt@nvidia.com \
    --cc=ychemla@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®