tcp_nv: fix potential integer overflow in tcpnv_acked
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Wed, 31 Jan 2018 04:21:48 +0000 (22:21 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Apr 2018 09:02:13 +0000 (11:02 +0200)
commita6a25002e6d83c4b66297a0fd192927c8fa0988d
tree0d46b731dda9ba8f6b6f8fb9650ed5a51afe7f0c
parentad10785a706e63ff155fc97860cdcc5e3bc5992d
tcp_nv: fix potential integer overflow in tcpnv_acked

[ Upstream commit e4823fbd229bfbba368b40cdadb8f4eeb20604cc ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv4/tcp_nv.c