Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp632464pxj; Thu, 20 May 2021 18:28:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+lyjemTf0eOzU4l+a2Gps9g6kFSMgaA0IVRtWrnNKXAFE9RLl2UJAuJIEIFoBGfOF2ECp X-Received: by 2002:a92:cc41:: with SMTP id t1mr8308403ilq.308.1621560537444; Thu, 20 May 2021 18:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621560537; cv=none; d=google.com; s=arc-20160816; b=GFgiGUqDruC8m0lcG4dBmg98Z3A81rN4U64NT02APGp4zOFwKcrPlkc7kimzOBIZ8b jcXYLgjNwcRzUNn34Q/G+66Q3dsCnsp/wFeoZgDMqnEwmrNUtVhEGOLuLUfP6cgD++z8 fxgQwn61MYgpNNlkvO/aLZj2PGHtwB+XT/DmLFza0P2ruvUoNOktl1Pa+PnSwOv750Vo Bna+mhBDSkZfevcGjEwjcnLoC6K+WEIR8EECuNGEOqcl1W9xdl1oaYyZAap32ileB49J RxM3uJMvX9VDXpGoXn7AgkPikF9RUYpKRgtEVQfXV80x/9sgQiN0ryyP6fsikMbkDuHS yRDQ== 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=1/gzp3w+2ZMNsSssUg7Hgi8Q4lOxVOWzqSwNnbQLcF0=; b=fxmAuWNZq3Bu7prnvNeZDnO3nR5udZb2FukIXZGyYofBoWAO9Fq2U1bZE6AfHYZPuC flttegevSv4jqnbBOtJmyc+jkZyDfM521Om/D2FRaHS4PVI78uFi4jiNC7+r/dib90io qIy6IaM47JnGk3huj3VbFP2nqL0LCGbMbci0UYA5L7GNpqQwMY5renA0cftXX17Nmscf jFeDfusNw3ZCd8107SAI/5QtGH2knp6VaFhBuvldR3ZRZ1OO+yWgePM2mVpHHW5CtFqH Lyj0ehDMMo1tm1kCcBCtJB/OoN+wIWQ72HPZNzjSBQLycI1dMNGgsgSgmD0sMwYhBMTW gVPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="a/PKqK/j"; 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 g15si3994785iln.71.2021.05.20.18.28.42; Thu, 20 May 2021 18:28:57 -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="a/PKqK/j"; 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 S240744AbhETLiX (ORCPT + 99 others); Thu, 20 May 2021 07:38:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:41388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239892AbhETLSh (ORCPT ); Thu, 20 May 2021 07:18:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C24D061D68; Thu, 20 May 2021 10:10:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505404; bh=bd/IiSAISo3nwrzhhxeSQkssRhl/I2sVGI1sSQ7DCpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a/PKqK/jXuqVPPgsJDVRGC4o5Wm956oZL4c9mFlRHSg3xye4cNTGjrwFe3wCXCymJ Tr/0cVEoxpQIDZCmgHG8iPNAGc/iGyAhBvT/cUTmRxCrHwcgKv3cJ3i+0FL8yjgwsG FtrHDeaB75oD3imkFl4iMvxybXT6hJ+hCBNT4J/I= 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.4 120/190] net: thunderx: Fix unintentional sign extension issue Date: Thu, 20 May 2021 11:23:04 +0200 Message-Id: <20210520092106.173671489@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 912ee28ab58b..5da49e8b533b 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c @@ -528,7 +528,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