]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
IPv6: fix problem with duplicate port assignment with v4-mapped addrs
authorMike Karels <karels@FreeBSD.org>
Fri, 29 Jul 2022 14:23:23 +0000 (09:23 -0500)
committerMike Karels <karels@FreeBSD.org>
Tue, 2 Aug 2022 14:49:46 +0000 (09:49 -0500)
commit637f317c6d9c0c689677f499fc78ac545b192071
tree9ec868be61f307c4c04086675a60081fa9d73508
parent190c4c2499e64e1c88f25f68c2929d110d635300
IPv6: fix problem with duplicate port assignment with v4-mapped addrs

In in_pcb_lport_dest(), if an IPv6 socket does not match any other IPv6
socket using in6_pcblookup_local(), and if the socket can also connect
to IPv4 (the INP_IPV4 vflag is set), check for IPv4 matches as well.
Otherwise, we can allocate a port that is used by an IPv4 socket
(possibly one created from IPv6 via the same procedure), and then
connect() can fail with EADDRINUSE, when it could have succeeded if
the bound port was not in use.

PR: 265064
Submitted by: firk at cantconnect.ru (with modifications)
Reviewed by: bz, melifaro
Differential Revision: https://reviews.freebsd.org/D36012
sys/netinet/in_pcb.c