linux/net
Florian Westphal 587e6308d6 netfilter: nat: fix ipv6 nat redirect with mapped and scoped addresses
[ Upstream commit 80abbe8a82 ]

The ipv6 redirect target was derived from the ipv4 one, i.e. its
identical to a 'dnat' with the first (primary) address assigned to the
network interface.  The code has been moved around to make it usable
from nf_tables too, but its still the same as it was back when this
was added in 2012.

IPv6, however, has different types of addresses, if the 'wrong' address
comes first the redirection does not work.

In Daniels case, the addresses are:
  inet6 ::ffff:192 ...
  inet6 2a01: ...

... so the function attempts to redirect to the mapped address.

Add more checks before the address is deemed correct:
1. If the packets' daddr is scoped, search for a scoped address too
2. skip tentative addresses
3. skip mapped addresses

Use the first address that appears to match our needs.

Reported-by: Daniel Huhardeaux <tech@tootai.net>
Closes: https://lore.kernel.org/netfilter/71be06b8-6aa0-4cf9-9e0b-e2839b01b22f@tootai.net/
Fixes: 115e23ac78 ("netfilter: ip6tables: add REDIRECT target")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:52:17 +01:00
..
6lowpan
9p 9p/net: fix possible memory leak in p9_check_errors() 2023-11-20 11:52:13 +01:00
802
8021q
appletalk
atm
ax25
batman-adv
bluetooth Bluetooth: hci_sync: Fix Opcode prints in bt_dev_dbg/err 2023-11-20 11:51:55 +01:00
bpf
bpfilter
bridge neighbour: fix data-races around n->output 2023-10-10 22:00:42 +02:00
caif
can can: isotp: isotp_sendmsg(): fix TX state detection and wait behavior 2023-10-19 23:08:52 +02:00
ceph libceph: use kernel_connect() 2023-10-19 23:08:56 +02:00
core net: page_pool: add missing free_percpu when page_pool_init fail 2023-11-20 11:52:16 +01:00
dcb
dccp dccp/tcp: Call security_inet_conn_request() after setting IPv6 addresses. 2023-11-20 11:52:16 +01:00
devlink
dns_resolver
dsa
ethernet
ethtool
hsr hsr: Prevent use after free in prp_create_tagged_frame() 2023-11-20 11:52:15 +01:00
ieee802154
ife
ipv4 tcp: fix cookie_init_timestamp() overflows 2023-11-20 11:51:54 +01:00
ipv6 dccp/tcp: Call security_inet_conn_request() after setting IPv6 addresses. 2023-11-20 11:52:16 +01:00
iucv
kcm
key
l2tp ipv4, ipv6: Fix handling of transhdrlen in __ip{,6}_append_data() 2023-10-10 22:00:42 +02:00
l3mdev
lapb
llc llc: verify mac len before reading mac header 2023-11-20 11:52:15 +01:00
mac80211 wifi: mac80211: fix # of MSDU in A-MSDU calculation 2023-11-20 11:51:51 +01:00
mac802154
mctp mctp: perform route lookups under a RCU read-side lock 2023-10-19 23:08:57 +02:00
mpls
mptcp mptcp: avoid sending RST when closing the initial subflow 2023-10-25 12:03:16 +02:00
ncsi ncsi: Propagate carrier gain/loss events to the NCSI controller 2023-10-06 14:56:57 +02:00
netfilter netfilter: nat: fix ipv6 nat redirect with mapped and scoped addresses 2023-11-20 11:52:17 +01:00
netlabel
netlink netlink: remove the flex array from struct nlmsghdr 2023-10-10 22:00:46 +02:00
netrom
nfc nfc: nci: fix possible NULL pointer dereference in send_acknowledge() 2023-10-25 12:03:04 +02:00
nsh
openvswitch
packet
phonet
psample
qrtr
rds net: prevent address rewrite in kernel_bind() 2023-10-19 23:08:50 +02:00
rfkill net: rfkill: gpio: prevent value glitch during probe 2023-10-25 12:03:06 +02:00
rose
rxrpc
sched net: sched: cls_u32: Fix allocation size in u32_init() 2023-11-08 14:10:57 +01:00
sctp sctp: update hb timer immediately after users change hb_interval 2023-10-10 22:00:44 +02:00
smc net/smc: put sk reference if close work was canceled 2023-11-20 11:52:16 +01:00
strparser
sunrpc Revert "SUNRPC dont update timeout value on connection reset" 2023-10-06 14:57:03 +02:00
switchdev
tipc tipc: Change nla_policy for bearer-related names to NLA_NUL_STRING 2023-11-20 11:52:15 +01:00
tls tls: Use size_add() in call to struct_size() 2023-11-20 11:51:52 +01:00
unix
vmw_vsock vsock/virtio: remove socket from connected/bound list on shutdown 2023-11-20 11:52:17 +01:00
wireless wifi: cfg80211: add flush functions for wiphy work 2023-11-20 11:51:51 +01:00
x25
xdp
xfrm net: xfrm: skip policies marked as dead while reinserting policies 2023-10-25 12:03:12 +02:00
compat.c
devres.c
Kconfig
Kconfig.debug
Makefile
socket.c net: prevent address rewrite in kernel_bind() 2023-10-19 23:08:50 +02:00
sysctl_net.c