Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp107118ybl; Thu, 22 Aug 2019 20:52:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCPDQvAyF0NIW82x4s7TpATeHX+gt4BRi3HQIoaHSzOfQdwSByhtuNr7pk1Voq8AaxLjlc X-Received: by 2002:a63:c304:: with SMTP id c4mr2128106pgd.126.1566532341999; Thu, 22 Aug 2019 20:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566532341; cv=none; d=google.com; s=arc-20160816; b=HOOSGa6agfegG6gIeaaV+U5ieRLAf+Ij+kdiIG0hWZcXD/LFEF86nGs1Jx9+ePAADq rHqPAYQNAkuinA4bFSm2XzxhViZ5NPuBkLrPI3SvxExpIePozQaqjYJWb5Jg+qH3cEVF OsBEeJeM7QUrC1Bhiaqk635uVkMA1kYSgHT1rjLkPhWnf0nlvhK4jc1Mh3njkacapTej 3iSInTUqISB3XH09V1UW621ThEaQ7yj8UtvPY9BDeEudhiWRJbyQa7Rk+Vdp4hsqeTUk zL4SWLC3Mb8OTj4Tb8eHiVbjr04L+/rI/JFhdj0ZLcobAksGwpYpT5XG+QbHU5ANo6k6 9eBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m1gOOWlLn6/kspl6TX9YuZXx4hq3nJr0BihMSH/xKaw=; b=M8hlWOlGB4qJvcBcsJfE3xk/cf8+M7uGdxjkkO1vUChtOUJRQOIKawdtyZouWJOOTI Zlo2RlVatYyyt8L7U5pg7S/FajM7JTjFh+Dd2kbF4O1BdVIJdHo5Qelm/mTquauijv5o vGHMH3wN++eq6s3iVYuYIxXftdgpDf3vQ+EGI4olFKy80kIhQF7Zg65SUg4/YXemp5Qf hWL9RMKCFQAh9niaFH3ffPPi6SRe/QLvlJr7V3KtvorJHquAbttMiM5VovJIvDAOa6MV m6Xgr/mg9GJUljhs4z95TFL4kZHxw1mHbZSwPUjlbXCuxrM9hYTPla+BbCENAPsjMje8 PGNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kiBIxfYz; 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 m186si1414943pfb.38.2019.08.22.20.52.07; Thu, 22 Aug 2019 20:52:21 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=kiBIxfYz; 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 S2404957AbfHVRi1 (ORCPT + 99 others); Thu, 22 Aug 2019 13:38:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:46036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404187AbfHVRY2 (ORCPT ); Thu, 22 Aug 2019 13:24:28 -0400 Received: from localhost (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0C0972341E; Thu, 22 Aug 2019 17:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566494667; bh=M0ON+wcSMXQ4IP2Gj/v1u/IHC14XFEaaHkW20mRRtX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kiBIxfYzDgxMGCEwJXi1uvk+1e9TsvbxG3tUAfkwLUP8vwyffM6jxMKUp69ovri0w rvVdAHswXhWGPcLaZFWgbL1GE9KUOGiQLLTXiMAwu1YFBDI3dhUouOeVmTs8HrrrsQ oCG/cQmX3YdS6/LbSMkMiDtJ1kwFbUHbBkjw93Yo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Binderman , Ian Abbott Subject: [PATCH 4.9 081/103] staging: comedi: dt3000: Fix signed integer overflow divider * base Date: Thu, 22 Aug 2019 10:19:09 -0700 Message-Id: <20190822171732.247195281@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190822171728.445189830@linuxfoundation.org> References: <20190822171728.445189830@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ian Abbott commit b4d98bc3fc93ec3a58459948a2c0e0c9b501cd88 upstream. In `dt3k_ns_to_timer()` the following lines near the end of the function result in a signed integer overflow: prescale = 15; base = timer_base * (1 << prescale); divider = 65535; *nanosec = divider * base; (`divider`, `base` and `prescale` are type `int`, `timer_base` and `*nanosec` are type `unsigned int`. The value of `timer_base` will be either 50 or 100.) The main reason for the overflow is that the calculation for `base` is completely wrong. It should be: base = timer_base * (prescale + 1); which matches an earlier instance of this calculation in the same function. Reported-by: David Binderman Cc: Signed-off-by: Ian Abbott Link: https://lore.kernel.org/r/20190812111517.26803-1-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt3000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -377,7 +377,7 @@ static int dt3k_ns_to_timer(unsigned int } prescale = 15; - base = timer_base * (1 << prescale); + base = timer_base * (prescale + 1); divider = 65535; *nanosec = divider * base; return (prescale << 16) | (divider);