tcp/dccp: fix timewait races in timer handling
Eric Dumazet authored
[ Upstream commit ed2e9239 ]

When creating a timewait socket, we need to arm the timer before
allowing other cpus to find it. The signal allowing cpus to find
the socket is setting tw_refcnt to non zero value.

As we set tw_refcnt in __inet_twsk_hashdance(), we therefore need to
call inet_twsk_schedule() first.

This also means we need to remove tw_refcnt changes from
inet_twsk_schedule() and let the caller handle it.

Note that because we use mod_timer_pinned(), we have the guarantee
the timer wont expire before we set tw_refcnt as we run in BH context.

To make things more readable I introduced inet_twsk_reschedule() helper.

When rearming the timer, we can use mod_timer_pending() to make sure
we do not rearm a canceled timer.

Note: This bug can possibly trigger if packets of a flow can hit
multiple cpus. This does not normally happen, unless flow steering
is broken somehow. This explains this bug was spotted ~5 months afte...
479b539a
Name Last commit Last update
..
ccids dccp: re-enable debug macro
Kconfig net/dccp: remove depends on CONFIG_EXPERIMENTAL
Makefile dccp: Policy-based packet dequeueing infrastructure
ackvec.c dccp: replace min/casting by min_t
ackvec.h net: dccp: Remove extern from function prototypes
ccid.c net/dccp/ccid.c: add __init to ccid_activate
ccid.h net: dccp: Remove extern from function prototypes
dccp.h ipv4: dccp: handle ICMP messages on DCCP_NEW_SYN_RECV request sockets
diag.c inet_diag: add const to inet_diag_req_v2
feat.c dccp: kerneldoc warning fixes
feat.h net: dccp: Remove extern from function prototypes
input.c dccp: spelling s/reseting/resetting
ipv4.c inet: fix possible panic in reqsk_queue_unlink()
ipv6.c ipv6: add complete rcu protection around np->opt
ipv6.h inet: includes a sock_common in request_sock
minisocks.c tcp/dccp: fix timewait races in timer handling
options.c dccp: remove obsolete code
output.c ipv4: add a sock pointer to ip_queue_xmit()
probe.c net: Remove iocb argument from sendmsg and recvmsg
proto.c net: Remove iocb argument from sendmsg and recvmsg
qpolicy.c dccp qpolicy: Parameter checking of cmsg qpolicy parameters
sysctl.c dccp: make the request_retries minimum is 1
timer.c inet: get rid of central tcp/dccp listener timer