]> git.baikalelectronics.ru Git - kernel.git/commit
tcp/dccp: fix hashdance race for passive sessions
authorEric Dumazet <edumazet@google.com>
Thu, 22 Oct 2015 15:20:46 +0000 (08:20 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 23 Oct 2015 12:42:21 +0000 (05:42 -0700)
commit95c4998b98f499411c91c34190eb5b7caf45d226
tree709301be9b56652004047b89f4467b3c917814cd
parent7277dfbe5677461fed857d6b2382eb5eac857d98
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: 6c67d9803aed ("tcp: do not lock listener to process SYN packets")
Fixes: aaf9f4668c2b ("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>
14 files changed:
include/net/inet_connection_sock.h
include/net/inet_hashtables.h
include/net/tcp.h
net/dccp/dccp.h
net/dccp/ipv4.c
net/dccp/ipv6.c
net/dccp/minisocks.c
net/ipv4/inet_connection_sock.c
net/ipv4/inet_hashtables.c
net/ipv4/syncookies.c
net/ipv4/tcp_fastopen.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c
net/ipv6/tcp_ipv6.c