Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3712791pxv; Mon, 26 Jul 2021 10:02:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmOs1nIveZiEBZpKCK2BnzH8AWarLfZplZKO5GJNzxhCxLqT42QJ52IYYSv6hBOKr888TU X-Received: by 2002:a05:6214:1362:: with SMTP id c2mr14341136qvw.9.1627318926906; Mon, 26 Jul 2021 10:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627318926; cv=none; d=google.com; s=arc-20160816; b=uD8YOczIHb1JISQdqriCzJjNyau9amtWoY8PViwlwV+UX1jTwnwgozmWmYaCqQY4Ii yMAopk92+fzoOal4kL9BWLTeBZKLjPxyVRCnc+eQI3i4JIfU/cWNuUQMJbOZdZAFcIPV 0Gza54F0MyU3d8jsS88B/upi3wP1CEl/jafs63yffO4KmPxis3V61UU5sn+Ljc3nwSSf 1F0D5XLo0F91ALq1CkEyqPNaqnjGx6a7Q0hoMBKnumMGFLVkNuM1ZpCG8esDzUaizOG4 vUo5oo2GCw9+lsTt2rsraGSFEgVqayuAr6FWDOy3PxHlVlAJhNnqA2KvaSAGY4H0T0+0 n/ow== 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=A2X9WVTIh5fKbqQFGwytR0An1msBoZvipKsr19iflHQWxQNzeViM9de3LNs2wity6k +uwtV9z45P2pIboCTqHc4O9zl/1KbZD0iPVdCpBYNLUZBB81to5Jfu4qgci2XyR+38sp OFPmMMRBvNxmMZu/1twNspb6M44Z45bSnREkYsFrBLLiiDzVJ5WFCjMTnHEJNoZTfU2v rh86cHOMU6Yx3ba/HW2mAdLatNrofwMevbDVrDWJ4PMYbivZy1jSMqBoTG7PxuomzT31 Ci65fUbbkjWLB+7KsQN+d2EiEBay8U2WuARCl/AIyCTqUQdN3DNEX4EVPCOgN6UxNRYt zWzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZLmeV3UB; 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 i14si265539qvo.145.2021.07.26.10.01.34; Mon, 26 Jul 2021 10:02:06 -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=ZLmeV3UB; 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 S236678AbhGZPiM (ORCPT + 99 others); Mon, 26 Jul 2021 11:38:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:36352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237235AbhGZPVz (ORCPT ); Mon, 26 Jul 2021 11:21:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B21FC60240; Mon, 26 Jul 2021 16:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315344; bh=KQBIvWw5YEEKzswPulW/87FGiBPzOznHMPU68F6m9Ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZLmeV3UBy4221i2ji2DahWzQAZmDaVmMBBzmBAiRD5W1HbUhFSexTZlI74hlIpWUP SAUaCWTKJRCxgqtFWTkeVIBpbYTHBghQDvY0J/rIZr4vI7K7LQr2Uys5Eqy+rCbOnI 57dQ1bgyC2LtTItuqRzUZX+MLc+VVQUTqROp+D2Y= 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 059/167] liquidio: Fix unintentional sign extension issue on left shift of u16 Date: Mon, 26 Jul 2021 17:38:12 +0200 Message-Id: <20210726153841.392261805@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153839.371771838@linuxfoundation.org> References: <20210726153839.371771838@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