The port recovered with getsockname() in _fd_delete_orphan() was given
back to the port range without being converted to host byte order. The
range then fills up with byte-swapped values which are handed out on the
next pass. Both TCP and QUIC are affected.
It is now released using get_host_port(), which takes care of the
conversion for both address families.
The issue was introduced with commit
02b7685013 ("MEDIUM: fd: Remove
fdinfo").
No backport needed.
* to figure out what the port was.
*/
BUG_ON(getsockname(fd, (struct sockaddr *)&sa, &addrlen) != 0);
- if (sa.ss_family == AF_INET)
- port = ((struct sockaddr_in *)&sa)->sin_port;
- else if (sa.ss_family == AF_INET6)
- port = ((struct sockaddr_in6 *)&sa)->sin6_port;
- else
+ port = get_host_port(&sa);
+ if (!port)
ABORT_NOW();
port_range_release_port(fdtab[fd].owner, port);
}