Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp346845pxj; Thu, 20 May 2021 10:39:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1/aPmZcWlaeFOWlLC8ix6IVYMcKKeBl47ir/Z2jeVPvBjG3mSIlT2L8o+hIe5lMkOoIWk X-Received: by 2002:a05:6402:337:: with SMTP id q23mr6112699edw.215.1621532346516; Thu, 20 May 2021 10:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621532346; cv=none; d=google.com; s=arc-20160816; b=gajXsVNAAgRahWYIsKN9fsM3DxAjJ6sffvAEfOTTCunmT6wGC5QacEK411WwZi6sMM j7JZsq2GvIkoXhko855b2i4fxO7rFa8TdrjJ0/mS68g+6zzqVAzZvMyeHQFp38hnHQdB u6Ohvpi+8B+DEe+s7saPAeZfGqCki9wEmc9KXXF6V58GqCpY8JmSdfeGRx9E5B2LbEmI KrFrc8J8nMZ+fvidfL6g7XTr5NuksgUVKlxbAna8yEbv8J+bSPbqBimRtLKVagVSjLGe aFL3JOwugMhPwWhFS40puYurkZThlbQw7QPG0nJBcWYjdQCcCqcXafyAiGSUcKkSLIZO Wcdw== 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=0Vb7H9yb9KegAZrOM/FxSK7XrXYOMYkf14Y75SGMfiQ=; b=k6SqT6sx2D/LAmGSKSWsUkldz52bY6pe9GSf1qsnVHJuspDUrS3QlwREXeO44f0cTP WSNmd67FDddqS15yORfnBBYJzqETPd/CKn32OQG3viXIDrwug5SnBK/OtA8RhKa02c+I 4+Hkb436RkURXO5NTyzJZoZaHP1yKCvrZFw4Lti7VhSJbtzegxKZej1hys00dQRhRjqh e08OM6Ub4FjqE6BmbAB3Y2qPXUyAigEQktW6/6+kddU6Bj+tGFOCXIThTkzOesFMNFB8 Hn8J4FLp6lSyzVbEjr0NZzOnj6IrQzwRQ4fYSTbUpYl1W6zKVpjTGkoIZ/G+776C7l/C N3ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JNw3aFUb; 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 ja16si2922973ejc.611.2021.05.20.10.38.42; Thu, 20 May 2021 10:39: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=JNw3aFUb; 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 S235123AbhETKGG (ORCPT + 99 others); Thu, 20 May 2021 06:06:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:59108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235316AbhETJ7w (ORCPT ); Thu, 20 May 2021 05:59:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BC8C96162F; Thu, 20 May 2021 09:38:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503533; bh=rsAVbisVqPMt5XCxbmhAn8+um5OsABO5xWVAhhGlUCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JNw3aFUbB5Yy7ZENf1oVXQZ4RRnGKW3AGCbxgIowVvyxGDRq7TOchj9Z0xyPKS3qf qSPrIiMfABpoS3A/jrTKUec1vLgEYQsCVEAZ52aSQrRWH+/Q1X0M1iXpScjV6Q4NoB +2xkjKeUaHeV/snMeIRVEzj7l5SXQZYleiUi/ktI= 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.19 265/425] net: thunderx: Fix unintentional sign extension issue Date: Thu, 20 May 2021 11:20:34 +0200 Message-Id: <20210520092140.155350579@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 9a4cfa61ed93..d9bcbe469ab9 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c @@ -779,7 +779,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