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.151; helo=mga17.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 1653B211D56BB for ; Tue, 5 Mar 2019 21:38:12 -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 fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2019 21:38:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,446,1544515200"; d="scan'208";a="131936970" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga007.fm.intel.com with ESMTP; 05 Mar 2019 21:38:12 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) 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:38:11 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.74]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.80]) with mapi id 14.03.0415.000; Wed, 6 Mar 2019 13:38:10 +0800 From: "Gao, Liming" To: "Ni, Ray" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Chen, Chen A" Thread-Topic: [edk2] [PATCH] UefiCpuPkg/Microcode.c: Add verification before calculate CheckSum32 Thread-Index: AQHU0ul9NPxcPJ0jyU2tTPhKIEOoJqX9WPMAgAA36wCAAIaSgA== Date: Wed, 6 Mar 2019 05:38:10 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3FC008@SHSMSX104.ccr.corp.intel.com> References: <20190305002118.10572-1-chen.a.chen@intel.com> <734D49CCEBEEF84792F5B80ED585239D5C05FD4A@SHSMSX104.ccr.corp.intel.com> <734D49CCEBEEF84792F5B80ED585239D5C060342@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5C060342@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDAzNzJkN2QtZDRhMS00OTFiLWIxNmUtNjJhOTMyOWE4MzYyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiN1U1NWg0U25Da2d6cVZXa2hkZnFcL0t0dExcL1VLSzIzYUhqczZhdFgxU3ZhQ01UeGszbGFhTjBFNVRxamNISVRLIn0= dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action 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:38:13 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This is a bug. I agree to add it into Q1 stable tag.=20 Thanks Liming > -----Original Message----- > From: Ni, Ray > Sent: Tuesday, March 5, 2019 9:35 PM > To: edk2-devel@lists.01.org; Gao, Liming > Cc: Dong, Eric ; Ni, Ray ; Chen, C= hen A > Subject: RE: [edk2] [PATCH] UefiCpuPkg/Microcode.c: Add verification befo= re calculate CheckSum32 >=20 > Liming, > Do I need any approval from you side before pushing the commit? >=20 > Thanks, > Ray >=20 > > -----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 > > > > Reviewed-by: Ray Ni > > > > > -----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