Files
linux/net/ipv4
Jesper Dangaard Brouer 798c7dba90 net: fix divide by zero in tcp algorithm illinois
[ Upstream commit 8f363b77ee ]

Reading TCP stats when using TCP Illinois congestion control algorithm
can cause a divide by zero kernel oops.

The division by zero occur in tcp_illinois_info() at:
 do_div(t, ca->cnt_rtt);
where ca->cnt_rtt can become zero (when rtt_reset is called)

Steps to Reproduce:
 1. Register tcp_illinois:
     # sysctl -w net.ipv4.tcp_congestion_control=illinois
 2. Monitor internal TCP information via command "ss -i"
     # watch -d ss -i
 3. Establish new TCP conn to machine

Either it fails at the initial conn, or else it needs to wait
for a loss or a reset.

This is only related to reading stats.  The function avg_delay() also
performs the same divide, but is guarded with a (ca->cnt_rtt > 0) at its
calling point in update_params().  Thus, simply fix tcp_illinois_info().

Function tcp_illinois_info() / get_info() is called without
socket lock.  Thus, eliminate any race condition on ca->cnt_rtt
by using a local stack variable.  Simply reuse info.tcpv_rttcnt,
as its already set to ca->cnt_rtt.
Function avg_delay() is not affected by this race condition, as
its called with the socket lock.

Cc: Petr Matousek <pmatouse@redhat.com>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-17 13:14:24 -08:00
..
2012-02-03 09:18:54 -08:00
2011-03-12 15:08:49 -08:00
2011-08-15 18:31:39 -07:00
2011-02-01 15:35:25 -08:00
2012-10-13 05:28:07 +09:00
2012-02-29 16:34:18 -08:00
2012-03-23 11:20:51 -07:00
2011-05-17 14:16:58 -04:00
2012-10-28 10:02:13 -07:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2012-11-17 13:14:24 -08:00
2010-10-27 11:37:32 -07:00
2011-07-07 00:27:05 -07:00
2010-07-12 12:57:54 -07:00