linux-stable/net/ipv6
Fabian Bläse 8d09b13789 icmp: fix icmp_ndo_send address translation for reply direction
[ Upstream commit c6dd1aa2cb ]

The icmp_ndo_send function was originally introduced to ensure proper
rate limiting when icmp_send is called by a network device driver,
where the packet's source address may have already been transformed
by SNAT.

However, the original implementation only considers the
IP_CT_DIR_ORIGINAL direction for SNAT and always replaced the packet's
source address with that of the original-direction tuple. This causes
two problems:

1. For SNAT:
   Reply-direction packets were incorrectly translated using the source
   address of the CT original direction, even though no translation is
   required.

2. For DNAT:
   Reply-direction packets were not handled at all. In DNAT, the original
   direction's destination is translated. Therefore, in the reply
   direction the source address must be set to the reply-direction
   source, so rate limiting works as intended.

Fix this by using the connection direction to select the correct tuple
for source address translation, and adjust the pre-checks to handle
reply-direction packets in case of DNAT.

Additionally, wrap the `ct->status` access in READ_ONCE(). This avoids
possible KCSAN reports about concurrent updates to `ct->status`.

Fixes: 0b41713b60 ("icmp: introduce helper for nat'd source address in network device context")
Signed-off-by: Fabian Bläse <fabian@blaese.de>
Cc: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-09-09 18:56:22 +02:00
..
ila net: Fix checksum update for ILA adj-transport 2025-06-27 11:09:00 +01:00
netfilter netfilter: nf_reject: don't leak dst refcount for loopback packets 2025-08-28 16:28:50 +02:00
addrconf_core.c
addrconf.c ipv6: mcast: Check inet6_dev->dead under idev->mc_lock in __ipv6_dev_mc_inc(). 2025-08-28 16:28:21 +02:00
addrlabel.c
af_inet6.c
ah6.c
anycast.c
calipso.c calipso: Fix null-ptr-deref in calipso_req_{set,del}attr(). 2025-06-27 11:09:02 +01:00
datagram.c
esp6_offload.c
esp6.c espintcp: remove encap socket caching to avoid reference leak 2025-06-04 14:42:17 +02:00
exthdrs_core.c
exthdrs_offload.c
exthdrs.c
fib6_notifier.c
fib6_rules.c ip: fib_rules: Fetch net from fib_rule in fib[46]_rule_configure(). 2025-06-04 14:42:11 +02:00
fou6.c
icmp.c ipv6: icmp: convert to dev_net_rcu() 2025-02-21 13:57:21 +01:00
inet6_connection_sock.c
inet6_hashtables.c
ioam6_iptunnel.c
ioam6.c
ip6_checksum.c
ip6_fib.c ipv6: annotate data-races around rt->fib6_nsiblings 2025-08-15 12:08:51 +02:00
ip6_flowlabel.c
ip6_gre.c
ip6_icmp.c icmp: fix icmp_ndo_send address translation for reply direction 2025-09-09 18:56:22 +02:00
ip6_input.c
ip6_offload.c ipv6: reject malicious packets in ipv6_gso_segment() 2025-08-15 12:09:02 +02:00
ip6_offload.h
ip6_output.c Revert "ipv6: save dontfrag in cork" 2025-07-06 11:00:16 +02:00
ip6_tunnel.c ipv4: Convert ip_route_input() to dscp_t. 2025-03-07 16:45:39 +01:00
ip6_udp_tunnel.c
ip6_vti.c
ip6mr.c net: ipv6: ip6mr: Fix in/out netdev to pass to the FORWARD chain 2025-08-15 12:08:45 +02:00
ipcomp6.c
ipv6_sockglue.c
Kconfig
Makefile
mcast_snoop.c
mcast.c ipv6: mcast: Check inet6_dev->dead under idev->mc_lock in __ipv6_dev_mc_inc(). 2025-08-28 16:28:21 +02:00
mip6.c
ndisc.c ndisc: extend RCU protection in ndisc_send_skb() 2025-02-21 13:57:24 +01:00
netfilter.c netfilter: bridge: Move specific fragmented packet to slow_path instead of dropping it 2025-06-19 15:28:13 +02:00
output_core.c
ping.c
proc.c
protocol.c
raw.c
reassembly.c net: Rename mono_delivery_time to tstamp_type for scalabilty 2025-05-09 09:43:57 +02:00
route.c ipv6: annotate data-races around rt->fib6_nsiblings 2025-08-15 12:08:51 +02:00
rpl_iptunnel.c rpl: Fix use-after-free in rpl_do_srh_inline(). 2025-07-24 08:53:17 +02:00
rpl.c
seg6_hmac.c ipv6: sr: validate HMAC algorithm ID in seg6_hmac_info_add 2025-08-28 16:28:48 +02:00
seg6_iptunnel.c net: ipv6: fix dst ref loop on input in seg6 lwt 2025-03-07 16:45:42 +01:00
seg6_local.c seg6: Fix validation of nexthop addresses 2025-06-19 15:28:35 +02:00
seg6.c
sit.c
syncookies.c
sysctl_net_ipv6.c
tcp_ipv6.c net: Rename mono_delivery_time to tstamp_type for scalabilty 2025-05-09 09:43:57 +02:00
tcpv6_offload.c
tunnel6.c
udp_impl.h
udp_offload.c
udp.c udp: gso: do not drop small packets when PMTU reduces 2025-02-17 09:40:12 +01:00
udplite.c
xfrm6_input.c
xfrm6_output.c
xfrm6_policy.c
xfrm6_protocol.c
xfrm6_state.c
xfrm6_tunnel.c