From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754632AbdKANrx (ORCPT ); Wed, 1 Nov 2017 09:47:53 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:51076 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751738AbdKANrv (ORCPT ); Wed, 1 Nov 2017 09:47:51 -0400 From: Lawrence Brakmo To: Konstantin Khlebnikov , "netdev@vger.kernel.org" , "David S. Miller" CC: Alexey Kuznetsov , Hideaki YOSHIFUJI , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] tcp_nv: fix division by zero in tcpnv_acked() Thread-Topic: [PATCH] tcp_nv: fix division by zero in tcpnv_acked() Thread-Index: AQHTUxXna/4eJRcF8k6uCcFf0dWyPKL/ia8A Date: Wed, 1 Nov 2017 13:47:17 +0000 Message-ID: <5FF5EDEE-FF34-43E0-9DFA-6CBDB206360D@fb.com> References: <150954313588.153848.10192893966808917578.stgit@buzz> In-Reply-To: <150954313588.153848.10192893966808917578.stgit@buzz> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/f.26.0.170902 x-originating-ip: [2620:10d:c090:180::1:397a] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR15MB1670;20:LHmC4YQKw/DbLQUDVWs05dsKtJ0Tx4uIbYLWaf6LX0JwNVWNkGpVO9D4aziLN84mw0vDoHXYbcLshHu15khRd/IoAtS7kvNkftfl/T2vs1FtC98as5qCURsLkA6oxl/luIuMJS2Ru/74+UkNaAjV2wD775C5S3GEz72SP9GbttI= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 634b3547-1e02-4803-6974-08d5212f10e6 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(2017052603199);SRVR:CY4PR15MB1670; x-ms-traffictypediagnostic: CY4PR15MB1670: x-exchange-antispam-report-test: UriScan:(67672495146484); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(11241501159)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(3231020)(6041248)(20161123558100)(20161123564025)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR15MB1670;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR15MB1670; x-forefront-prvs: 0478C23FE0 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(346002)(376002)(199003)(24454002)(189002)(2900100001)(86362001)(33656002)(2906002)(3280700002)(8936002)(53936002)(4477795004)(6246003)(3660700001)(76176999)(54356999)(54906003)(97736004)(50986999)(5660300001)(82746002)(229853002)(2950100002)(83716003)(101416001)(478600001)(110136005)(316002)(25786009)(189998001)(77096006)(6486002)(58126008)(68736007)(105586002)(14454004)(345774005)(106356001)(6116002)(305945005)(102836003)(6512007)(81156014)(81166006)(8676002)(53546010)(99286003)(83506002)(36756003)(6506006)(6436002)(4326008)(7736002)(2501003);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR15MB1670;H:CY4PR15MB1671.namprd15.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <85C36806C43CA144A375021662C5F18F@namprd15.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 634b3547-1e02-4803-6974-08d5212f10e6 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Nov 2017 13:47:17.2570 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1670 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-01_03:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id vA1DlxEX003502 Thank you for finding and fixing this. On 11/1/17, 6:32 AM, "Konstantin Khlebnikov" wrote: Average RTT could become zero. This happened in real life at least twice. This patch treats zero as 1us. Signed-off-by: Konstantin Khlebnikov khlebnikov@yandex-team.ru Acked-by: Lawrence Brakmo --- net/ipv4/tcp_nv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_nv.c b/net/ipv4/tcp_nv.c index 1ff73982e28c..125fc1450b01 100644 --- a/net/ipv4/tcp_nv.c +++ b/net/ipv4/tcp_nv.c @@ -252,7 +252,7 @@ static void tcpnv_acked(struct sock *sk, const struct ack_sample *sample) /* rate in 100's bits per second */ rate64 = ((u64)sample->in_flight) * 8000000; - rate = (u32)div64_u64(rate64, (u64)(avg_rtt * 100)); + rate = (u32)div64_u64(rate64, (u64)(avg_rtt ?: 1) * 100); /* Remember the maximum rate seen during this RTT * Note: It may be more than one RTT. This function should be