summaryrefslogtreecommitdiff
path: root/include/net/inet_connection_sock.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-10-22 15:20:46 (GMT)
committerDavid S. Miller <davem@davemloft.net>2015-10-23 12:42:21 (GMT)
commit5e0724d027f0548511a2165a209572d48fe7a4c8 (patch)
tree709301be9b56652004047b89f4467b3c917814cd /include/net/inet_connection_sock.h
parent7b1311807f3d3eb8bef3ccc53127838b3bea3771 (diff)
downloadlinux-5e0724d027f0548511a2165a209572d48fe7a4c8.tar.xz
tcp/dccp: fix hashdance race for passive sessions
Multiple cpus can process duplicates of incoming ACK messages matching a SYN_RECV request socket. This is a rare event under normal operations, but definitely can happen. Only one must win the race, otherwise corruption would occur. To fix this without adding new atomic ops, we use logic in inet_ehash_nolisten() to detect the request was present in the same ehash bucket where we try to insert the new child. If request socket was not found, we have to undo the child creation. This actually removes a spin_lock()/spin_unlock() pair in reqsk_queue_unlink() for the fast path. Fixes: e994b2f0fb92 ("tcp: do not lock listener to process SYN packets") Fixes: 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table") Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/inet_connection_sock.h')
-rw-r--r--include/net/inet_connection_sock.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 6361570..481fe1c 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -43,7 +43,9 @@ struct inet_connection_sock_af_ops {
int (*conn_request)(struct sock *sk, struct sk_buff *skb);
struct sock *(*syn_recv_sock)(const struct sock *sk, struct sk_buff *skb,
struct request_sock *req,
- struct dst_entry *dst);
+ struct dst_entry *dst,
+ struct request_sock *req_unhash,
+ bool *own_req);
u16 net_header_len;
u16 net_frag_header_len;
u16 sockaddr_len;
@@ -272,6 +274,9 @@ void inet_csk_reqsk_queue_add(struct sock *sk, struct request_sock *req,
struct sock *child);
void inet_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req,
unsigned long timeout);
+struct sock *inet_csk_complete_hashdance(struct sock *sk, struct sock *child,
+ struct request_sock *req,
+ bool own_req);
static inline void inet_csk_reqsk_queue_added(struct sock *sk)
{