Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4630185pxj; Wed, 12 May 2021 09:36:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznGdMrNiIdPW1xlWAo25CD072bmBY3Of4wv+UHiEhTOtqmaydJRrKXhSYQcetqVbBSjnUV X-Received: by 2002:a17:906:414d:: with SMTP id l13mr38255737ejk.527.1620837389149; Wed, 12 May 2021 09:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837389; cv=none; d=google.com; s=arc-20160816; b=oy/+EnaTPWf0mylRbwj9iGXxj3CICGBut76X3JYLu+q2I6MV7j0EjvVO3bSZ40Fg0Q qSqiXXzstkW/2F0CYz8xfdfQYpZ3mCYfQtvntZy+cjXLuIJMaiPnch86ibMMsEwS4rNp TJWsyhUgO/xDFZBSxffNvB1NTwqAu3sTdflkXN5iNqRovpZ7pFJ0SV8iL4yfiADhHD2Q SZM2YqohBr1PygK5Xe+mEfLwjzYFHtuVXGtaz5ua0qg5Vsl2ph6CE9OjYvluvcBDOkjd ENgRLpGLdxW8T1JzW0zntyIIQfPpVB2wxgutrvUKotOMo8ijoaEX4lptrnpu94Y1LTyD XRVQ== 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=7Hn+CNA/od2iiWvjV0g5aEQaFXL+eY+gs+CBeivDkzk=; b=orTSkksiiI7CyALoHwWutwBwwZ4gi3viYf6u4MQV0LR/qtZvm5Tze88XyCv2+RY/aL FNyqfEJrbw0ao1eohb8xAJmuFpF5jcSc5Ibaw7KGpZlnsiL1STpaWiLpgOufLy56ZeKR dU5RQ+MniUL7eAoEVREOt3RF1xVVqMXz5h280fIqjtwZEMXk3uWUoswuZ8z78vvA9mDL w3ksy/m68647keNqa4B5I4OA/J90Y8tjkgta93KnCpZLVla5pFVlew4iCTd0mKWGY7YD iGI86m7zxunRon2ZMLGH+ThTN2aM0+tgZG+lNYc7/EneGAy2rmLYY6kxKJ/YjsovIi37 Idkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="qwLqcU/h"; 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 y18si233606ejp.276.2021.05.12.09.36.04; Wed, 12 May 2021 09:36:29 -0700 (PDT) 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="qwLqcU/h"; 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 S238700AbhELQYt (ORCPT + 99 others); Wed, 12 May 2021 12:24:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:57182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236255AbhELPhZ (ORCPT ); Wed, 12 May 2021 11:37:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EFB6861C57; Wed, 12 May 2021 15:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832739; bh=uidAe+Es+/+PmreWX+fJb2EbtdDpLV3OhFvWEUt83cY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qwLqcU/hq8z/g34BX2TOzCnkjTjy97RIW98vM9K5u637qnaa7fUPEOuHMyUpTNV2t IhYi99AdkinaIaPIt/GHhr7WHszNpvXDlN1QszY20eKi3UvyiS62UMZLi2FG7uiPpP Www/1jwUwJ910Y7R3ud0VsRz1WYSBzLeqvGf+R20= 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 5.10 402/530] liquidio: Fix unintented sign extension of a left shift of a u16 Date: Wed, 12 May 2021 16:48:32 +0200 Message-Id: <20210512144832.976707409@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 298b58f00c0f86868ea717426beb5c1198772f81 ] The macro CN23XX_PEM_BAR1_INDEX_REG is being used to shift oct->pcie_port (a u16) left 24 places. There are two subtle issues here, first the shift gets promoted to an signed int and then sign extended to a u64. If oct->pcie_port is 0x80 or more then the upper bits get sign extended to 1. Secondly shfiting a u16 24 bits will lead to an overflow so it needs to be cast to a u64 for all the bits to not overflow. It is entirely possible that the u16 port value is never large enough for this to fail, but it is useful to fix unintended overflows such as this. Fix this by casting the port parameter to the macro to a u64 before the shift. Addresses-Coverity: ("Unintended sign extension") Fixes: 5bc67f587ba7 ("liquidio: CN23XX register definitions") Signed-off-by: Colin Ian King Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h index e6d4ad99cc38..3f1c189646f4 100644 --- a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h +++ b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h @@ -521,7 +521,7 @@ #define CN23XX_BAR1_INDEX_OFFSET 3 #define CN23XX_PEM_BAR1_INDEX_REG(port, idx) \ - (CN23XX_PEM_BAR1_INDEX_START + ((port) << CN23XX_PEM_OFFSET) + \ + (CN23XX_PEM_BAR1_INDEX_START + (((u64)port) << CN23XX_PEM_OFFSET) + \ ((idx) << CN23XX_BAR1_INDEX_OFFSET)) /*############################ DPI #########################*/ -- 2.30.2