Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp557269pxj; Thu, 20 May 2021 16:10:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzPUu5LJ50MIYRqU1Hxmb/zkPmESagGz2ayt4vQ6X4WNFBoXBEbC+IkZ1NA9eYbBX6cl5+ X-Received: by 2002:aa7:c6cd:: with SMTP id b13mr7431805eds.94.1621552208060; Thu, 20 May 2021 16:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621552208; cv=none; d=google.com; s=arc-20160816; b=da4BXhAlymwbRHxUGoWA7bPDVsCyIfjFpVjq7E5YJ5MJN/BOLt5vqiGd1J6ezw+XB2 nITxlBPw3/SYDatk+zVIfCd0veE4MS69GKgm5RrTHN7vNDh2WuyRWzN4T+866khf1+aA Lz5VzWBKyncY25zFxo6LhA76Sx6dsAhiuR+xESVytZYsFv0M9Eh2wp/7Z+z20W+Ecw+s k3lo553WFu2VU9KRl9/N7BjLHYuM64Lm0kQV4GMriwQv7mBLUlOgaPN9M3QFhLRKZ1cY 9vJpBQ3zdLmty2zH43HWSDRL5Q4cbAKb6hf/zEBvuvSF3VKaogiux+JPy2aM3lwLvPbA aIqg== 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=6T8qsc41a0VPSrsITdkJJi/zP/KL9nnp4MKSePAQ/6s=; b=tjOHWTASQtcJUz1WPgrl5aml6oE/tKlK8hxlCEobZ5GeuGKA3FDqXe1CA79ngiHMW9 5zFuD6Jstx4xs5VnoM0ZMYl8zMBCD/NmMSZ0N8snEOCqOSYosKxSR0bhgCSUf14vaVCp L0nMy0EsgHR1iABJG+CqqijHTje00LIv0iWQ/4NrIz+ya7apxh4NMDXjGuPx3pAMTGIY f45Wiz5GKYfXN6qf8O7BzP4LMjm7Z8qdzVh4yahk05F1hnlTezBXBx7NJyuO2ZKCLVJx 6OYzeSLnKRg7J/1l33O0RHUEw3c8JhHMePGZNxtAElh13FGf+DT01s534duzUBPUySsV E5cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="0kUaliJ/"; 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 nb17si1579516ejc.226.2021.05.20.16.09.43; Thu, 20 May 2021 16:10:08 -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="0kUaliJ/"; 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 S240643AbhETLVO (ORCPT + 99 others); Thu, 20 May 2021 07:21:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:59128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238750AbhETLBC (ORCPT ); Thu, 20 May 2021 07:01:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6C0EC61D0A; Thu, 20 May 2021 10:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505011; bh=rZz1ZdBZL2WzTgvLe7/w0Oc3q815CYmWv5pnPMZ73co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0kUaliJ/TYB/G2PSU9f3G3kpqsQQVBozb9K5IVmM/xv18JFsXINY2FExepQTbBXzX 4wMRFc8/GpPeiAnXRwop5wEHlQCHX0LD440HG3EzPh8q7SvAlJi2ulL+ZD+l7oBiTD 0nehfWvq9/mzvRnkJ2nmSThTwvGBSvtp2Xsa/Zag= 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.9 149/240] net: thunderx: Fix unintentional sign extension issue Date: Thu, 20 May 2021 11:22:21 +0200 Message-Id: <20210520092113.653804196@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092108.587553970@linuxfoundation.org> References: <20210520092108.587553970@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 e701a25840360706fe4cf5de0015913ca19c274b ] The shifting of the u8 integers rq->caching by 26 bits to the left will be promoted to a 32 bit signed int and then sign-extended to a u64. In the event that rq->caching is greater than 0x1f then all then all the upper 32 bits of the u64 end up as also being set because of the int sign-extension. Fix this by casting the u8 values to a u64 before the 26 bit left shift. Addresses-Coverity: ("Unintended sign extension") Fixes: 4863dea3fab0 ("net: Adding support for Cavium ThunderX network controller") Signed-off-by: Colin Ian King Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c index 747ef0882976..8f3d544bec0c 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c @@ -537,7 +537,7 @@ static void nicvf_rcv_queue_config(struct nicvf *nic, struct queue_set *qs, mbx.rq.msg = NIC_MBOX_MSG_RQ_CFG; mbx.rq.qs_num = qs->vnic_id; mbx.rq.rq_num = qidx; - mbx.rq.cfg = (rq->caching << 26) | (rq->cq_qs << 19) | + mbx.rq.cfg = ((u64)rq->caching << 26) | (rq->cq_qs << 19) | (rq->cq_idx << 16) | (rq->cont_rbdr_qs << 9) | (rq->cont_qs_rbdr_idx << 8) | (rq->start_rbdr_qs << 1) | (rq->start_qs_rbdr_idx); -- 2.30.2