Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp456887pxj; Thu, 20 May 2021 13:23:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7xxhqUbdVX4bxp5EGrarZPZiutMK5ua9xkzZzYeT9AJPPAcfL8HdTxIR8cmcMy+X2KPSo X-Received: by 2002:a6b:f815:: with SMTP id o21mr6627558ioh.0.1621542210061; Thu, 20 May 2021 13:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621542210; cv=none; d=google.com; s=arc-20160816; b=X5kOGpZP8+VuZa0igX3xMe4TQmMHdeZosbkoNZ7B9FJR96g9SIjmqPtaVk7I2mqIq9 T1fvfV3BBx4Y7gRuyl2fRED0S58afZi8XfWWOIETxzYf1RunK8WzTUpJhTROmI+e+Ue+ mm9os6VjNrvfI3YV+Cnm/RRDniWizHqsXUSc2q+lWOlLiDuLl3A99pukD5OcmbJ48O/i Sks3CgCyS8Idg4XdTd8YrXUotqDnhIsVAWQMkCvTlueghD0oLAtPLc6vEAGfNIhPETD4 lUwyAJqE5h+9dNI9icwwC/Z/s6rgR7cGeEkkx6Cgr4dZ6lCJEYzZlMstl00chRVp3Ln5 OZCg== 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=l3pOazbeIJPOrj666NWkxGtslnM+hV2EZeCURt6/AU8=; b=aElFUVfKCB7ojORWE6EsJDPO45c0WrZPwDck89LVdeZL5cU/Zuxl/Bj6fZfbhtt6yU 2IqJF9YD8+JQAI8zt2ZfacWb6T3l4Itm/GOKxdpk5O67AGcQEwgT+CDV1tOJBcH8G7eU SmQ/qt3MSrffYr1pgC7ZLgFikShaW5mY8FAV5CrBEgWOn8ePjCwarCY//+2KONYzLQS3 hcMPb7/cyqiTW4XmcmuYTUkmEc3eH+W7ZOxppxksHDt/+wo/i3ChlNHaDF67/4xQ6EDG jnTJS/hRTxvXqmkDDkWShh4E6zo1SdkZbwGwWzQe3HBHbvtOaDnkIq5nfcsuEjg3RvnW xH8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BryJXmQq; 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 j6si3473667ilu.44.2021.05.20.13.23.15; Thu, 20 May 2021 13:23:30 -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=BryJXmQq; 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 S238415AbhETKvg (ORCPT + 99 others); Thu, 20 May 2021 06:51:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:39858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237830AbhETKfl (ORCPT ); Thu, 20 May 2021 06:35:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3BC5961403; Thu, 20 May 2021 09:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504435; bh=7IflujBnkgUsmWPYmn9b0eAFUiRYqtEistH+wt4Pl7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BryJXmQq1COMTQc2sF7XkaNYb4LlzkhRq2rS3+1+cWE8qgjWVWEX1nbH3fjxIcYn1 Z6haHCLFLZ+5M9cfZVFJC8jJWlAES+EZb3W5K4jhxQvOP9bCAeF8etqDdZhng7c2gr 64dg3Uly1O65Qoy+dNoXTzhvNtuW7yC3cRrrw5c8= 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.14 210/323] net: thunderx: Fix unintentional sign extension issue Date: Thu, 20 May 2021 11:21:42 +0200 Message-Id: <20210520092127.320382148@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 7ad1d56d8389..d44d9d0e9d06 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c @@ -775,7 +775,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