From nobody Sun May 5 00:16:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+42833+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42833+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1561475754; cv=none; d=zoho.com; s=zohoarc; b=d6BqGOFMi63txs7a5AxGEsoPGnsE+Ng/8tIXefmXh0yjSbBe+JX5812HpZS4MsEIRMhamGPuKhs5SJ5W4iz2Gu4UajdRRbfEbLcdSma/mhkIJt1ettKCJGxnSbOUMvF8vLEyJaTODX4CYdH7XhwCy8USATI4vBkcqQBdopAnjps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561475754; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=hX7lXy3wxsG0xaWWUocnIIT8jtH2EJ24DatWAhId2Mc=; b=ihoRAS5s5l5JOtQ1D0RDbaBPv3ocGa7/AY8covWnzMXwtPcQeV35Uvjakm+qAh7k2GMKQRZWpRmgPVBSufDyrwqnfWZp46RTFABQCVU/HOBRbNkIjhfEVt4IrIzNj9JdTmy2fM/AMGjyIviBzn7xp5To2/9MvjePkNPn4fB2rAU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42833+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1561475754874407.60390266510717; Tue, 25 Jun 2019 08:15:54 -0700 (PDT) Return-Path: X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by groups.io with SMTP; Tue, 25 Jun 2019 08:15:46 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2019 08:15:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,416,1557212400"; d="scan'208";a="182908362" X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga001.fm.intel.com with ESMTP; 25 Jun 2019 08:15:44 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Liming Gao Subject: [edk2-devel] [PATCH V2] UefiCpuPkg/MpInitLib: MicrocodeDetect: Ensure checked range is valid Date: Tue, 25 Jun 2019 23:15:41 +0800 Message-Id: <20190625151541.28632-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1561475746; bh=nJKtrcdCWT9wI4uv0NFjOG4q2EZKisbbN90QrDeg24w=; h=Cc:Date:From:Reply-To:Subject:To; b=CY9JLxUCyT5fwOTFTdGzP/hfQLl/6emB4Hd6d/+syzoWJpaBeAi+om1m0ES7XdTtp0f GHQZavxPSW+BoAPtTYrlJ5fj1hFBh5U4WeKohbCvyaSpQ9JOS3iiiM80ftLobVl80WEfV XiN5s2OxNUE5w/wP0avwqevPdsdhrofVsno= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1934 V1: Originally, the checksum part would done before verfiy the microcode data. Which meas the checksum would be done for a meaningless data. It would cause a incorrect TotalSize (the size of microcode data), then incorrect checksum and incorrect pointer increasing would happen. To fix this, move the checksum part 1 section in 'if (MicrocodeEntryPoint->HeaderVersion =3D=3D 0x1)' section for a valid microcode data. V2: 'if (MicrocodeEntryPoint->HeaderVersion =3D=3D 0x1)' condition doesn't make sure the entry data is a valid microcode. So abandon it. Instead, make sure the checked data is in the microcode data range. Because the DataSize of non microcde data may make (MicrocodeEntryPoint + TotalSize) larger than 0xffffffff. For PEI driver, UINTN is 32bit and the result is overflow and it may be a very small value. That means the checksum check would be done out of the microcode range. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Liming Gao Signed-off-by: Zhichao Gao Reviewed-by: Eric Dong --- UefiCpuPkg/Library/MpInitLib/Microcode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c b/UefiCpuPkg/Library/= MpInitLib/Microcode.c index 4763dcfebe..6c0995cb0d 100644 --- a/UefiCpuPkg/Library/MpInitLib/Microcode.c +++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c @@ -1,7 +1,7 @@ /** @file Implementation of loading microcode on processors. =20 - Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -170,6 +170,7 @@ MicrocodeDetect ( /// Check overflow and whether TotalSize is aligned with 4 bytes. /// if ( ((UINTN)MicrocodeEntryPoint + TotalSize) > MicrocodeEnd || + ((UINTN)MicrocodeEntryPoint + TotalSize) < (UINTN) CpuMpData->Mic= rocodePatchAddress || (TotalSize & 0x3) !=3D 0 ) { MicrocodeEntryPoint =3D (CPU_MICROCODE_HEADER *) (((UINTN) Microcode= EntryPoint) + SIZE_1KB); --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#42833): https://edk2.groups.io/g/devel/message/42833 Mute This Topic: https://groups.io/mt/32204622/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-