diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2009-12-03 22:46:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-08 23:17:51 -0500 |
commit | 9327f7053e3993c125944fdb137a0618319ef2a0 (patch) | |
tree | 3cee7de049a2468bef930b1832c42bd1b2e69e9a /net/dccp | |
parent | 74757d49016a8b06ca028196886641d7aeb78de5 (diff) |
tcp: Fix a connect() race with timewait sockets
First patch changes __inet_hash_nolisten() and __inet6_hash()
to get a timewait parameter to be able to unhash it from ehash
at same time the new socket is inserted in hash.
This makes sure timewait socket wont be found by a concurrent
writer in __inet_check_established()
Reported-by: kapil dakhane <kdakhane@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp')
-rw-r--r-- | net/dccp/ipv4.c | 2 | ||||
-rw-r--r-- | net/dccp/ipv6.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index efbcfdc12796..dad7bc4878e0 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -408,7 +408,7 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
408 | 408 | ||
409 | dccp_sync_mss(newsk, dst_mtu(dst)); | 409 | dccp_sync_mss(newsk, dst_mtu(dst)); |
410 | 410 | ||
411 | __inet_hash_nolisten(newsk); | 411 | __inet_hash_nolisten(newsk, NULL); |
412 | __inet_inherit_port(sk, newsk); | 412 | __inet_inherit_port(sk, newsk); |
413 | 413 | ||
414 | return newsk; | 414 | return newsk; |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 6574215a1f51..baf05cf43c28 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -46,7 +46,7 @@ static void dccp_v6_hash(struct sock *sk) | |||
46 | return; | 46 | return; |
47 | } | 47 | } |
48 | local_bh_disable(); | 48 | local_bh_disable(); |
49 | __inet6_hash(sk); | 49 | __inet6_hash(sk, NULL); |
50 | local_bh_enable(); | 50 | local_bh_enable(); |
51 | } | 51 | } |
52 | } | 52 | } |
@@ -644,7 +644,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
644 | newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; | 644 | newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; |
645 | newinet->inet_rcv_saddr = LOOPBACK4_IPV6; | 645 | newinet->inet_rcv_saddr = LOOPBACK4_IPV6; |
646 | 646 | ||
647 | __inet6_hash(newsk); | 647 | __inet6_hash(newsk, NULL); |
648 | __inet_inherit_port(sk, newsk); | 648 | __inet_inherit_port(sk, newsk); |
649 | 649 | ||
650 | return newsk; | 650 | return newsk; |