Eric Dumazet b357a364c5 inet: fix possible panic in reqsk_queue_unlink()
[ 3897.923145] BUG: unable to handle kernel NULL pointer dereference at
 0000000000000080
[ 3897.931025] IP: [<ffffffffa9f27686>] reqsk_timer_handler+0x1a6/0x243

There is a race when reqsk_timer_handler() and tcp_check_req() call
inet_csk_reqsk_queue_unlink() on the same req at the same time.

Before commit fa76ce7328b2 ("inet: get rid of central tcp/dccp listener
timer"), listener spinlock was held and race could not happen.

To solve this bug, we change reqsk_queue_unlink() to not assume req
must be found, and we return a status, to conditionally release a
refcount on the request sock.

This also means tcp_check_req() in non fastopen case might or not
consume req refcount, so tcp_v6_hnd_req() & tcp_v4_hnd_req() have
to properly handle this.

(Same remark for dccp_check_req() and its callers)

inet_csk_reqsk_queue_drop() is now too big to be inlined, as it is
called 4 times in tcp and 3 times in dccp.

Fixes: fa76ce7328b2 ("inet: get rid of central tcp/dccp listener timer")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-04-24 11:39:15 -04:00
..
2014-09-18 10:54:36 +02:00
2015-03-04 00:23:23 -05:00
2015-03-06 21:50:02 -05:00
2013-11-07 19:28:58 -05:00
2015-03-12 14:39:40 -04:00
2014-09-30 01:02:26 -04:00
2015-03-12 14:39:40 -04:00
2014-06-04 22:46:38 -07:00
2015-01-18 01:56:32 -05:00
2015-03-17 22:02:29 -04:00
2015-03-11 16:22:14 -04:00
2015-03-12 14:39:40 -04:00
2015-04-07 22:24:37 -04:00
2014-01-03 20:56:48 -05:00
2015-03-12 14:39:40 -04:00
2015-01-15 18:26:16 -05:00
2014-06-02 11:00:41 -07:00
2015-04-09 00:01:38 -04:00
2015-03-12 22:58:12 -04:00
2014-05-22 14:57:15 -04:00