Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4628387pxj; Wed, 12 May 2021 09:34:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+SPiNPlH7IBszugTDgyWe2O3YABQ3VNrfalTS9LsB7a72HiI0I+OyfR1/9yOllbm4nw+K X-Received: by 2002:aa7:c390:: with SMTP id k16mr40849782edq.97.1620837242724; Wed, 12 May 2021 09:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837242; cv=none; d=google.com; s=arc-20160816; b=CfhPoFeiuDTDisbxkmqHzO9m1fguAtscJDtqSdNV8svHIXLlNdTpj1mgpY3e7BMU6I D1WX1dTbSOtrDo1RJK7w2YW9lnHY5nwrFellqEFXF9rY7bfbHpy/OE+oh1Zx1FM+FNxH 7g1eRDfNdw4/p9EgpfSrk7Kv4YRkES+PimFS8DUaf97AkwjbHo2E2FEDKRL8ZQykQlBZ nc50i3AEBnfcV8oGTI0OqtlkqRY2QXbNcCz42vqGaXRAGdlGbCclnw3lMoz0JnDHWsDQ sNYxajg1qa9+rOrWFHJIqTp6mJo1MX5co+/XJgOu4q4W5pXVMJxGvNTIHocX8WgOhA5M 5ejQ== 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=P7+uOF4NETdXm/D4G1ho6eaSv/MSGWt4038KgVBLCxU=; b=FeeV9IFgq1ifCycXmdhAmH4HnYudrsJrDLc2SvKhuCGZemBeFD5XUO5NH56rJ/JIjf lphar+1fEg2tgp/lmMWSEhE34QYIHwjOdiM2HLrBJpMgQVy8NV7GsZUlAqCZ2DrWdpUX mD8CQAburkdcmX8BjM7Y4FcGbQAE4WYK7cIpRNEeoUykD8LmJM4KadConrcabmt8ay4B 0o9/bCXGpyepl0iVACg9ZiWIXFiZhStdKucEtXx64qnoCaoga/kDxeQXxL+lvNwqkZOb mE1D3YtnN01eApapN2e4g6ktnxNNXIMl7rYFq17kY/PKML159ix1SVpHCwAL4VLtnXl/ ktCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wro5u94A; 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 t12si359907eje.621.2021.05.12.09.33.38; Wed, 12 May 2021 09:34:02 -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=wro5u94A; 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 S241420AbhELQ1J (ORCPT + 99 others); Wed, 12 May 2021 12:27:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:56528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236458AbhELPh7 (ORCPT ); Wed, 12 May 2021 11:37:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7E11661C69; Wed, 12 May 2021 15:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832793; bh=j1j8JL/bNXI0g6v0uAf05DOPgLESTmU6ootudLeUBM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wro5u94AUZ3M4PS8AVsuzP8rUzxJR68c2xwarFpPYJ3wo+nCfjo9qhqiDGtfSHjcf uLvCzwDfD1VfkH8cMGWB3MMkvHd5Yz67ds/I5/+ghtv6AJIqd96HxHxfkoR9DNEaI5 qOD43I9p137Jz99eOiiiEttAKjVm58ueYV9UHDPU= 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 425/530] net: thunderx: Fix unintentional sign extension issue Date: Wed, 12 May 2021 16:48:55 +0200 Message-Id: <20210512144833.740295027@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 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 7a141ce32e86..0ccd5b40ef5c 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c @@ -776,7 +776,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