Received: by 10.223.176.5 with SMTP id f5csp2071763wra; Wed, 31 Jan 2018 16:25:31 -0800 (PST) X-Google-Smtp-Source: AH8x227+iG5e5PTkYNMztFfUGyiK1MbTwNZfFEU7E8Ef8083zYW+cTGw4zNJ13EmfMPK+hJd2RdS X-Received: by 10.99.113.11 with SMTP id m11mr28037744pgc.57.1517444731296; Wed, 31 Jan 2018 16:25:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517444731; cv=none; d=google.com; s=arc-20160816; b=fsKb4l3IMpgCJD8Z5PiKMpyTzjAN04QWnt7U9qLIJEv12+QJnmlFSU3s4DFJbr51W8 r/nEfN64D6yeXZ4+AFZdKxxEfQ3FO51dhMapnzejODAM4cB/V3loPsIch3ILROGd4GGR YS0/TJ/3mMGELqacrONPpqx9zCMNF+1ByUtxGjSpmPERf1YazT6oPlV8r2IKE5zQBu6i uXgNleDemtj/W7JTCUaDD4s5b/kRvY8k9jG99yfviiWBmnsWfmv95fr9Zybsm+PmZzPL G4Jrt7QGP/NyiBA8BeeSp7Ov5hrc03DyIEivO4k0AiClBkckniO9FIERLfNiO7i1fbnF G+sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=aqQfRTTP6KtWyFSbN2Ys9RY7b7JKXie3Pj9+LS8xpvQ=; b=wsDvz/xknhGYMiIkP80htrQdCW07fdVAmbFPRUtUY9TQ6gsU91Qj5gobgJGxXV4GRq mkLOEYgB9DD8FvZZfQ6VmLd/0bJ/LeNsoDoUVrh74ppEK6nvSuOcG0pES2Y6YmnwiWCQ mtdAyJ+FH23sIlPCJsUoLIuBkjmpmEATi2qFgSSqV1aOyq/uNwCIfwZ6FcfOrqxRgPSu msYjYK5XcGXNJRjB85+q4JZ6BeXjc7DSgxJyIEPqlNu7wrj+YisfXha1nmTgaSfv4bf9 iNbTcy1KWwrOYAod8/b+3mkyCVID367MGpa0QVfTc+Zr0TOPPaJyLYTsPLZqTNLPOD3n i4Kw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m37-v6si5463283plg.37.2018.01.31.16.25.05; Wed, 31 Jan 2018 16:25:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932140AbeBAAYM (ORCPT + 99 others); Wed, 31 Jan 2018 19:24:12 -0500 Received: from gateway22.websitewelcome.com ([192.185.46.131]:16273 "EHLO gateway22.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753846AbeBAAYJ (ORCPT ); Wed, 31 Jan 2018 19:24:09 -0500 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway22.websitewelcome.com (Postfix) with ESMTP id A613911496 for ; Wed, 31 Jan 2018 18:24:08 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id h2fgeuB6hBUMKh2fgeyTSO; Wed, 31 Jan 2018 18:24:08 -0600 Received: from [189.152.201.65] (port=43454 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1eh2fg-000wkz-4r; Wed, 31 Jan 2018 18:24:08 -0600 Date: Wed, 31 Jan 2018 18:24:07 -0600 From: "Gustavo A. R. Silva" To: "Wong Hoi Sing, Edison" , "Hung Hing Lun, Mike" , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] tcp_lp: use 64-bit arithmetic instead of 32-bit Message-ID: <20180201002407.GA1608@embeddedgus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.152.201.65 X-Source-L: No X-Exim-ID: 1eh2fg-000wkz-4r X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.152.201.65]:43454 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 7 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cast to s64 some variables and a macro in order to give the compiler complete information about the proper arithmetic to use. Notice that these elements are used in contexts that expect expressions of type s64 (64 bits, signed). Currently such expression are being evaluated using 32-bit arithmetic. Addresses-Coverity-ID: 200687 Addresses-Coverity-ID: 200688 Addresses-Coverity-ID: 200689 Signed-off-by: Gustavo A. R. Silva --- net/ipv4/tcp_lp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c index ae10ed6..4999111 100644 --- a/net/ipv4/tcp_lp.c +++ b/net/ipv4/tcp_lp.c @@ -134,7 +134,7 @@ static u32 tcp_lp_remote_hz_estimator(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); struct lp *lp = inet_csk_ca(sk); - s64 rhz = lp->remote_hz << 6; /* remote HZ << 6 */ + s64 rhz = (s64)lp->remote_hz << 6; /* remote HZ << 6 */ s64 m = 0; /* not yet record reference time @@ -147,7 +147,7 @@ static u32 tcp_lp_remote_hz_estimator(struct sock *sk) tp->rx_opt.rcv_tsecr == lp->local_ref_time) goto out; - m = TCP_TS_HZ * + m = (s64)TCP_TS_HZ * (tp->rx_opt.rcv_tsval - lp->remote_ref_time) / (tp->rx_opt.rcv_tsecr - lp->local_ref_time); if (m < 0) @@ -193,8 +193,8 @@ static u32 tcp_lp_owd_calculator(struct sock *sk) if (lp->flag & LP_VALID_RHZ) { owd = - tp->rx_opt.rcv_tsval * (LP_RESOL / lp->remote_hz) - - tp->rx_opt.rcv_tsecr * (LP_RESOL / TCP_TS_HZ); + (s64)tp->rx_opt.rcv_tsval * (LP_RESOL / lp->remote_hz) - + (s64)tp->rx_opt.rcv_tsecr * (LP_RESOL / TCP_TS_HZ); if (owd < 0) owd = -owd; } -- 2.7.4