Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3672407pxv; Mon, 26 Jul 2021 09:07:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwO11s1wIc8Y3i6yrkHIOWe96+TgdkzYCR56ViFHPQZb/vcmYOWZFsYxiUbQlNmmN4IV62 X-Received: by 2002:a92:b741:: with SMTP id c1mr13820239ilm.220.1627315672794; Mon, 26 Jul 2021 09:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315672; cv=none; d=google.com; s=arc-20160816; b=ale9a1crRxoHcpUQEGGG1YWp4kb74I2XLMk/BXbTquOySoNW8hMYqYA/eHeHRdZQGb clZ5XXviFTcNcUDqt01Ldqdh3L4gBJlCskChGHgqxbMiIH6GxAp7841HXSKqLRg2Svnd qYNH8xqRDTcXxqR/RJXNM55VYbM/dri9MqZkmLZ0BaasmCpEG43JcFTQrheOPhW+YxQY a9Wu9XMadLIuWRMnQwJYZ/5DtnAmyshsM6cgz9wo0iULAjkmmhvGT7JurF5ZFah2jZEv 6eHFZKV/gsB//l5BJC8XjztdDTS6dn+qTHlKaFVJWZDohGvNKJKkfbMv4OEJfsbmLj3B Dh/w== 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=KAcw5nt151s2CKcxRlE9G6guDMV6CdRpcEqzQFMiv8k=; b=xX8kytTddtu/E+fn2tHqUaq1Jrpj+Sxsf+IVB2QTHqS5UXIr5gdqk+qV+4bliZQUvH PYN9c4h9CIn7ke/KMlHCK8gsKhVrq2wV7bu0r2/x9wrGLKQeC+B3VrMCbMcGaMLGH3By QoF0NTAvNufjP8IUitWthPSlozF9VdhEo4UuMECHfaHtIibyUG5TMTtiHaWVk3Z9ejBU d5000WzM7SttoCTt6D6sKI2AVokKGlw8WICt7odXTokQpYYpqyZoWcmcR+HGnmWp+DOP bLMmenH/EiQrfBD/EtM2clnD9LGwb6v3h7Sk0ILRvzNVHXYxPPO2KezL42HAqPJsY58d SgWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=woXBJvyM; 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 y12si279608ilq.107.2021.07.26.09.07.40; Mon, 26 Jul 2021 09:07:52 -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=woXBJvyM; 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 S237482AbhGZPXJ (ORCPT + 99 others); Mon, 26 Jul 2021 11:23:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:52932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237450AbhGZPPr (ORCPT ); Mon, 26 Jul 2021 11:15:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E8409610CB; Mon, 26 Jul 2021 15:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314967; bh=KQBIvWw5YEEKzswPulW/87FGiBPzOznHMPU68F6m9Ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=woXBJvyMfpsnSG/jixYVdNUIqX5Lz710/elJoHUh3/C2o9kNJNwmUWzo9Et+3RdL4 VrQphIGmqIcbWyWM6IE3Xk91P78Ps/IxePcf8LbL5i9LzG2CO6otHlBQuL20Qtx+e0 MfjEpPY3HsbyHGUov7pxEnxPzqu0rnxrGD8or7rY= 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.4 037/108] liquidio: Fix unintentional sign extension issue on left shift of u16 Date: Mon, 26 Jul 2021 17:38:38 +0200 Message-Id: <20210726153832.884665464@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@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 e7efc2ce3d0789cd7c21b70ff00cd7838d382639 ] Shifting the u16 integer oct->pcie_port by CN23XX_PKT_INPUT_CTL_MAC_NUM_POS (29) bits will be promoted to a 32 bit signed int and then sign-extended to a u64. In the cases where oct->pcie_port where bit 2 is set (e.g. 3..7) the shifted value will be sign extended and the top 32 bits of the result will be set. Fix this by casting the u16 values to a u64 before the 29 bit left shift. Addresses-Coverity: ("Unintended sign extension") Fixes: 3451b97cce2d ("liquidio: CN23XX register setup") Signed-off-by: Colin Ian King Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c index 4cddd628d41b..9ed3d1ab2ca5 100644 --- a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c +++ b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c @@ -420,7 +420,7 @@ static int cn23xx_pf_setup_global_input_regs(struct octeon_device *oct) * bits 32:47 indicate the PVF num. */ for (q_no = 0; q_no < ern; q_no++) { - reg_val = oct->pcie_port << CN23XX_PKT_INPUT_CTL_MAC_NUM_POS; + reg_val = (u64)oct->pcie_port << CN23XX_PKT_INPUT_CTL_MAC_NUM_POS; /* for VF assigned queues. */ if (q_no < oct->sriov_info.pf_srn) { -- 2.30.2