Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1419142ybl; Thu, 22 Aug 2019 14:19:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqy509G9LUsCsQS/XcgA2qRTx47s8LEDAG/nL4Zu0znrNYcD5CS8Cp5RIK+fAexhz47y26a3 X-Received: by 2002:a65:4786:: with SMTP id e6mr1034944pgs.448.1566508793808; Thu, 22 Aug 2019 14:19:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566508793; cv=none; d=google.com; s=arc-20160816; b=anKx/3ortIRD17MselJYwqGpaFyBTkA/5xX8w159X0EHkOPVMEcNyXwuGTh7m2JLve tPUr6PGS5UAbAcnFwhkLZDFjmYdgrNd/vvfD1mdFx5fj+eoC2BYVAS1TRrRTyRhNUTCg pWD6+Afz242D+zxCGn9KOXG6jTFThY7wLU9YXKNtinwskxNaxRg7Lr9Kv+wQ6DsyTCRR snS9yeeGLd/hszGugGOOHejpBDrzmu6ajFRzbvxrG46AMyCSXVOD85wJ1VNVnlme9hfa xDIuOEm79cjueB75cgG1q7PL5IWnfOue55PRhVhT++sewsrCGN0mFil++eq4m57mVv56 1WLA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AJ8OL1xQZOHwaiA1m/PiK8w8+kbq+ofHK5R+gyI7qP8=; b=KOAScrHh13M8Re+CgI+rWhRc9r++poHcC1k5sUkI/o11Pa51+yi13ktoj+y2yBasHA V/3cvfjdDdqkxdZ8l+Olciu2EIBa7bWwRcZfynNuqBDngv2BmsER4LvdXKUMqdMzZgzy 2pwzNcrCUgrR7cIf7pyaNI6QZuKyURQalVQnnsHcs+LkI/nkCnXbTW9rLISJRCqYRMhm 5QBGB9EE0/9h3OG259CMhQaEomtRBx1o86rxDMODqSW7RnWtArhXGsFqNYDD3saq8T9R +IarvEeuF3H5x0dTPj7cN4zaRapf8+II/moHQkj7eejRW3ejKXM22nFbPAC/uVVKcwQB vMmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OZDN8NLV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2si598235pjk.86.2019.08.22.14.19.38; Thu, 22 Aug 2019 14:19:53 -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=OZDN8NLV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390686AbfHVRJJ (ORCPT + 99 others); Thu, 22 Aug 2019 13:09:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:59282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390652AbfHVRJF (ORCPT ); Thu, 22 Aug 2019 13:09:05 -0400 Received: from sasha-vm.mshome.net (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ABA6123427; Thu, 22 Aug 2019 17:09:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566493744; bh=dmpAG+jXk1w4jDYTvVqCkRzkHJ94KtVhPWJc1JIVRwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZDN8NLVnWgPBSKRMs0yQWr3TSAKXCB/BruXsrQgeBEhit5QP3rr8Nl+gFub+DmQa tqFiN+CAvdN8Obe9CgDTDU/G0XZ1n9gnbc9iTKujIDBsytR1Ke1uENwKYjj6clAwwF ZTxeZdQCxdvpZDHOBagw/62xdhqrBEg7nhfsRqNI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ian Abbott , David Binderman , Greg Kroah-Hartman Subject: [PATCH 5.2 092/135] staging: comedi: dt3000: Fix signed integer overflow 'divider * base' Date: Thu, 22 Aug 2019 13:07:28 -0400 Message-Id: <20190822170811.13303-93-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190822170811.13303-1-sashal@kernel.org> References: <20190822170811.13303-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.10-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.2.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.2.10-rc1 X-KernelTest-Deadline: 2019-08-24T17:07+00:00 X-stable: review X-Patchwork-Hint: Ignore 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(-) diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index 2edf3ee913000..4ad176fc14ad1 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -368,7 +368,7 @@ static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec, } prescale = 15; - base = timer_base * (1 << prescale); + base = timer_base * (prescale + 1); divider = 65535; *nanosec = divider * base; return (prescale << 16) | (divider); -- 2.20.1