tcp: Fix connect() races with timewait sockets
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 3 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | tcp: Fix a connect() race with timewait socketsinclude/ include/ net/ +5 more | +35 | 5 replies | |
| 2/2 | tcp: Fix a connect() race with timewait socketsinclude/ net/ net/ | +26 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] tcp: Fix connect() races with timewait sockets
Quoted 11 lines · Eric Dumazet
[PATCH] tcp: Fix a
connect()race with timewait socketsWhen we find a timewait connection in
__inet_hash_connect()and reuse it for a new connection request, we have a race window, releasing bind list lock and reacquiring it in__inet_twsk_kill()to remove timewait socket from list.Another thread might find the timewait socket we already chose, leading to list corruption and crashes.
Fix is to remove timewait socket from bind list before releasing the lock.
I cooked two patches on top of net-next-2.6 to solve the two last race problems I am aware of.
Kapil, if you want to test them, make sure you take last net-next-2.6 snapshot.
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 into ehash.
Second patch is a respin of the first patch I sent :
It makes sure __inet_has_connect() cannot give same timewait socket to different threads.
Thanks !