Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4624171pxj; Wed, 12 May 2021 09:28:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4AFFWQCAnG3Av7sCLtmomC9qbCSZI9X8x1gM75ihkOoBTYTcA7q5WLI13ks1Op63lows8 X-Received: by 2002:a17:906:cc48:: with SMTP id mm8mr38655663ejb.344.1620836924133; Wed, 12 May 2021 09:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836924; cv=none; d=google.com; s=arc-20160816; b=q+X+Yw4kfEkzmW3pp32bES29ocPJPaIQBtorqVSbq7Op3qTJLQZZQeayvWUYyl1wPW 9jtRvaCR4hCbcCBUZY7+xNofOAMippEnslWaSDtxHjwDQFXQf86hsdus8bGl+3cLZA9m s5k3q+reAiMTpf0wxrSmL5kr/7r9hjJFrY2rz02RlJB9XUwH7qBK5YAi+CvFbYRchOhl MERxnn7n+b+l/TnndQlRj1YMASEVCOSmihdEjpZFNnlEsmTcr5PRlohq5mM305D+uAa7 vEk2XOUduMwnCMR4OEQz+VG37QwlZYmMHFYHn7h5cYJ1yrvsZF1QR1V9gEloFVPeljsN hITQ== 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=8MhazfxotYo2wL87FfdcQg3KY8/D2YPBt0hpgYYo97Y=; b=d35Tj/8oLoJHoB7Em0Faz+cPZ1K4FezKdc3FMu7rGai/rjdQKppcGhkkIKC+e24Hxu 3HU922qvGRD8XmiBGZHmORY92w0FHP8QmxP9z8oGn15NwQ2h8LhGE7X8qmGDgdzz+SUr MTDy1nfu1dBhjVkDLVD2cPKVNFbSz3O/fIIeIH2zgZ46U0OSTjHTKDeIc8wCRAg8HZOt ImzhgaK56k/Jp/O1iEVGwnxYEoA+GrW5kN27HlhBelEkrc44MM3lWo6N7Rg0EXbU0g8H IYh1C6SsArdpH8Vftg9z4ZyuKl/EhrXl2heyhsUZg2Zfb6T+/5gl9Y4SS33S88XCMlCW 7q3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O7x7xA1N; 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 s24si387673ejd.357.2021.05.12.09.28.19; Wed, 12 May 2021 09:28:44 -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=O7x7xA1N; 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 S241388AbhELQ1H (ORCPT + 99 others); Wed, 12 May 2021 12:27:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:56350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236450AbhELPh6 (ORCPT ); Wed, 12 May 2021 11:37:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 12C2061C68; Wed, 12 May 2021 15:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832790; bh=X7kW5XeS5iSsyQsOvlCif7BER4DQTsz13EwFSfoR8g0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O7x7xA1NmbGmM90jgJUEJsXkZ77dIOcPaBScs/u/cfRElAyGLXrS9n9oeefZzllKK bRrydLHtlH1HOtTxW0JqaY4Bp9q/+IcqULC0SP0DXoAonfxBXzSPpu/BzD/LPX3Shk s3g25b6RwdXZCc7raWzCb5HpAro6cOL+pM79X6kw= 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 424/530] cxgb4: Fix unintentional sign extension issues Date: Wed, 12 May 2021 16:48:54 +0200 Message-Id: <20210512144833.706658184@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 dd2c79677375c37f8f9f8d663eb4708495d595ef ] The shifting of the u8 integers f->fs.nat_lip[] by 24 bits to the left will be promoted to a 32 bit signed int and then sign-extended to a u64. In the event that the top bit of the u8 is set then all then all the upper 32 bits of the u64 end up as also being set because of the sign-extension. Fix this by casting the u8 values to a u64 before the 24 bit left shift. Addresses-Coverity: ("Unintended sign extension") Fixes: 12b276fbf6e0 ("cxgb4: add support to create hash filters") Signed-off-by: Colin Ian King Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c index 83b46440408b..bde8494215c4 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c @@ -174,31 +174,31 @@ static void set_nat_params(struct adapter *adap, struct filter_entry *f, WORD_MASK, f->fs.nat_lip[15] | f->fs.nat_lip[14] << 8 | f->fs.nat_lip[13] << 16 | - f->fs.nat_lip[12] << 24, 1); + (u64)f->fs.nat_lip[12] << 24, 1); set_tcb_field(adap, f, tid, TCB_SND_UNA_RAW_W + 1, WORD_MASK, f->fs.nat_lip[11] | f->fs.nat_lip[10] << 8 | f->fs.nat_lip[9] << 16 | - f->fs.nat_lip[8] << 24, 1); + (u64)f->fs.nat_lip[8] << 24, 1); set_tcb_field(adap, f, tid, TCB_SND_UNA_RAW_W + 2, WORD_MASK, f->fs.nat_lip[7] | f->fs.nat_lip[6] << 8 | f->fs.nat_lip[5] << 16 | - f->fs.nat_lip[4] << 24, 1); + (u64)f->fs.nat_lip[4] << 24, 1); set_tcb_field(adap, f, tid, TCB_SND_UNA_RAW_W + 3, WORD_MASK, f->fs.nat_lip[3] | f->fs.nat_lip[2] << 8 | f->fs.nat_lip[1] << 16 | - f->fs.nat_lip[0] << 24, 1); + (u64)f->fs.nat_lip[0] << 24, 1); } else { set_tcb_field(adap, f, tid, TCB_RX_FRAG3_LEN_RAW_W, WORD_MASK, f->fs.nat_lip[3] | f->fs.nat_lip[2] << 8 | f->fs.nat_lip[1] << 16 | - f->fs.nat_lip[0] << 24, 1); + (u64)f->fs.nat_lip[0] << 25, 1); } } @@ -208,25 +208,25 @@ static void set_nat_params(struct adapter *adap, struct filter_entry *f, WORD_MASK, f->fs.nat_fip[15] | f->fs.nat_fip[14] << 8 | f->fs.nat_fip[13] << 16 | - f->fs.nat_fip[12] << 24, 1); + (u64)f->fs.nat_fip[12] << 24, 1); set_tcb_field(adap, f, tid, TCB_RX_FRAG2_PTR_RAW_W + 1, WORD_MASK, f->fs.nat_fip[11] | f->fs.nat_fip[10] << 8 | f->fs.nat_fip[9] << 16 | - f->fs.nat_fip[8] << 24, 1); + (u64)f->fs.nat_fip[8] << 24, 1); set_tcb_field(adap, f, tid, TCB_RX_FRAG2_PTR_RAW_W + 2, WORD_MASK, f->fs.nat_fip[7] | f->fs.nat_fip[6] << 8 | f->fs.nat_fip[5] << 16 | - f->fs.nat_fip[4] << 24, 1); + (u64)f->fs.nat_fip[4] << 24, 1); set_tcb_field(adap, f, tid, TCB_RX_FRAG2_PTR_RAW_W + 3, WORD_MASK, f->fs.nat_fip[3] | f->fs.nat_fip[2] << 8 | f->fs.nat_fip[1] << 16 | - f->fs.nat_fip[0] << 24, 1); + (u64)f->fs.nat_fip[0] << 24, 1); } else { set_tcb_field(adap, f, tid, @@ -234,13 +234,13 @@ static void set_nat_params(struct adapter *adap, struct filter_entry *f, WORD_MASK, f->fs.nat_fip[3] | f->fs.nat_fip[2] << 8 | f->fs.nat_fip[1] << 16 | - f->fs.nat_fip[0] << 24, 1); + (u64)f->fs.nat_fip[0] << 24, 1); } } set_tcb_field(adap, f, tid, TCB_PDU_HDR_LEN_W, WORD_MASK, (dp ? (nat_lp[1] | nat_lp[0] << 8) : 0) | - (sp ? (nat_fp[1] << 16 | nat_fp[0] << 24) : 0), + (sp ? (nat_fp[1] << 16 | (u64)nat_fp[0] << 24) : 0), 1); } -- 2.30.2