Skip to content

Commit e4823fb

Browse files
GustavoARSilvadavem330
authored andcommitted
tcp_nv: fix potential integer overflow in tcpnv_acked
Add suffix ULL to constant 80000 in order to avoid a potential integer overflow and give the compiler complete information about the proper arithmetic to use. Notice that this constant is used in a context that expects an expression of type u64. The current cast to u64 effectively applies to the whole expression as an argument of type u64 to be passed to div64_u64, but it does not prevent it from being evaluated using 32-bit arithmetic instead of 64-bit arithmetic. Also, once the expression is properly evaluated using 64-bit arithmentic, there is no need for the parentheses and the external cast to u64. Addresses-Coverity-ID: 1357588 ("Unintentional integer overflow") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 086ca23 commit e4823fb

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎net/ipv4/tcp_nv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ static void tcpnv_acked(struct sock *sk, const struct ack_sample *sample)
364364
*/
365365
cwnd_by_slope = (u32)
366366
div64_u64(((u64)ca->nv_rtt_max_rate) * ca->nv_min_rtt,
367-
(u64)(80000 * tp->mss_cache));
367+
80000ULL * tp->mss_cache);
368368
max_win = cwnd_by_slope + nv_pad;
369369

370370
/* If cwnd > max_win, decrease cwnd

0 commit comments

Comments
 (0)