]> git.baikalelectronics.ru Git - kernel.git/commit
tcp: handle inet_csk_reqsk_queue_add() failures
authorGuillaume Nault <gnault@redhat.com>
Fri, 8 Mar 2019 21:09:47 +0000 (22:09 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 9 Mar 2019 00:05:10 +0000 (16:05 -0800)
commitb806376ebeeb32b74a777ef6877b814844262a0b
tree803b92c4735eb270910bc9846273b00e65343729
parent2d0e5c6961ae66e8f09b02aefd21b5185947062a
tcp: handle inet_csk_reqsk_queue_add() failures

Commit 8a32d89e0cef ("tcp/dccp: fix another race at listener
dismantle") let inet_csk_reqsk_queue_add() fail, and adjusted
{tcp,dccp}_check_req() accordingly. However, TFO and syncookies
weren't modified, thus leaking allocated resources on error.

Contrary to tcp_check_req(), in both syncookies and TFO cases,
we need to drop the request socket. Also, since the child socket is
created with inet_csk_clone_lock(), we have to unlock it and drop an
extra reference (->sk_refcount is initially set to 2 and
inet_csk_reqsk_queue_add() drops only one ref).

For TFO, we also need to revert the work done by tcp_try_fastopen()
(with reqsk_fastopen_remove()).

Fixes: 8a32d89e0cef ("tcp/dccp: fix another race at listener dismantle")
Signed-off-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/syncookies.c
net/ipv4/tcp_input.c