]> git.baikalelectronics.ru Git - kernel.git/commit
tcp: disallow bind() to reuse addr/port
authorEric Dumazet <eric.dumazet@gmail.com>
Tue, 11 Jan 2011 01:14:22 +0000 (01:14 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 11 Jan 2011 22:03:07 +0000 (14:03 -0800)
commitf3b7b03719bef53bc539d9dca7ec18197a983dc4
tree98ab4ed7316d55bb014f758e590fec2811694f30
parent7fcbed6c381506363085c199c675b4a703f884a0
tcp: disallow bind() to reuse addr/port

inet_csk_bind_conflict() logic currently disallows a bind() if
it finds a friend socket (a socket bound on same address/port)
satisfying a set of conditions :

1) Current (to be bound) socket doesnt have sk_reuse set
OR
2) other socket doesnt have sk_reuse set
OR
3) other socket is in LISTEN state

We should add the CLOSE state in the 3) condition, in order to avoid two
REUSEADDR sockets in CLOSE state with same local address/port, since
this can deny further operations.

Note : a prior patch tried to address the problem in a different (and
buggy) way. (commit f4899d0dac5bcdf21 tcp: bind() fix when many ports
are bound).

Reported-by: Gaspar Chilingarov <gasparch@gmail.com>
Reported-by: Daniel Baluta <daniel.baluta@gmail.com>
Tested-by: Daniel Baluta <daniel.baluta@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/inet_connection_sock.c
net/ipv6/inet6_connection_sock.c