From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4210BC43381 for ; Mon, 25 Feb 2019 21:59:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F30C52146F for ; Mon, 25 Feb 2019 21:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551131972; bh=FGp/CED7qHMomc/0yNRnZdZHhQxhJ6B9BtQBTfNzZ/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ukcfPRtYu9FM5rLWenPO4YEK86lbo6prDclpjNLCS+eoGKELKFsVR1m5qaoLYD9UH lMHDO8tn6NGFsOh0w1bNEsj8nq7+4n8eMDX80PmrN0pR+FCbt7pUSzy4QhMqX9jXCV qp5coOBOLPTi/+0LkiLkkcCPOWVpHoeYLn3acs8c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730194AbfBYV7a (ORCPT ); Mon, 25 Feb 2019 16:59:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:51952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730245AbfBYVTG (ORCPT ); Mon, 25 Feb 2019 16:19:06 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 4463B205C9; Mon, 25 Feb 2019 21:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551129545; bh=FGp/CED7qHMomc/0yNRnZdZHhQxhJ6B9BtQBTfNzZ/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NvyWRo/YCqTu6gvJ0sayUR66UiFWcKugxkwKR6WZaTyOMF9QsZDoM5XGphfxsYXAJ ijF1k0QPggyJoKOFOG+Mzn644QYrzv0A/ccSZZcfdmGkdkkhoAWHB7Bs9bvBRu7HRQ ehAkX3BqFwzPF1credhhFDKoGW6bEG3MBJt+JMo4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 38/71] atm: he: fix sign-extension overflow on large shift Date: Mon, 25 Feb 2019 22:11:40 +0100 Message-Id: <20190225195037.396837224@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190225195034.555044862@linuxfoundation.org> References: <20190225195034.555044862@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit cb12d72b27a6f41325ae23a11033cf5fedfa1b97 ] Shifting the 1 by exp by an int can lead to sign-extension overlow when exp is 31 since 1 is an signed int and sign-extending this result to an unsigned long long will set the upper 32 bits. Fix this by shifting an unsigned long. Detected by cppcheck: (warning) Shifting signed 32-bit value by 31 bits is undefined behaviour Signed-off-by: Colin Ian King Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/atm/he.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/atm/he.c b/drivers/atm/he.c index e58538c293777..7ba243691004e 100644 --- a/drivers/atm/he.c +++ b/drivers/atm/he.c @@ -717,7 +717,7 @@ static int he_init_cs_block_rcm(struct he_dev *he_dev) instead of '/ 512', use '>> 9' to prevent a call to divdu3 on x86 platforms */ - rate_cps = (unsigned long long) (1 << exp) * (man + 512) >> 9; + rate_cps = (unsigned long long) (1UL << exp) * (man + 512) >> 9; if (rate_cps < 10) rate_cps = 10; /* 2.2.1 minimum payload rate is 10 cps */ -- 2.19.1