From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=ray.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D0C3A2194EB7B for ; Tue, 5 Mar 2019 21:35:29 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2019 21:35:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,446,1544515200"; d="scan'208";a="131936624" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga007.fm.intel.com with ESMTP; 05 Mar 2019 21:35:29 -0800 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 5 Mar 2019 21:35:29 -0800 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 5 Mar 2019 21:35:28 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.74]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.223]) with mapi id 14.03.0415.000; Wed, 6 Mar 2019 13:35:26 +0800 From: "Ni, Ray" To: "edk2-devel@lists.01.org" , "Gao, Liming" CC: "Dong, Eric" , "Ni, Ray" , "Chen, Chen A" Thread-Topic: [edk2] [PATCH] UefiCpuPkg/Microcode.c: Add verification before calculate CheckSum32 Thread-Index: AQHU0ul7UqdVE3cgxE+vP6lcradFFaX939nwgAA3btA= Date: Wed, 6 Mar 2019 05:35:26 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C060342@SHSMSX104.ccr.corp.intel.com> References: <20190305002118.10572-1-chen.a.chen@intel.com> <734D49CCEBEEF84792F5B80ED585239D5C05FD4A@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5C05FD4A@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] UefiCpuPkg/Microcode.c: Add verification before calculate CheckSum32 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Mar 2019 05:35:30 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Liming, Do I need any approval from you side before pushing the commit? Thanks, Ray > -----Original Message----- > From: edk2-devel On Behalf Of Ni, Ray > Sent: Wednesday, March 6, 2019 10:15 AM > To: Chen, Chen A ; edk2-devel@lists.01.org > Cc: Dong, Eric > Subject: Re: [edk2] [PATCH] UefiCpuPkg/Microcode.c: Add verification > before calculate CheckSum32 >=20 > Reviewed-by: Ray Ni >=20 > > -----Original Message----- > > From: edk2-devel On Behalf Of Chen A > > Chen > > Sent: Tuesday, March 5, 2019 8:21 AM > > To: edk2-devel@lists.01.org > > Cc: Dong, Eric > > Subject: [edk2] [PATCH] UefiCpuPkg/Microcode.c: Add verification > > before calculate CheckSum32 > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1020 > > > > Should make sure the TotalSize of Microcode is aligned with 4 bytes > > before calling CalculateSum32 function. > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Chen A Chen > > Cc: Ray Ni > > Cc: Eric Dong > > --- > > UefiCpuPkg/Library/MpInitLib/Microcode.c | 31 > ++++++++++++++++++++-- > > --------- > > 1 file changed, 20 insertions(+), 11 deletions(-) > > > > diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c > > b/UefiCpuPkg/Library/MpInitLib/Microcode.c > > index 5f9ae22794..643a6f94f4 100644 > > --- a/UefiCpuPkg/Library/MpInitLib/Microcode.c > > +++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c > > @@ -166,20 +166,29 @@ MicrocodeDetect ( > > // > > CorrectMicrocode =3D FALSE; > > > > - // > > - // Save an in-complete CheckSum32 from CheckSum Part1 for common > > parts. > > - // > > if (MicrocodeEntryPoint->DataSize =3D=3D 0) { > > - InCompleteCheckSum32 =3D CalculateSum32 ( > > - (UINT32 *) MicrocodeEntryPoint, > > - sizeof (CPU_MICROCODE_HEADER) + 2000 > > - ); > > + TotalSize =3D sizeof (CPU_MICROCODE_HEADER) + 2000; > > } else { > > - InCompleteCheckSum32 =3D CalculateSum32 ( > > - (UINT32 *) MicrocodeEntryPoint, > > - sizeof (CPU_MICROCODE_HEADER) + > MicrocodeEntryPoint- > > >DataSize > > - ); > > + TotalSize =3D sizeof (CPU_MICROCODE_HEADER) + > > + MicrocodeEntryPoint- > > >DataSize; > > } > > + > > + /// > > + /// Check overflow and whether TotalSize is aligned with 4 bytes. > > + /// > > + if ( ((UINTN)MicrocodeEntryPoint + TotalSize) > MicrocodeEnd || > > + (TotalSize & 0x3) !=3D 0 > > + ) { > > + MicrocodeEntryPoint =3D (CPU_MICROCODE_HEADER *) (((UINTN) > > MicrocodeEntryPoint) + SIZE_1KB); > > + continue; > > + } > > + > > + // > > + // Save an in-complete CheckSum32 from CheckSum Part1 for common > > parts. > > + // > > + InCompleteCheckSum32 =3D CalculateSum32 ( > > + (UINT32 *) MicrocodeEntryPoint, > > + TotalSize > > + ); > > InCompleteCheckSum32 -=3D MicrocodeEntryPoint- > > >ProcessorSignature.Uint32; > > InCompleteCheckSum32 -=3D MicrocodeEntryPoint->ProcessorFlags; > > InCompleteCheckSum32 -=3D MicrocodeEntryPoint->Checksum; > > -- > > 2.16.2.windows.1 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel