Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp839699pxu; Mon, 23 Nov 2020 05:36:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxM9ym6oB2Ulo9QJpwwi8PZt5hQzL/kmXx/Db5633xI0ZfD+qy8x2QlVlVND+cth0NI26SG X-Received: by 2002:a50:f1d2:: with SMTP id y18mr13223355edl.166.1606138601301; Mon, 23 Nov 2020 05:36:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606138601; cv=none; d=google.com; s=arc-20160816; b=K+AVvZK2PyBB/W/dW/iDHd8u9QqLWBFBCYoc4JN8ndVPOjqoGFFLbSLzXCxXO3l22y K9m3tGPIozumpxuVDkfYkGqGD2k9IYbMqnXGXu2C2zpNy4lvjzlPhN3Ky25c8s/VdIw6 k7Jvhs5jBYEdwa5diC0fbM7sk7a/NKARN5q8vN8kLVap9jdiBGFS5r9XrKiawU+guFwL lW33ulNrZ0LdQ3eHVx8zwRNtWPnlh7rwB64b1+6C7Ji+fYGsXNswXMq6YiZ1fVwv5acV 5B8x+ETDOzuCrkgar4gM825YJF2CHS9oyRzQL8Iqj5WvNMl5igUdlyVtcX++KlG8W8ER L76Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/wPoBMumKGpl5R2G0Spdfdv/mhFHxHHYGpgNCHUqlKI=; b=rlZwT0N6MrvKcJTZRw2pPZYEWuMYQwIOVbXqi5+efV2j59fw0rMGpUz0HWEF7Fko/A Wa6S7YUyJ+1gLrKr3gj0eALA4M2/uDFd1k5uZfS4Mn/WAr9GGena2CQqkqXaJ97jwtA8 Z9UhPu/4wYw5FzDPciUlWDYboLU9igVw2AiFNQetKJO1Qs9pRHCvc8GH+xaoAviZab7y J6AlqgagfQLDdCJXq8kwQrccrow8oZdqAZcNlAuJkoF+Vtocu7GPhgr3CoYI4M2ggy8Z 1HjK8H36kKjwLc6XUngf7Fjk5cFHU5ZHtoXbyeUCTcoqpO6UpyhwlLBpgMPbGfa4/xRr boMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mH9Kct5a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si3678474edp.385.2020.11.23.05.36.17; Mon, 23 Nov 2020 05:36:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mH9Kct5a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389386AbgKWNcN (ORCPT + 99 others); Mon, 23 Nov 2020 08:32:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:36672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730179AbgKWM0l (ORCPT ); Mon, 23 Nov 2020 07:26:41 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 8EB9A2076E; Mon, 23 Nov 2020 12:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134401; bh=6Dcwo4OSCRn0tLFb05dYVmqq8EyU5c8u391HU+6KyMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mH9Kct5aw+A1bedmJFTvxD0kHwq+vrs31VPxmm1yFQvJFb9DEG3jz6rptJQguejmq b+FPULyZnDAHiFG3IDe9nIg7IYFgi3QHZbrBb8G3s1Lc2riNpG4pkmVc+DANdMzQ1F VoZ0DAPsZKc0C1GcLtAKB7TotHLl50ApUEUNGn1Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 4.9 28/47] can: peak_usb: fix potential integer overflow on shift of a int Date: Mon, 23 Nov 2020 13:22:14 +0100 Message-Id: <20201123121806.909374940@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121805.530891002@linuxfoundation.org> References: <20201123121805.530891002@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 8a68cc0d690c9e5730d676b764c6f059343b842c ] The left shift of int 32 bit integer constant 1 is evaluated using 32 bit arithmetic and then assigned to a signed 64 bit variable. In the case where time_ref->adapter->ts_used_bits is 32 or more this can lead to an oveflow. Avoid this by shifting using the BIT_ULL macro instead. Fixes: bb4785551f64 ("can: usb: PEAK-System Technik USB adapters driver core") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20201105112427.40688-1-colin.king@canonical.com Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/usb/peak_usb/pcan_usb_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c index 74b37309efab7..2e316228aa1e8 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c @@ -178,7 +178,7 @@ void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts, if (time_ref->ts_dev_1 < time_ref->ts_dev_2) { /* case when event time (tsw) wraps */ if (ts < time_ref->ts_dev_1) - delta_ts = 1 << time_ref->adapter->ts_used_bits; + delta_ts = BIT_ULL(time_ref->adapter->ts_used_bits); /* Otherwise, sync time counter (ts_dev_2) has wrapped: * handle case when event time (tsn) hasn't. @@ -190,7 +190,7 @@ void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts, * tsn ts */ } else if (time_ref->ts_dev_1 < ts) { - delta_ts = -(1 << time_ref->adapter->ts_used_bits); + delta_ts = -BIT_ULL(time_ref->adapter->ts_used_bits); } /* add delay between last sync and event timestamps */ -- 2.27.0