Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1327392pxu; Mon, 23 Nov 2020 18:41:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzV47UBAINFxcRyFqYUGLj6Z6Tp5uJx8VYgetdk27KK2Sq/mZv8T8RrLYTa0WJuWid0WD+p X-Received: by 2002:a17:906:1e84:: with SMTP id e4mr2308899ejj.57.1606185694757; Mon, 23 Nov 2020 18:41:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606185694; cv=none; d=google.com; s=arc-20160816; b=BqzkfdA5i4SloJdFQZQ6fpBI95A40D+SA9KJDkBkAjjL7PBuzWWe+AD6+l+t+J0vhk 8sSZdYRDTgPFbcPhLpifh9fzWFfMxMDW7YohDI3BI5YFfTYtPPJWSjwUuGP7s7lqXtIz d4YOED9bWAZ1ZKzwoDdcIUMBs7dGrjY0+6RySXHwsdVX5CiqZxIgl17+JSnpZA01hjXg QgpPNZM0ioSngJI0zjQq9ovYTlaac5ZiPVcLRmlezZ07GkYDiK7nqcO1GBi1OimJCdkC D7IQDA0e+Kw9TsYsrMvSCaoAOaqjeB9lg8t+a9BJo+R4WS4D/K/lLCUq2usTxfqn1WwT zReA== 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=psa4VucjEGyvZUijbYOO1Wv3B1Ug0FPUzowoUHMnC/Q=; b=0l/8cQFVqAWdvM2DnhXB9xE7ZSmOS+aox6asHYR1GIRKv/XrBIIOaGMTalvH+hcToR JnY4hcKkSPqH6vG2hdwhkUcjUQGCNes++aHLw8CpI30LdiqAAi7bpxZVhfLUfOQY6k8t 7ZkBKVMXGUzrautZ2tGlKigm5dYbRJADYXDMPwy+Kbfi7F2+bSqdAFgIO3Hh8eHMj/ON lzq4kbx+pTJfNdRYTNOxeG7V8j5kl+TdVCNzmykyvMVC/3xh1zOcuHJZhPSaVKFRWgjd Yk7Ceh/B1fgQTvl9Pi6gjqaW1CpYK7NMaj7At1nJ4Cu/kcC3uZfZpBD+HQNxoHu9/csY w79Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JAeJOprI; 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 r1si7790994ejh.137.2020.11.23.18.41.12; Mon, 23 Nov 2020 18:41:34 -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=JAeJOprI; 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 S2387676AbgKWMv7 (ORCPT + 99 others); Mon, 23 Nov 2020 07:51:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:60774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732795AbgKWMrB (ORCPT ); Mon, 23 Nov 2020 07:47:01 -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 7219C20732; Mon, 23 Nov 2020 12:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135621; bh=oG3NrPNOgJal3AFiR6gofdzlvirfWkPYKsf4dt6fgWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JAeJOprIqIQBvqGr7nCegf86YYRPAuNCKpTSQHtE/Ic4fMkHmv8p5rMrxfX/AWUEu vFwhClVaWdcgEjvryc9TCGf95GnOl/th/UBmKYC7WI5AJeNYCifVmXuvatKxwh5D0Z Qjwx8ogXqMQ8eW5SiSJS4FhMeFlLoEcEBmV2auwU= 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 5.9 134/252] can: peak_usb: fix potential integer overflow on shift of a int Date: Mon, 23 Nov 2020 13:21:24 +0100 Message-Id: <20201123121842.063435898@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121835.580259631@linuxfoundation.org> References: <20201123121835.580259631@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 c2764799f9efb..204ccb27d6d9a 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c @@ -156,7 +156,7 @@ void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *time) 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. @@ -168,7 +168,7 @@ void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *time) * 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