Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp3393961lkq; Mon, 23 Nov 2020 04:42:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLb35OM/dI3SgPnFhywfqINc/9sJ0Qu7nVQQbWmkwDWL58jjf9d+U7ISLffQYCiVHsSan/ X-Received: by 2002:a17:906:114b:: with SMTP id i11mr42271681eja.106.1606135350790; Mon, 23 Nov 2020 04:42:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606135350; cv=none; d=google.com; s=arc-20160816; b=oW+aLW9ecFTxFkEjOSDtozooECKuDJKGNNaaeSp6s/gLwS6TQ5NG+f7lgaQUbsWEBc fRsFMaTSI7yutj9DR+imz1JxkKTtV971IDQRfN0Aemcc2xnaSRkhjmemnI4ULC3x5YM7 hv814+VV9qp9hmx/V9z7PBcEbEgfue7Gk/r8fL3irImD6o9/Ez6u05rJm/6OMALL+Bay 5Jo6t7z6ELdbPgOQzYMqf2B6e84xbnFh1O4FqCknnxTHjQrusQAZVuKdXz9HDlJmGrc1 l6IqgySEza6I0obvjwsVG19bdFVhS27guP7ofw6idrjqwXr6CTrM6+SBwhBvD4fKbmb0 ydow== 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=pUvDxHFx/Pdw/WeITC41Wm9CXOjnsEw9+eFFWnn2rbM=; b=0vXiG7efa+BWu20ibyuI4cZKA4iHhFKQprg5VCl5uCd6ivuus5uXWzak5/DfJcgEdg 8znyObf/Rk2vWMXqvujddphcZ0Ofyy6E+hkHF1NzRvWp9jxxKz5wLw/fnQwiL01qcdtX DWfDGoBAkJ91kvyjuojXS5dSF0RZyhGXbxslymjH8yEM1v5//vHkSrb2B7NsaL2TxNhE Eaov4FR+l7Y6YQ2q65KJQeosNEkswaKB/bNxvA81XEXFh8FokcBGFQcNlC4Wr9++txHr kJdiqOX6kGuH+/VteMRAYsBnv/jLsGR/kejQZGdR6Cgw5Yw3kRmd9gZ4wweSknsDDGGZ 2ESA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=duMgYQxe; 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 o10si6458809edv.480.2020.11.23.04.42.07; Mon, 23 Nov 2020 04:42:30 -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=duMgYQxe; 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 S1731910AbgKWMhS (ORCPT + 99 others); Mon, 23 Nov 2020 07:37:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:49486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731890AbgKWMhP (ORCPT ); Mon, 23 Nov 2020 07:37:15 -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 6F1D0208C3; Mon, 23 Nov 2020 12:37:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135034; bh=U3fYj2vHn0MagQMrtVBvn8uHOh9WjHxdDBl7aVj5zKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=duMgYQxerpNk1PzwKW15MmHm0KlktBGYh3/R3riW9aK1z30mqVsKYOwWlnPe3Tzhd Ks0euSUe9tDM4xfMUmi3AAKzdbUSrF9mxn4xwudk1qcCJS4PwSc0avXWo9Ug+uWuj2 0rE7nkUtO3HE8Ik3SjFYbsvu1kXrtoBecwj85FLE= 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.4 080/158] can: peak_usb: fix potential integer overflow on shift of a int Date: Mon, 23 Nov 2020 13:21:48 +0100 Message-Id: <20201123121823.798746832@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@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 c844c6abe5fcd..f22089101cdda 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