From patchwork Fri Sep 28 16:22:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10620155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8DB8215A7 for ; Fri, 28 Sep 2018 16:23:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 820D42BE3F for ; Fri, 28 Sep 2018 16:23:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 763332BE48; Fri, 28 Sep 2018 16:23:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0264D2BE3F for ; Fri, 28 Sep 2018 16:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbeI1Wr3 (ORCPT ); Fri, 28 Sep 2018 18:47:29 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41223 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726121AbeI1Wr3 (ORCPT ); Fri, 28 Sep 2018 18:47:29 -0400 Received: by mail-pf1-f196.google.com with SMTP id m77-v6so4653223pfi.8 for ; Fri, 28 Sep 2018 09:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bqD2kx8pVl5nLYzlK1nOGcZPhgfhasQOrHzBnUnMc4o=; b=FxPqNCkI+3rDUKms+TyJtQz4WsgIr0vseIMDAkoXbQh+fI/U2VJITAf8hX50W+KlGT 3nV4FIsOH3lZBXRyR1hzH9fvOYLhbxxs3itqYkTvOetnv4EiZ70d4z9+0xGtqrif6M0b vDF2lopYUD3Qz5wRJrpFK8IpgU4bhqYSSRISXbqThZh9Dav33a+2w1z8xm72dL+AJ9gd PjEWU3D7ZuB7ni26E8MoGPM1bt+iEQB1QIJ0Ep3hQobmzLkkjd3SEVg1QVvhdvea4rDu Cx1Vdn9wwNfttMy7Ie57WVsYjOveK+iFw9H8DKoJdx611IVI+wP00rfcJEPo8Q69RoDh vqXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bqD2kx8pVl5nLYzlK1nOGcZPhgfhasQOrHzBnUnMc4o=; b=Iue+SvsGrFhn9kcf8CbRy51WGCAP8Yg1s9BlHdVFuX2JzQhE9kXqzXGjCwfFbZbD1I gixDTLzDTS6yPTDLOeMq2GHuNUR8Ev6nLGP5s21vxyaF9yAUVEruSZqqHdlC84Rt5rVu MQJVS3GGv9rXm96ZKdXiPg6cknQyIYl0X9yxmIi/Z+flYe9qR7C+4Uc8IuVMr3uhJJ0h Pvs2OUSovl00+vUrRpVi9wavsD7hui38JD5i8Hd4n2Vdvw7qIFr0FsrJo0LklmCJUf0Y LdfZxFc0PGpInPF4OwegSWN/eENJZaqDuEYslJOIYAjfJkNLEDa06dfWmlwgj8sBGSKG yy/w== X-Gm-Message-State: ABuFfogmu9MaL1w8ykD9cgZEFuVvpBtXY/s4csnY9ITNFuATj+vaZSLx 5j3vpv2GlnvGU/foTCEXUpqAdK7dLPIaXw== X-Google-Smtp-Source: ACcGV62yNeNVUSo45Gem4LWUJ++sEdW/HKTaVj+78YY0IVauHWO3p+K4wn7OrtcFp/krbIhrIUr7qQ== X-Received: by 2002:a62:7f8c:: with SMTP id a134-v6mr17388765pfd.257.1538151777894; Fri, 28 Sep 2018 09:22:57 -0700 (PDT) Received: from vader.hsd1.wa.comcast.net ([2601:602:8800:a9a9:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id r81-v6sm8830387pfa.18.2018.09.28.09.22.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Sep 2018 09:22:57 -0700 (PDT) From: Omar Sandoval To: linux-block@vger.kernel.org Cc: Jens Axboe , kernel-team@fb.com, Stephen Rothwell Subject: [PATCH] kyber: fix integer overflow of latency targets on 32-bit Date: Fri, 28 Sep 2018 09:22:50 -0700 Message-Id: <56a03261ec32ef67a8ce36106bf2f2f7638600ca.1538151757.git.osandov@fb.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval NSEC_PER_SEC has type long, so 5 * NSEC_PER_SEC is calculated as a long. However, 5 seconds is 5,000,000,000 nanoseconds, which overflows a 32-bit long. Make sure all of the targets are calculated as 64-bit values. Fixes: 6e25cb01ea20 ("kyber: implement improved heuristics") Reported-by: Stephen Rothwell Signed-off-by: Omar Sandoval --- block/kyber-iosched.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/kyber-iosched.c b/block/kyber-iosched.c index 2b62e362fb36..eccac01a10b6 100644 --- a/block/kyber-iosched.c +++ b/block/kyber-iosched.c @@ -79,9 +79,9 @@ static const unsigned int kyber_depth[] = { * Default latency targets for each scheduling domain. */ static const u64 kyber_latency_targets[] = { - [KYBER_READ] = 2 * NSEC_PER_MSEC, - [KYBER_WRITE] = 10 * NSEC_PER_MSEC, - [KYBER_DISCARD] = 5 * NSEC_PER_SEC, + [KYBER_READ] = 2ULL * NSEC_PER_MSEC, + [KYBER_WRITE] = 10ULL * NSEC_PER_MSEC, + [KYBER_DISCARD] = 5ULL * NSEC_PER_SEC, }; /*