Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp455876pxj; Thu, 20 May 2021 13:22:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR1ShqQZTzas6i44kjZ3p9WmwgdXJFhd6WmxpJh0G9JYFcDKBsrqHTPV9/bWfxhrIFTX4Z X-Received: by 2002:a92:d34a:: with SMTP id a10mr6313012ilh.123.1621542123429; Thu, 20 May 2021 13:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621542123; cv=none; d=google.com; s=arc-20160816; b=KOHejZDAigb2ejYdtwU8Q2bviYskNfFVUA7tEoaoqZSC3xepyMmLXlQ+qd2SfeGO2N KX+85Aegs1PSA/0fnXgnbEatySJh1uBuC9MW78Lk2HZInGXUfk1/wfsaUp2wgBp9vCJI Nf0auDj/Dv7HKmKELytZMkPErL0zqkmsNzG5xFyAAjpzPBRBN7fRpEZjXI6EtDmOZOar mNFWksVna7ZQZFB7Bk2Ql3c8IroSi4hRr/LnoU0zSsFguM3FxWrOWuE1jcySZrTqHqAj nU/65tZsLvr6+8CxzoDmEgitdy76QAM0KYJI6hpwBbys1EBubGi4tj6CNUgreHXrABSl vWMw== 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=JiCT9HgzHHGfJHs0ZW8ew+N307Eqgae9koNlxv04TZmi3mn7QjJl6UPwku7CSK/uis 2Q0yj9hEYOg7zvi6jSrQi0xuMXPJyVrMW4w0M6PpJT46dR8SVwkcL6DcgkuyV8XkU2vQ FzPS5QNQ1JQkeKXCxPPv1Vhe7DOUVTQMdgUvaErPu4wyEMqyW89I2W1GhnBtvIHqG1e3 56/Hw9lsjMI+srRahdQnBYT11V2R5ltmBwWjvxfctSqXS0geE+mkrOshLks9dFYzVQJB hrhn0ACeNAoYaWwaDYvBxXGzi8ei5kqSuLghZlO1gTpD+NFf++894W9hjUrEmXA0qYE8 5/lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="W0bRR/Io"; 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 a23si3179652jap.18.2021.05.20.13.21.48; Thu, 20 May 2021 13:22:03 -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="W0bRR/Io"; 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 S238928AbhETKuj (ORCPT + 99 others); Thu, 20 May 2021 06:50:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:39656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237689AbhETKfT (ORCPT ); Thu, 20 May 2021 06:35:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AA60461601; Thu, 20 May 2021 09:53:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504407; bh=uidAe+Es+/+PmreWX+fJb2EbtdDpLV3OhFvWEUt83cY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W0bRR/IopTo6dDZm3Nw/QAITAsj3JLIC7UuU+tI3sktZvhTj6rqVMDQxk6J41Nj4N Hmr9obqgs8VHMmBIzZVrheXNjMCWxoa/ZP3C7z/UFktAiTETXi7smhZbuixRiXE3H2 DhzjaRQXc20B8aVqz+3ACEoAxyMXGzPOgHG29sLI= 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 204/323] liquidio: Fix unintented sign extension of a left shift of a u16 Date: Thu, 20 May 2021 11:21:36 +0200 Message-Id: <20210520092127.123009570@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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