Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1007990pxb; Wed, 1 Sep 2021 15:09:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdbPn944ZukBLJrRc1SCh+A0zkUDUv6TCo8jZ9AMqhfff4tmKTH0dfprsUBB/DahA/Kni8 X-Received: by 2002:aa7:cb0f:: with SMTP id s15mr125274edt.190.1630534144723; Wed, 01 Sep 2021 15:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630534144; cv=none; d=google.com; s=arc-20160816; b=aGtZQBlAnab/hQz5GXxqSap7PmUUIx0e5D86V28nJlnm7NECG1gSk3dg4EdKyAhUwo YFSyUVZKc+YhVA3d4YghP12nkcxxZ9WwfCNjVn10dKzgelhRZhkiISku6azCt+3eJGFL mTZLW1rlBY06WuKxSN2K+DsQfdZ3QnzOHCYLCepYirjrUL2wwAhPL5uGw0zRQJeyfYCW WhlZO1faQPVTpVlEzR39y3+qBvdDVXRDZsH5z4O5Uooqg7SvfTXxfcOMnOcyz8e5sTok +5kIcEQOrnJwBzipyDg4jcu1VG8jUhMe5poHC9rvE5xs4TmOBuPUCAjvLyCIQ1X3b+bS qCaw== 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=VLLTxOOG+0t6AjNB/0SIbMkrDSBFbA9jd4zHxRLPB1Q=; b=PA1P49zKrgjn9yGea+vTzSmp6Ls4Cbi/grIPEMjMzimX7w8fxaOeRBr/tgjfJid6xZ gNp/GJH1QZ9W922pUknQmCwNVCVGVxioBv99kDG8TFxREU5S+F1yDUCwHH8+PX2wM3Fu 8fYlNXD5+JdCIOzMorOS4EpVKZEs/iiCfXla7R+5UDyHH4WXbLZ/CnQZOvwbbUEOhSPO RF7R2gqEKx57stbb2WTt4zVJAWY6gVksWBOI9EWGLQJ0jub9ozL1HadrtqFIlcu031Jg W3mIqtApj8IPhbhE0H5K0ulNqoQTjhsr2D7POIdKhAS+XDXJ09muMfiDtORGoByW/o/i NkWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E8EFUZUu; 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 dg17si27608edb.308.2021.09.01.15.08.40; Wed, 01 Sep 2021 15:09:04 -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=E8EFUZUu; 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 S1345673AbhIAMv7 (ORCPT + 99 others); Wed, 1 Sep 2021 08:51:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:49254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344224AbhIAMrI (ORCPT ); Wed, 1 Sep 2021 08:47:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 38A8F6112E; Wed, 1 Sep 2021 12:40:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1630500011; bh=PR5+UzwjhjiHksRjiJxo2SybVQtKJ2lalyfiAKsmi+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E8EFUZUuTYUG/MEiQDBt2dP0gbKpnBZVeMXe9H1X7vIyJhYUua83eE/LNqJ6XK2hP wt0cOfXnENC0wzonc1G5oICX+niCttzqsZeEGrNN8BXOm+QsQDHKRdlyhx3AfwNxZc GoiGtETTZbMo8wiotb8grJND+b75u84ybwC5F5LA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , "Peter Zijlstra (Intel)" , Ingo Molnar , Kan Liang , Sasha Levin Subject: [PATCH 5.13 070/113] perf/x86/intel/uncore: Fix integer overflow on 23 bit left shift of a u32 Date: Wed, 1 Sep 2021 14:28:25 +0200 Message-Id: <20210901122304.330892212@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210901122301.984263453@linuxfoundation.org> References: <20210901122301.984263453@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 0b3a8738b76fe2087f7bc2bd59f4c78504c79180 ] The u32 variable pci_dword is being masked with 0x1fffffff and then left shifted 23 places. The shift is a u32 operation,so a value of 0x200 or more in pci_dword will overflow the u32 and only the bottow 32 bits are assigned to addr. I don't believe this was the original intent. Fix this by casting pci_dword to a resource_size_t to ensure no overflow occurs. Note that the mask and 12 bit left shift operation does not need this because the mask SNR_IMC_MMIO_MEM0_MASK and shift is always a 32 bit value. Fixes: ee49532b38dd ("perf/x86/intel/uncore: Add IMC uncore support for Snow Ridge") Addresses-Coverity: ("Unintentional integer overflow") Signed-off-by: Colin Ian King Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Reviewed-by: Kan Liang Link: https://lore.kernel.org/r/20210706114553.28249-1-colin.king@canonical.com Signed-off-by: Sasha Levin --- arch/x86/events/intel/uncore_snbep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 1f7bb4898a9d..a8f02c889ae8 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -4701,7 +4701,7 @@ static void __snr_uncore_mmio_init_box(struct intel_uncore_box *box, return; pci_read_config_dword(pdev, SNR_IMC_MMIO_BASE_OFFSET, &pci_dword); - addr = (pci_dword & SNR_IMC_MMIO_BASE_MASK) << 23; + addr = ((resource_size_t)pci_dword & SNR_IMC_MMIO_BASE_MASK) << 23; pci_read_config_dword(pdev, mem_offset, &pci_dword); addr |= (pci_dword & SNR_IMC_MMIO_MEM0_MASK) << 12; -- 2.30.2