]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - net/ipv4/inet_connection_sock.c
inet: Fix get port to handle zero port number with soreuseport set
authorTom Herbert <tom@herbertland.com>
Thu, 15 Dec 2016 00:54:16 +0000 (16:54 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 17 Dec 2016 16:13:19 +0000 (11:13 -0500)
commit0643ee4fd1b79c1af3bd7bc8968dbf5fd047f490
treeddae48385faf13e6537d82b1f72cff8553456a9a
parent9af7e923fdd82dc25ad5ea75e24e92708947f961
inet: Fix get port to handle zero port number with soreuseport set

A user may call listen with binding an explicit port with the intent
that the kernel will assign an available port to the socket. In this
case inet_csk_get_port does a port scan. For such sockets, the user may
also set soreuseport with the intent a creating more sockets for the
port that is selected. The problem is that the initial socket being
opened could inadvertently choose an existing and unreleated port
number that was already created with soreuseport.

This patch adds a boolean parameter to inet_bind_conflict that indicates
rather soreuseport is allowed for the check (in addition to
sk->sk_reuseport). In calls to inet_bind_conflict from inet_csk_get_port
the argument is set to true if an explicit port is being looked up (snum
argument is nonzero), and is false if port scan is done.

Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/inet6_connection_sock.h
include/net/inet_connection_sock.h
net/ipv4/inet_connection_sock.c
net/ipv6/inet6_connection_sock.c